0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 11:52:54 +01:00

DEV: Add settled to prevent rendering errors

Dieser Commit ist enthalten in:
jumagura 2022-12-21 01:30:25 -04:00
Ursprung bd03d62da1
Commit 9583851501
5 geänderte Dateien mit 69 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -4,7 +4,7 @@ import {
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { findAll, visit } from "@ember/test-helpers";
import { findAll, settled, visit } from "@ember/test-helpers";
acceptance("Admin | Custom Fields", function (needs) {
needs.user();
@ -322,6 +322,7 @@ acceptance("Admin | Custom Fields", function (needs) {
test("viewing custom fields tab", async (assert) => {
await visit("/admin/wizards/custom-fields");
await settled();
assert.ok(find("table"));
assert.ok(findAll("table tbody tr").length === 9);
assert.ok(
@ -331,6 +332,7 @@ acceptance("Admin | Custom Fields", function (needs) {
"it displays wizard message"
);
await click(".btn-icon-text");
await settled();
assert.ok(
visible(".wizard-subscription-selector"),
"custom field class is present"

Datei anzeigen

@ -1,6 +1,6 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, find, findAll, visit } from "@ember/test-helpers";
import { click, find, findAll, settled, visit } from "@ember/test-helpers";
acceptance("Admin | Manager", function (needs) {
needs.user();
@ -290,6 +290,7 @@ acceptance("Admin | Manager", function (needs) {
});
test("viewing manager fields content", async (assert) => {
await visit("/admin/wizards/manager");
await settled();
assert.ok(
query(".message-content").innerText.includes(
"Export, import or destroy wizards"
@ -313,11 +314,13 @@ acceptance("Admin | Manager", function (needs) {
"the export button is disabled when export checkbox is unchecked"
);
await click(exportCheck);
await settled();
assert.ok(
!exportButton.hasAttribute("disabled"),
"the export button is enabled when export checkbox is clicked"
);
await click(exportCheck);
await settled();
assert.ok(
exportButton.hasAttribute("disabled"),
"the export button is disabled when export checkbox is unchecked"
@ -328,11 +331,13 @@ acceptance("Admin | Manager", function (needs) {
"the destroy button is disabled when destroy checkbox is unchecked"
);
await click(destroyCheck);
await settled();
assert.ok(
!destroyButton.hasAttribute("disabled"),
"the destroy button is enabled when destroy checkbox is clicked"
);
await click(destroyCheck);
await settled();
assert.ok(
destroyButton.hasAttribute("disabled"),
"the destroy button is disabled when destroy checkbox is unchecked"

Datei anzeigen

@ -4,7 +4,7 @@ import {
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { findAll, visit } from "@ember/test-helpers";
import { findAll, settled, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
@ -417,7 +417,9 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
test("creting a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await settled();
await click('button:contains("Create Wizard")');
await settled();
assert.ok(
query(".message-content").innerText.includes(
"You're creating a new wizard"
@ -427,6 +429,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
assert.step("Step 1: Inserting a title");
const wizardTitle = "New wizard for testing";
await fillIn(".wizard-header input", wizardTitle);
await settled();
assert.equal(
$(".wizard-header input").val(),
wizardTitle,
@ -448,15 +451,18 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
".wizard-subscription-container .subscription-settings .setting-value input"
);
await click(subsFeature);
await settled();
assert.ok(subsFeature.is(":checked"), "subscription feature available");
assert.step("Step 2: Creating a step section");
const stepAddBtn = find(".step .link-list button:contains('Add')");
await click(stepAddBtn);
await settled();
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
await settled();
const stepButtonText = $.trim(
$(".step div[data-id='step_1'] button").text()
);
@ -472,6 +478,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
assert.step("Step 3: Creating a field section");
const fieldAddBtn = find(".field .link-list button:contains('Add')");
await click(fieldAddBtn);
await settled();
assert.ok(
!visible(".wizard-custom-field button.undo-changes"),
"clear button is not rendered"
@ -481,6 +488,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
await settled();
assert.ok(
visible(".wizard-custom-field button.undo-changes"),
"clear button is rendered after filling content"
@ -494,6 +502,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
const clearBtn = find(`.wizard-custom-field button.undo-changes`);
await click(clearBtn);
await settled();
fieldButtonText = $(".field div[data-id='step_1_field_1'] button")
.text()
.trim();
@ -506,6 +515,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
await fieldTypeDropdown.expand();
await fieldTypeDropdown.selectRowByValue("text");
await settled();
assert.ok(
query(".wizard-custom-field .message-content").innerText.includes(
"You're editing a field"
@ -523,6 +533,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
const actionAddBtn = find(".action .link-list button:contains('Add')");
await click(actionAddBtn);
await settled();
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
@ -536,6 +547,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
".wizard-custom-action .setting-value .select-kit"
);
await actionTypeDropdown.expand();
await settled();
const listEnabled = findAll(
".wizard-custom-action .setting .setting-value ul li:not(.disabled)"
);
@ -552,6 +564,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
"Enabled items displayed correctly in action dropdown"
);
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.ok(
query(".wizard-custom-action .message-content").innerText.includes(
"You're editing an action"
@ -567,6 +580,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("send_to_api");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -576,6 +590,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("create_category");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -585,6 +600,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("create_group");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -594,7 +610,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.step("Step 5: Save wizard");
const saveButton = find(
'.admin-wizard-buttons button:contains("Save Changes")'
@ -604,6 +620,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
"delete wizard button not displayed"
);
await click(saveButton);
await settled();
assert.equal(
currentURL(),
"/admin/wizards/wizard/new_wizard_for_testing",

Datei anzeigen

@ -4,7 +4,7 @@ import {
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { findAll, visit } from "@ember/test-helpers";
import { findAll, settled, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
@ -418,6 +418,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
test("creting a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await click('button:contains("Create Wizard")');
await settled();
assert.ok(
query(".message-content").innerText.includes(
"You're creating a new wizard"
@ -427,6 +428,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
assert.step("Step 1: Inserting a title");
const wizardTitle = "New wizard for testing";
await fillIn(".wizard-header input", wizardTitle);
await settled();
assert.equal(
$(".wizard-header input").val(),
wizardTitle,
@ -448,15 +450,18 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
".wizard-subscription-container .subscription-settings .setting-value input"
);
await click(subsFeature);
await settled();
assert.ok(subsFeature.is(":checked"), "subscription feature available");
assert.step("Step 2: Creating a step section");
const stepAddBtn = find(".step .link-list button:contains('Add')");
await click(stepAddBtn);
await settled();
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
await settled();
const stepButtonText = $.trim(
$(".step div[data-id='step_1'] button").text()
);
@ -472,6 +477,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
assert.step("Step 3: Creating a field section");
const fieldAddBtn = find(".field .link-list button:contains('Add')");
await click(fieldAddBtn);
await settled();
assert.ok(
!visible(".wizard-custom-field button.undo-changes"),
"clear button is not rendered"
@ -481,6 +487,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
await settled();
assert.ok(
visible(".wizard-custom-field button.undo-changes"),
"clear button is rendered after filling content"
@ -494,6 +501,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
const clearBtn = find(`.wizard-custom-field button.undo-changes`);
await click(clearBtn);
await settled();
fieldButtonText = $(".field div[data-id='step_1_field_1'] button")
.text()
.trim();
@ -506,6 +514,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await fieldTypeDropdown.expand();
await fieldTypeDropdown.selectRowByValue("text");
await settled();
assert.ok(
query(".wizard-custom-field .message-content").innerText.includes(
"You're editing a field"
@ -521,6 +530,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
assert.step("Step 4: Creating a action section");
const actionAddBtn = find(".action .link-list button:contains('Add')");
await click(actionAddBtn);
await settled();
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
@ -534,6 +544,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
".wizard-custom-action .setting-value .select-kit"
);
await actionTypeDropdown.expand();
await settled();
const listEnabled = findAll(
".wizard-custom-action .setting .setting-value ul li:not(.disabled)"
);
@ -550,6 +561,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
"Enabled items displayed correctly in action dropdown"
);
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.ok(
query(".wizard-custom-action .message-content").innerText.includes(
"You're editing an action"
@ -565,6 +577,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("send_message");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -574,6 +587,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("watch_categories");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -583,6 +597,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("add_to_group");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -592,7 +607,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.step("Step 5: Save wizard");
const saveButton = find(
'.admin-wizard-buttons button:contains("Save Changes")'
@ -602,6 +617,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
"delete wizard button not displayed"
);
await click(saveButton);
await settled();
assert.equal(
currentURL(),
"/admin/wizards/wizard/new_wizard_for_testing",

Datei anzeigen

@ -4,7 +4,7 @@ import {
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { findAll, visit } from "@ember/test-helpers";
import { findAll, settled, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
@ -417,6 +417,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
test("viewing content for a selected wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await settled();
assert.ok(
query(".message-content").innerText.includes(
"Select a wizard, or create a new one"
@ -426,13 +427,16 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
const wizards = selectKit(".select-kit");
await wizards.expand();
await wizards.selectRowByValue("this_is_testing_wizard");
await settled();
assert.ok(
query(".message-content").innerText.includes("You're editing a wizard"),
"it displays wizard message for a selected wizard"
);
await wizards.expand();
await settled();
const li = find('[data-name="Select a wizard"]');
await click(li);
await settled();
const wizardContainerDiv = find(".admin-wizard-container");
assert.ok(
wizardContainerDiv.children().length === 0,
@ -442,6 +446,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
test("creting a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await click('button:contains("Create Wizard")');
await settled();
assert.ok(
query(".message-content").innerText.includes(
"You're creating a new wizard"
@ -451,6 +456,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
assert.step("Step 1: Inserting a title");
const wizardTitle = "New wizard for testing";
await fillIn(".wizard-header input", wizardTitle);
await settled();
assert.equal(
$(".wizard-header input").val(),
wizardTitle,
@ -471,11 +477,13 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
assert.step("Step 2: Creating a step section");
const stepAddBtn = find(".step .link-list button:contains('Add')");
await click(stepAddBtn);
await settled();
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
await settled();
const stepButtonText = $.trim(
$(".step div[data-id='step_1'] button").text()
);
@ -492,6 +500,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
assert.step("Step 3: Creating a field section");
const fieldAddBtn = find(".field .link-list button:contains('Add')");
await click(fieldAddBtn);
await settled();
assert.ok(
!visible(".wizard-custom-field button.undo-changes"),
"clear button is not rendered"
@ -501,6 +510,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
await settled();
assert.ok(
visible(".wizard-custom-field button.undo-changes"),
"clear button is rendered after filling content"
@ -514,6 +524,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
const clearBtn = find(`.wizard-custom-field button.undo-changes`);
await click(clearBtn);
await settled();
fieldButtonText = $(".field div[data-id='step_1_field_1'] button")
.text()
.trim();
@ -526,6 +537,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await fieldTypeDropdown.expand();
await fieldTypeDropdown.selectRowByValue("text");
await settled();
assert.ok(
query(".wizard-custom-field .message-content").innerText.includes(
"You're editing a field"
@ -542,6 +554,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
assert.step("Step 4: Creating a action section");
const actionAddBtn = find(".action .link-list button:contains('Add')");
await click(actionAddBtn);
await settled();
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
@ -555,6 +568,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
".wizard-custom-action .setting-value .select-kit"
);
await actionTypeDropdown.expand();
await settled();
const listEnabled = findAll(
".wizard-custom-action .setting .setting-value ul li:not(.disabled)"
);
@ -570,6 +584,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"Enabled items displayed correctly in action dropdown"
);
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.ok(
query(".wizard-custom-action .message-content").innerText.includes(
"You're editing an action"
@ -585,6 +600,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("open_composer");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -594,6 +610,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("update_profile");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -603,6 +620,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("route_to");
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -611,8 +629,10 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"Display all settings of route to"
);
await actionTypeDropdown.expand();
await settled();
const li = find('[data-name="Select a type"]');
await click(li);
await settled();
listTopicSettings = findAll(
".admin-wizard-container .wizard-custom-action .setting"
);
@ -622,7 +642,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("create_topic");
await settled();
assert.step("Step 5: Save changes");
const saveButton = find(
'.admin-wizard-buttons button:contains("Save Changes")'
@ -632,6 +652,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"delete wizard button not displayed"
);
await click(saveButton);
await settled();
assert.equal(
currentURL(),
"/admin/wizards/wizard/new_wizard_for_testing",