From 0c08b5c044cfd16d73de0cd9834e8f4901771184 Mon Sep 17 00:00:00 2001 From: jumagura Date: Tue, 9 May 2023 01:19:46 -0400 Subject: [PATCH] DEV: Add test for enabled and disabled custom field for unsuscribed plan --- .../admin-custom-fields-unsuscribed-test.js | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js b/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js index 59fa2759..7f331c33 100644 --- a/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js +++ b/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js @@ -1,6 +1,11 @@ -import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; +import { + acceptance, + query, + visible, +} from "discourse/tests/helpers/qunit-helpers"; import { test } from "qunit"; -import { findAll, visit } from "@ember/test-helpers"; +import { click, findAll, visit } from "@ember/test-helpers"; +import selectKit from "discourse/tests/helpers/select-kit-helper"; import { getCustomFields, getUnsubscribedAdminWizards, @@ -37,4 +42,60 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) { "it displays wizard message" ); }); + test("view available custom fields for unsubscribed plan", async (assert) => { + await visit("/admin/wizards/custom-fields"); + await click(".admin-wizard-controls .btn-icon-text"); + assert.ok( + visible(".wizard-subscription-selector"), + "custom field class is present" + ); + assert.ok( + visible(".wizard-subscription-selector-header"), + "custom field type is present" + ); + assert.ok(visible(".input"), "custom field name is present"); + assert.ok(visible(".multi-select"), "custom field serializer is present"); + assert.ok(visible(".actions"), "custom field action buttons are present"); + + const dropdown1 = selectKit( + '.admin-wizard-container details:has(summary[name="Filter by: Select a class"])' + ); + await dropdown1.expand(); + let enabledOptions1 = findAll( + '.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li:not(.disabled)' + ); + let disabledOptions1 = findAll( + '.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li.disabled' + ); + assert.equal( + enabledOptions1.length, + 2, + "There are two enabled options for class fields" + ); + assert.equal( + disabledOptions1.length, + 2, + "There are two disabled options for class fields" + ); + const dropdown2 = selectKit( + '.admin-wizard-container details:has(summary[name="Filter by: Select a type"])' + ); + await dropdown2.expand(); + let enabledOptions2 = findAll( + '.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li:not(.disabled)' + ); + let disabledOptions2 = findAll( + '.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li.disabled' + ); + assert.equal( + enabledOptions2.length, + 3, + "There are three enabled options for type" + ); + assert.equal( + disabledOptions2.length, + 1, + "There is one disabled option for type" + ); + }); });