DEV: ctrl+click on user menu items should open in new tab (#18243)

This commit is contained in:
Osama Sayegh 2022-09-14 01:25:40 +03:00 committed by GitHub
parent 5ee760dc2c
commit 2f428023da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import DiscourseURL from "discourse/lib/url";
import { wantsNewWindow } from "discourse/lib/intercept-click";
export default class UserMenuBaseItem {
get className() {}
@ -30,6 +31,9 @@ export default class UserMenuBaseItem {
get topicId() {}
onClick({ event, closeUserMenu }) {
if (wantsNewWindow(event)) {
return;
}
closeUserMenu();
const href = this.linkHref;
if (href) {

View File

@ -112,6 +112,25 @@ acceptance("User menu", function (needs) {
exists(".user-menu"),
"clicking on the same item again closes the menu"
);
await click(".d-header-icons .current-user");
await click("#user-menu-button-review-queue");
// this may not be ideal because it actually attempts to open a new tab
// which gets blocked by the browser, but otherwise it seems harmless and
// doesn't cause the test to fail. if it causes problems for you, feel free
// to remove the ctrl+click tests.
await click("#quick-access-review-queue li.reviewable.reviewed a", {
ctrlKey: true,
});
assert.strictEqual(
currentURL(),
"/review/17",
"ctrl-clicking on an item doesn't navigate to a new page"
);
assert.ok(
exists(".user-menu"),
"ctrl-clicking on an item doesn't close the menu"
);
});
test("tabs added via the plugin API", async function (assert) {