0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00
discourse-custom-wizard/test/javascripts/acceptance/admin-logs-test.js

78 Zeilen
2,4 KiB
JavaScript

2024-01-26 16:18:11 +01:00
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
2022-12-29 22:02:19 +01:00
import { test } from "qunit";
2024-01-26 16:18:11 +01:00
import { click, visit } from "@ember/test-helpers";
2022-12-13 13:58:35 +01:00
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
2023-09-25 17:07:41 +02:00
getSuppliers,
getUnsubscribedAdminWizards,
getWizard,
getWizardTestingLog,
} from "../helpers/admin-wizard";
2022-12-13 13:58:35 +01:00
acceptance("Admin | Logs", function (needs) {
needs.user();
needs.settings({
custom_wizard_enabled: true,
available_locales: JSON.stringify([{ name: "English", value: "en" }]),
});
needs.pretender((server, helper) => {
server.get("/admin/wizards/logs", () => {
2022-12-13 13:58:35 +01:00
return helper.response([
{ id: "this_is_testing_wizard", name: "This is testing wizard" },
]);
});
server.get("/admin/wizards/logs/this_is_testing_wizard", () => {
return helper.response(getWizardTestingLog);
2022-12-13 13:58:35 +01:00
});
2023-09-24 18:35:20 +02:00
server.get("/admin/wizards/subscription", () => {
return helper.response(getUnsubscribedAdminWizards);
2022-12-13 13:58:35 +01:00
});
server.get("/admin/wizards/wizard", () => {
return helper.response(getWizard);
2022-12-13 13:58:35 +01:00
});
2023-09-25 16:41:01 +02:00
server.get("/admin/plugins/subscription-client/suppliers", () => {
return helper.response(getSuppliers);
});
2022-12-13 13:58:35 +01:00
});
2022-12-29 22:02:19 +01:00
test("viewing logs fields tab", async (assert) => {
2022-12-13 13:58:35 +01:00
await visit("/admin/wizards/logs");
const wizards = selectKit(".select-kit");
assert.ok(
query(".message-content").innerText.includes(
"Select a wizard to see its logs"
),
"it displays logs message"
);
assert.ok(
query(".message-content").innerText.includes("Select a wizard"),
"it displays list of logs"
);
await wizards.expand();
await wizards.selectRowByValue("this_is_testing_wizard");
assert.ok(
query(".message-content").innerText.includes(
"View recent logs for wizards on the forum"
),
"it displays logs for a selected wizard"
);
2024-01-26 16:18:11 +01:00
assert.ok(queryAll("table"));
assert.ok(queryAll("table tbody tr").length === 2, "Displays logs list");
await click(".refresh.btn");
2024-01-26 16:18:11 +01:00
assert.ok(queryAll("table"));
2022-12-13 13:58:35 +01:00
assert.ok(
2024-01-26 16:18:11 +01:00
queryAll("table tbody tr").length === 2,
"Refresh button works correctly"
2022-12-13 13:58:35 +01:00
);
2022-12-13 13:58:35 +01:00
await wizards.expand();
await click('[data-name="Select a wizard"]');
2024-01-26 16:18:11 +01:00
const wizardContainerDiv = queryAll(".admin-wizard-container");
2022-12-13 13:58:35 +01:00
assert.ok(wizardContainerDiv.children().length === 0, "the div is empty");
});
});