Files
discourse/app/assets/javascripts/discourse/tests/acceptance/client-error-handler-test.js
David Taylor 67bcef3959 DEV: Show theme/plugin error banner for route loading failures (#24218)
This aims to help admins and developers identify the cause of loading issues on routes.

As with other theme/plugin errors, the UI banner is only shown to administrators. For non-admins, the information is only written to the browser console.
2023-11-02 15:45:02 +00:00

31 lines
930 B
JavaScript

import { getOwner } from "@ember/application";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import Sinon from "sinon";
import { acceptance } from "../helpers/qunit-helpers";
acceptance("client-error-handler service", function (needs) {
needs.user({
admin: true,
});
test("displays route-loading errors caused by themes", async function (assert) {
const fakeError = new Error("Something bad happened");
fakeError.stack = "assets/plugins/some-fake-plugin-name.js";
const topicRoute = getOwner(this).lookup("route:topic");
Sinon.stub(topicRoute, "model").throws(fakeError);
const consoleStub = Sinon.stub(console, "error");
try {
await visit("/t/280");
} catch {}
consoleStub.restore();
assert.dom(".broken-theme-alert-banner").exists();
assert
.dom(".broken-theme-alert-banner")
.containsText("some-fake-plugin-name");
});
});