From 590a13377b8e249d68858b1fa121eefafcb0149a Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Wed, 10 Aug 2022 10:10:34 +0300 Subject: [PATCH] DEV: Fix the build (#17853) https://github.com/discourse/discourse/commit/473695ee4dac69e7e59a10f8698346ee6812f2bc and https://github.com/discourse/discourse/commit/23520b88c2dca7b4fee90bb9b043c79d000933d8 were merged very close to each other, but they had some subtle conflicting changes that broke some tests. --- .../tests/acceptance/user-menu-test.js | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js index 84be04227e4..e0d125177fe 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js @@ -2,6 +2,8 @@ import { click, visit } from "@ember/test-helpers"; import { acceptance, exists, + loggedInUser, + publishToMessageBus, query, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -90,42 +92,44 @@ acceptance("User menu", function (needs) { }; }); }); + const expectedTabOrder = { + "user-menu-button-all-notifications": "0", + "user-menu-button-replies": "1", + "user-menu-button-mentions": "2", + "user-menu-button-likes": "3", + "user-menu-button-messages": "4", + "user-menu-button-bookmarks": "5", + "user-menu-button-custom-tab-1": "6", + "user-menu-button-custom-tab-2": "7", + "user-menu-button-review-queue": "8", + }; await visit("/"); await click(".d-header-icons .current-user"); - const customTab1 = query("#user-menu-button-custom-tab-1"); - const customTab2 = query("#user-menu-button-custom-tab-2"); - - assert.ok(customTab1, "first custom tab is rendered"); - assert.ok(customTab2, "second custom tab is rendered"); - - assert.strictEqual( - customTab1.dataset.tabNumber, - "5", - "custom tab has the right tab number" + assert.ok( + exists("#user-menu-button-custom-tab-1"), + "first custom tab is rendered" + ); + assert.ok( + exists("#user-menu-button-custom-tab-2"), + "second custom tab is rendered" ); - assert.strictEqual( - customTab2.dataset.tabNumber, - "6", - "custom tab has the right tab number" - ); - - const reviewQueueTab = query("#user-menu-button-review-queue"); - - assert.strictEqual( - reviewQueueTab.dataset.tabNumber, - "7", - "review queue tab comes after the custom tabs" - ); - - const tabs = [...queryAll(".tabs-list .btn")]; // top and bottom tabs + const tabs = [...queryAll(".tabs-list.top-tabs .btn")]; assert.deepEqual( - tabs.map((t) => t.dataset.tabNumber), - ["0", "1", "2", "3", "4", "5", "6", "7", "8"], - "data-tab-number of the tabs has no gaps when custom tabs are added" + tabs.reduce((acc, tab) => { + acc[tab.id] = tab.dataset.tabNumber; + return acc; + }, {}), + expectedTabOrder, + "data-tab-number of the tabs has no gaps when custom tabs are added and the tabs are in the right order" + ); + assert.strictEqual( + query(".tabs-list.bottom-tabs .btn").dataset.tabNumber, + "9", + "bottom tab has the correct data-tab-number" ); let customTab1Bubble = query(