Skip to content

Commit

Permalink
Merge pull request Expensify#56461 from callstack-internal/bugfix/tes…
Browse files Browse the repository at this point in the history
…ts-failing-debug

[No QA] Enable group chat name tests by removing skip from last message preview
  • Loading branch information
mountiny authored Feb 17, 2025
2 parents 3c10fbb + 97ac148 commit c19715d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
70 changes: 35 additions & 35 deletions tests/ui/GroupChatNameTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand All @@ -92,7 +92,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
return waitForBatchedUpdatesWithAct();
})
.then(() => {
User.subscribeToUserEvents();
subscribeToUserEvents();
return waitForBatchedUpdates();
})
.then(async () => {
Expand All @@ -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();
});
}
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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");
Expand All @@ -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'));
Expand Down

0 comments on commit c19715d

Please sign in to comment.