discourse/plugins/discourse-ai/test/javascripts/unit/routes/discourse-ai-shared-conversation-show-route-test.js
Jarek Radosz 21e9733f27
DEV: Fix various lint issues (#33811)
…mostly in recently bundled plugins.
2025-07-24 15:27:04 +02:00

65 lines
1.6 KiB
JavaScript
Vendored

import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import sinon from "sinon";
module(
"Unit | Route | discourse-ai-shared-conversation-show",
function (hooks) {
setupTest(hooks);
test("it redirects based on currentUser preference", function (assert) {
const transition = {
intent: { url: "https://www.discourse.org" },
abort() {
assert.true(true, "transition.abort() was called");
},
};
const route = this.owner.lookup(
"route:discourse-ai-shared-conversation-show"
);
const windowOpenStub = sinon.stub(window, "open");
const routeRedirectStub = sinon.stub(route, "redirect");
// external_links_in_new_tab = true
route.set("currentUser", {
user_option: {
external_links_in_new_tab: true,
},
});
windowOpenStub.callsFake((url, target) => {
assert.strictEqual(
url,
"https://www.discourse.org",
"window.open was called with the correct URL"
);
assert.strictEqual(
target,
"_blank",
'window.open was called with "_blank"'
);
});
route.beforeModel(transition);
// external_links_in_new_tab = false
route.set("currentUser", {
user_option: {
external_links_in_new_tab: false,
},
});
routeRedirectStub.callsFake((url) => {
assert.strictEqual(
url,
"https://www.discourse.org",
"redirect was called with the correct URL"
);
});
route.beforeModel(transition);
});
}
);