diff --git a/force-app/main/default/lwc/workspaceAPI/__tests__/workspaceAPI.test.js b/force-app/main/default/lwc/workspaceAPI/__tests__/workspaceAPI.test.js index ab0cbb947..6e00861ef 100644 --- a/force-app/main/default/lwc/workspaceAPI/__tests__/workspaceAPI.test.js +++ b/force-app/main/default/lwc/workspaceAPI/__tests__/workspaceAPI.test.js @@ -33,7 +33,7 @@ describe('c-workspace-api', () => { IsConsoleNavigation.emit(true); await flushPromises(); - // Click button + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); diff --git a/force-app/main/default/lwc/workspaceAPICloseTab/__tests__/workspaceAPICloseTab.test.js b/force-app/main/default/lwc/workspaceAPICloseTab/__tests__/workspaceAPICloseTab.test.js index 3f1f864d9..bbacd063f 100644 --- a/force-app/main/default/lwc/workspaceAPICloseTab/__tests__/workspaceAPICloseTab.test.js +++ b/force-app/main/default/lwc/workspaceAPICloseTab/__tests__/workspaceAPICloseTab.test.js @@ -28,12 +28,14 @@ describe('c-workspace-api-close-tab', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPIDisableTabClose/__tests__/workspaceAPIDisableTabClose.test.js b/force-app/main/default/lwc/workspaceAPIDisableTabClose/__tests__/workspaceAPIDisableTabClose.test.js index b1beafc35..2808da92a 100644 --- a/force-app/main/default/lwc/workspaceAPIDisableTabClose/__tests__/workspaceAPIDisableTabClose.test.js +++ b/force-app/main/default/lwc/workspaceAPIDisableTabClose/__tests__/workspaceAPIDisableTabClose.test.js @@ -29,15 +29,18 @@ describe('c-workspace-api-disable-tab-close', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); + await flushPromises(); - // Query lightning-input component element + // Find and toggle input const inputEl = element.shadowRoot.querySelector('lightning-input'); const toggleValue = true; inputEl.dispatchEvent( new CustomEvent('change', { detail: { checked: toggleValue } }) ); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPIFocusTab/__tests__/workspaceAPIFocusTab.test.js b/force-app/main/default/lwc/workspaceAPIFocusTab/__tests__/workspaceAPIFocusTab.test.js index 5ba98716e..ac6718445 100644 --- a/force-app/main/default/lwc/workspaceAPIFocusTab/__tests__/workspaceAPIFocusTab.test.js +++ b/force-app/main/default/lwc/workspaceAPIFocusTab/__tests__/workspaceAPIFocusTab.test.js @@ -29,12 +29,14 @@ describe('c-workspace-api-focus-tab', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPIHighlightTab/__tests__/workspaceAPIHighlightTab.test.js b/force-app/main/default/lwc/workspaceAPIHighlightTab/__tests__/workspaceAPIHighlightTab.test.js index 647b8cf8c..afebe6095 100644 --- a/force-app/main/default/lwc/workspaceAPIHighlightTab/__tests__/workspaceAPIHighlightTab.test.js +++ b/force-app/main/default/lwc/workspaceAPIHighlightTab/__tests__/workspaceAPIHighlightTab.test.js @@ -28,14 +28,16 @@ describe('c-workspace-api-highlight-tab', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-input component element + // Find and toggle input const inputEl = element.shadowRoot.querySelector('lightning-input'); inputEl.dispatchEvent( new CustomEvent('change', { detail: { checked: true } }) ); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPIOpenSubtab/__tests__/workspaceAPIOpenSubtab.test.js b/force-app/main/default/lwc/workspaceAPIOpenSubtab/__tests__/workspaceAPIOpenSubtab.test.js index 81c2f6265..0ad806adf 100644 --- a/force-app/main/default/lwc/workspaceAPIOpenSubtab/__tests__/workspaceAPIOpenSubtab.test.js +++ b/force-app/main/default/lwc/workspaceAPIOpenSubtab/__tests__/workspaceAPIOpenSubtab.test.js @@ -28,13 +28,15 @@ describe('c-workspace-api-open-subtab', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); EnclosingTabId.emit(ENCLOSING_TAB_ID); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPIOpenTab/__tests__/workspaceAPIOpenTab.test.js b/force-app/main/default/lwc/workspaceAPIOpenTab/__tests__/workspaceAPIOpenTab.test.js index 874226678..dfa8101e2 100644 --- a/force-app/main/default/lwc/workspaceAPIOpenTab/__tests__/workspaceAPIOpenTab.test.js +++ b/force-app/main/default/lwc/workspaceAPIOpenTab/__tests__/workspaceAPIOpenTab.test.js @@ -23,14 +23,14 @@ describe('c-workspace-api-open-tab', () => { }); document.body.appendChild(element); + // Simulate console navigation IsConsoleNavigation.emit(true); + await flushPromises(); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); - await flushPromises(); - // Check that related platformWorkspaceApi functions have been called expect(openTab).toHaveBeenCalledWith({ pageReference: { diff --git a/force-app/main/default/lwc/workspaceAPIRefreshTab/__tests__/workspaceAPIRefreshTab.test.js b/force-app/main/default/lwc/workspaceAPIRefreshTab/__tests__/workspaceAPIRefreshTab.test.js index 0feed2980..faa064664 100644 --- a/force-app/main/default/lwc/workspaceAPIRefreshTab/__tests__/workspaceAPIRefreshTab.test.js +++ b/force-app/main/default/lwc/workspaceAPIRefreshTab/__tests__/workspaceAPIRefreshTab.test.js @@ -31,10 +31,11 @@ describe('c-workspace-api-refresh-tab', () => { // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called diff --git a/force-app/main/default/lwc/workspaceAPISetTabIcon/__tests__/workspaceAPISetTabIcon.test.js b/force-app/main/default/lwc/workspaceAPISetTabIcon/__tests__/workspaceAPISetTabIcon.test.js index ff9182e91..dbee42804 100644 --- a/force-app/main/default/lwc/workspaceAPISetTabIcon/__tests__/workspaceAPISetTabIcon.test.js +++ b/force-app/main/default/lwc/workspaceAPISetTabIcon/__tests__/workspaceAPISetTabIcon.test.js @@ -7,6 +7,9 @@ import { FOCUSED_TAB_ID } from 'lightning/platformWorkspaceApi'; +const UPDATED_TAB_ICON = 'utility:animal_and_nature'; +const UPDATED_TAB_ICON_ALT_TEXT = 'Animal and Nature'; + describe('c-workspace-api-set-tab-icon', () => { afterEach(() => { // The jsdom instance is shared across test cases in a single file so reset the DOM @@ -28,21 +31,25 @@ describe('c-workspace-api-set-tab-icon', () => { }); document.body.appendChild(element); - const TAB_ICON = 'utility:animal_and_nature'; - const TAB_ICON_ALT_TEXT = 'Animal and Nature'; + // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called expect(getFocusedTabInfo).toHaveBeenCalled(); - expect(setTabIcon).toHaveBeenCalledWith(FOCUSED_TAB_ID, TAB_ICON, { - iconAlt: TAB_ICON_ALT_TEXT - }); + expect(setTabIcon).toHaveBeenCalledWith( + FOCUSED_TAB_ID, + UPDATED_TAB_ICON, + { + iconAlt: UPDATED_TAB_ICON_ALT_TEXT + } + ); }); it('is accessible', async () => { diff --git a/force-app/main/default/lwc/workspaceAPISetTabLabel/__tests__/workspaceAPISetTabLabel.test.js b/force-app/main/default/lwc/workspaceAPISetTabLabel/__tests__/workspaceAPISetTabLabel.test.js index a918ee3dc..eede6c426 100644 --- a/force-app/main/default/lwc/workspaceAPISetTabLabel/__tests__/workspaceAPISetTabLabel.test.js +++ b/force-app/main/default/lwc/workspaceAPISetTabLabel/__tests__/workspaceAPISetTabLabel.test.js @@ -7,6 +7,8 @@ import { FOCUSED_TAB_ID } from 'lightning/platformWorkspaceApi'; +const UPDATED_TAB_LABEL = 'Awesome Label'; + describe('c-workspace-api-set-tab-label', () => { afterEach(() => { // The jsdom instance is shared across test cases in a single file so reset the DOM @@ -28,18 +30,22 @@ describe('c-workspace-api-set-tab-label', () => { }); document.body.appendChild(element); - const TAB_LABEL = 'Awesome Label'; + // Simulate console navigation IsConsoleNavigation.emit(true); - // Query lightning-button component element + // Find and click button const buttonEl = element.shadowRoot.querySelector('lightning-button'); buttonEl.click(); + // Wait for async event await flushPromises(); // Check that related platformWorkspaceApi functions have been called expect(getFocusedTabInfo).toHaveBeenCalled(); - expect(setTabLabel).toHaveBeenCalledWith(FOCUSED_TAB_ID, TAB_LABEL); + expect(setTabLabel).toHaveBeenCalledWith( + FOCUSED_TAB_ID, + UPDATED_TAB_LABEL + ); }); it('is accessible', async () => {