This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/admin-plugins-test.js
David Taylor 782f43cc55
Improve route error handling in admin/plugins (#18911)
Previously if a specific plugin route was not available (e.g. there was an error loading the plugin's JS due to an ad blocker), the entire page would fail to load. This commit updates the behavior to catch this kind of issue and display a user-friendly message at the top of the screen.
2022-11-07 16:39:27 +00:00

52 lines
1.3 KiB
JavaScript

import {
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
acceptance("Admin - Plugins", function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.get("/admin/plugins", () =>
helper.response({
plugins: [
{
id: "some-test-plugin",
name: "some-test-plugin",
about: "Plugin description",
version: "0.1",
url: "https://example.com",
admin_route: {
location: "testlocation",
label: "test.plugin.label",
full_location: "adminPlugins.testlocation",
},
enabled: true,
enabled_setting: "testplugin_enabled",
has_settings: true,
is_official: true,
},
],
})
);
});
test("shows plugin list", async function (assert) {
await visit("/admin/plugins");
const table = query("table.admin-plugins");
assert.strictEqual(
table.querySelector("tr .plugin-name .name").innerText,
"some-test-plugin",
"displays the plugin in the table"
);
assert.true(
exists(".admin-plugins .admin-detail .alert-error"),
"displays an error for unknown routes"
);
});
});