diff --git a/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.hbs b/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.hbs index 759d7cf93da..b81151b1c84 100644 --- a/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.hbs +++ b/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.hbs @@ -120,6 +120,19 @@ {{/if}} + {{#each this.extraItems as |item|}} +
  • + + {{#if item.icon}} + {{d-icon item.icon}} + {{/if}} + + {{item.content}} + + +
  • + {{/each}} +
  • { + api.addQuickAccessProfileItem({ + className: "test-1-item", + icon: "wrench", + content: "test 1", + href: "/test_1_path", + }); + + api.addQuickAccessProfileItem({ + className: "test-2-item", + content: "test 2", + href: "/test_2_path", + }); + }); + + await visit("/"); + await click(".d-header-icons .current-user"); + await click("#user-menu-button-profile"); + + const item1 = query("#quick-access-profile ul li.test-1-item"); + + assert.ok( + item1.querySelector(".d-icon-wrench"), + "The first item's icon is rendered" + ); + assert.ok( + item1.querySelector("a").href.endsWith("/test_1_path"), + "The first item's link is present with correct href" + ); + + const item2 = query("#quick-access-profile ul li.test-2-item"); + + assert.notOk( + item2.querySelector(".d-icon"), + "The second item doesn't have an icon" + ); + assert.ok( + item2.querySelector("a").href.endsWith("/test_2_path"), + "The second item's link is present with correct href" + ); + }); + test("the active tab can be clicked again to navigate to a page", async function (assert) { updateCurrentUser({ reviewable_count: 1 }); withPluginApi("0.1", (api) => { diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index fa0473c17d3..767b59a65b1 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -35,7 +35,9 @@ import { resetWidgetCleanCallbacks } from "discourse/components/mount-widget"; import { resetUserSearchCache } from "discourse/lib/user-search"; import { resetCardClickListenerSelector } from "discourse/mixins/card-contents-base"; import { resetComposerCustomizations } from "discourse/models/composer"; +import { resetQuickAccessProfileItems } from "discourse/widgets/quick-access-profile"; import { resetQuickSearchRandomTips } from "discourse/widgets/search-menu-results"; +import { resetUserMenuProfileTabItems } from "discourse/components/user-menu/profile-tab-content"; import sessionFixtures from "discourse/tests/fixtures/session-fixtures"; import { resetHighestReadCache, @@ -179,8 +181,10 @@ export function testCleanup(container, app) { resetHighestReadCache(); resetCardClickListenerSelector(); resetComposerCustomizations(); + resetQuickAccessProfileItems(); resetQuickSearchRandomTips(); resetPostMenuExtraButtons(); + resetUserMenuProfileTabItems(); clearExtraKeyboardShortcutHelp(); clearNavItems(); setTopicList(null);