Files
David TaylorandGitHub 666b5dddde DEV: Move discourse-common/(utils|lib) to discourse/lib (#30733)
`discourse-common` was created in the past to share logic between the
'wizard' app and the main 'discourse' app. Since then, the wizard has
been consolidated into the main app, so the separation of
`discourse-common` is no longer useful.

This commit moves `discourse-common/(lib|utils)/*` into
`discourse/lib/*`, adds shims for the imports, and updates existing
uses in core.
2025-01-13 13:02:49 +00:00

60 lines
1.7 KiB
JavaScript

import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import Sinon from "sinon";
import { cloneJSON } from "discourse/lib/object";
import DiscourseURL from "discourse/lib/url";
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import {
acceptance,
publishToMessageBus,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Software update refresh", function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.get("/hot.json", () => {
return helper.response(cloneJSON(discoveryFixtures["/latest.json"]));
});
});
test("Refreshes page on next navigation", async function (assert) {
const redirectStub = Sinon.stub(DiscourseURL, "redirectTo");
await visit("/");
await click(".nav-item_hot a");
assert.true(
redirectStub.notCalled,
"redirect was not triggered by default"
);
await publishToMessageBus("/global/asset-version", "somenewversion");
redirectStub.resetHistory();
await visit("/");
await click(".nav-item_hot a");
assert.true(
redirectStub.calledWith("/hot"),
"redirect was triggered after asset change"
);
redirectStub.resetHistory();
await visit("/");
await click("#create-topic");
await click(".nav-item_hot a");
assert.true(
redirectStub.notCalled,
"redirect is not triggered while composer is open"
);
redirectStub.resetHistory();
await visit("/");
await click(".save-or-cancel .cancel");
await click(".nav-item_hot a");
assert.true(
redirectStub.calledWith("/hot"),
"redirect is triggered on next navigation after composer closed"
);
});
});