0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-14 05:52:52 +01:00
discourse-custom-wizard/test/javascripts/acceptance/step-test.js

56 Zeilen
1,7 KiB
JavaScript

2022-06-15 08:59:09 +02:00
import { click, visit } from "@ember/test-helpers";
2022-03-16 12:33:34 +01:00
import { test } from "qunit";
2022-07-27 12:47:50 +02:00
import {
acceptance,
count,
exists,
2022-07-27 16:30:45 +02:00
query,
2022-07-27 15:50:49 +02:00
visible,
2022-07-27 12:47:50 +02:00
} from "discourse/tests/helpers/qunit-helpers";
2022-07-27 16:30:45 +02:00
import { stepNotPermitted, update, wizard } from "../helpers/wizard";
2022-07-27 12:47:50 +02:00
acceptance("Step | Not permitted", function (needs) {
needs.pretender((server, helper) => {
2022-07-27 16:36:22 +02:00
server.get("/w/wizard.json", () => helper.response(stepNotPermitted));
2022-07-27 12:47:50 +02:00
});
2022-03-16 12:33:34 +01:00
2022-06-15 08:59:09 +02:00
test("Shows not permitted message", async function (assert) {
2022-07-27 12:47:50 +02:00
await visit("/w/wizard");
2022-06-15 08:59:09 +02:00
assert.ok(exists(".step-message.not-permitted"));
});
});
2022-03-16 12:33:34 +01:00
2022-07-27 12:47:50 +02:00
acceptance("Step | Step", function (needs) {
needs.user();
2022-07-27 12:47:50 +02:00
needs.pretender((server, helper) => {
2022-07-27 16:30:45 +02:00
server.get("/w/wizard.json", () => helper.response(wizard));
2022-07-27 16:36:22 +02:00
server.put("/w/wizard/steps/:step_id", () => helper.response(update));
2022-07-27 12:47:50 +02:00
});
2022-06-15 08:59:09 +02:00
test("Renders the step", async function (assert) {
2022-07-27 12:47:50 +02:00
await visit("/w/wizard");
2022-06-15 08:59:09 +02:00
assert.strictEqual(
query(".wizard-step-title p").textContent.trim(),
"Text"
);
assert.strictEqual(
query(".wizard-step-description p").textContent.trim(),
"Text inputs!"
);
assert.strictEqual(
query(".wizard-step-description p").textContent.trim(),
"Text inputs!"
);
assert.strictEqual(count(".wizard-step-form .wizard-field"), 6);
assert.ok(visible(".wizard-step-footer .wizard-progress"), true);
assert.ok(visible(".wizard-step-footer .wizard-buttons"), true);
});
2022-03-16 12:33:34 +01:00
2022-06-15 08:59:09 +02:00
test("Goes to the next step", async function (assert) {
2022-07-27 12:47:50 +02:00
await visit("/w/wizard");
2022-06-15 08:59:09 +02:00
assert.ok(visible(".wizard-step.step_1"), true);
await click(".wizard-btn.next");
assert.ok(visible(".wizard-step.step_2"), true);
});
});