diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36d4248fcc3c..cc9cad591925 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: key: ${{ runner.os }}-jest - name: Jest tests - run: NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" npx jest --silent --shard=${{ fromJSON(matrix.chunk) }}/${{ strategy.job-total }} --max-workers ${{ steps.cpu-cores.outputs.count }} + run: NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" npm test -- --silent --shard=${{ fromJSON(matrix.chunk) }}/${{ strategy.job-total }} --max-workers ${{ steps.cpu-cores.outputs.count }} storybookTests: if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' || github.event_name == 'workflow_call' }} diff --git a/tests/ui/GroupChatNameTests.tsx b/tests/ui/GroupChatNameTests.tsx index 184be0f740da..a1c0be78c38c 100644 --- a/tests/ui/GroupChatNameTests.tsx +++ b/tests/ui/GroupChatNameTests.tsx @@ -6,9 +6,9 @@ import {act, render, screen, waitFor} from '@testing-library/react-native'; import React from 'react'; import Onyx from 'react-native-onyx'; -import * as Localize from '@libs/Localize'; -import * as AppActions from '@userActions/App'; -import * as User from '@userActions/User'; +import {translateLocal} from '@libs/Localize'; +import {setSidebarLoaded} from '@userActions/App'; +import {subscribeToUserEvents} from '@userActions/User'; import App from '@src/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -82,7 +82,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro return waitForBatchedUpdatesWithAct() .then(async () => { await waitForBatchedUpdatesWithAct(); - const hintText = Localize.translateLocal('loginForm.loginForm'); + const hintText = translateLocal('loginForm.loginForm'); const loginForm = screen.queryAllByLabelText(hintText); expect(loginForm).toHaveLength(1); @@ -92,7 +92,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro return waitForBatchedUpdatesWithAct(); }) .then(() => { - User.subscribeToUserEvents(); + subscribeToUserEvents(); return waitForBatchedUpdates(); }) .then(async () => { @@ -119,7 +119,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro }); // We manually setting the sidebar as loaded since the onLayout event does not fire in tests - AppActions.setSidebarLoaded(); + setSidebarLoaded(); return waitForBatchedUpdatesWithAct(); }); } @@ -143,16 +143,16 @@ describe('Tests for group chat name', () => { it('Should show correctly in LHN', () => signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D')); @@ -161,16 +161,16 @@ describe('Tests for group chat name', () => { it('Should show correctly in LHN when report name is not present', () => signInAndGetApp('', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D')); @@ -179,16 +179,16 @@ describe('Tests for group chat name', () => { it('Should show limited names in LHN when 8 participants are present', () => signInAndGetApp('', participantAccountIDs8).then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E')); @@ -198,16 +198,16 @@ describe('Tests for group chat name', () => { signInAndGetApp('', participantAccountIDs4) .then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D'); @@ -226,16 +226,16 @@ describe('Tests for group chat name', () => { signInAndGetApp('', participantAccountIDs8) .then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E'); @@ -254,16 +254,16 @@ describe('Tests for group chat name', () => { signInAndGetApp('Test chat', participantAccountIDs4) .then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe('Test chat'); @@ -282,16 +282,16 @@ describe('Tests for group chat name', () => { signInAndGetApp("Let's talk", participantAccountIDs8) .then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe("Let's talk"); @@ -306,37 +306,37 @@ describe('Tests for group chat name', () => { return waitFor(() => expect(displayNameTexts).toHaveLength(1)); })); - it.skip('Should show last message preview in LHN', () => + it('Should show last message preview in LHN', () => signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const lastChatHintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); + const lastChatHintText = translateLocal('accessibilityHints.lastChatMessagePreview'); const lastChatText = screen.queryByLabelText(lastChatHintText); return waitFor(() => expect(lastChatText?.props?.children).toBe('B: Test')); })); - it.skip('Should sort the names before displaying', () => + it('Should sort the names before displaying', () => signInAndGetApp('', [USER_E_ACCOUNT_ID, ...participantAccountIDs4]).then(() => { // Verify the sidebar links are rendered - const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar - const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText); expect(optionRows).toHaveLength(1); - const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E'));