Skip to content

Commit c19715d

Browse files
authored
Merge pull request #56461 from callstack-internal/bugfix/tests-failing-debug
[No QA] Enable group chat name tests by removing skip from last message preview
2 parents 3c10fbb + 97ac148 commit c19715d

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
key: ${{ runner.os }}-jest
4242

4343
- name: Jest tests
44-
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 }}
44+
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 }}
4545

4646
storybookTests:
4747
if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' || github.event_name == 'workflow_call' }}

tests/ui/GroupChatNameTests.tsx

+35-35
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import {act, render, screen, waitFor} from '@testing-library/react-native';
77
import React from 'react';
88
import Onyx from 'react-native-onyx';
9-
import * as Localize from '@libs/Localize';
10-
import * as AppActions from '@userActions/App';
11-
import * as User from '@userActions/User';
9+
import {translateLocal} from '@libs/Localize';
10+
import {setSidebarLoaded} from '@userActions/App';
11+
import {subscribeToUserEvents} from '@userActions/User';
1212
import App from '@src/App';
1313
import CONST from '@src/CONST';
1414
import ONYXKEYS from '@src/ONYXKEYS';
@@ -82,7 +82,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
8282
return waitForBatchedUpdatesWithAct()
8383
.then(async () => {
8484
await waitForBatchedUpdatesWithAct();
85-
const hintText = Localize.translateLocal('loginForm.loginForm');
85+
const hintText = translateLocal('loginForm.loginForm');
8686
const loginForm = screen.queryAllByLabelText(hintText);
8787
expect(loginForm).toHaveLength(1);
8888

@@ -92,7 +92,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
9292
return waitForBatchedUpdatesWithAct();
9393
})
9494
.then(() => {
95-
User.subscribeToUserEvents();
95+
subscribeToUserEvents();
9696
return waitForBatchedUpdates();
9797
})
9898
.then(async () => {
@@ -119,7 +119,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
119119
});
120120

121121
// We manually setting the sidebar as loaded since the onLayout event does not fire in tests
122-
AppActions.setSidebarLoaded();
122+
setSidebarLoaded();
123123
return waitForBatchedUpdatesWithAct();
124124
});
125125
}
@@ -143,16 +143,16 @@ describe('Tests for group chat name', () => {
143143
it('Should show correctly in LHN', () =>
144144
signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => {
145145
// Verify the sidebar links are rendered
146-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
146+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
147147
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
148148
expect(sidebarLinks).toHaveLength(1);
149149

150150
// Verify there is only one option in the sidebar
151-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
151+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
152152
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
153153
expect(optionRows).toHaveLength(1);
154154

155-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
155+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
156156
const displayNameText = screen.queryByLabelText(displayNameHintText);
157157

158158
return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D'));
@@ -161,16 +161,16 @@ describe('Tests for group chat name', () => {
161161
it('Should show correctly in LHN when report name is not present', () =>
162162
signInAndGetApp('', participantAccountIDs4).then(() => {
163163
// Verify the sidebar links are rendered
164-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
164+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
165165
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
166166
expect(sidebarLinks).toHaveLength(1);
167167

168168
// Verify there is only one option in the sidebar
169-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
169+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
170170
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
171171
expect(optionRows).toHaveLength(1);
172172

173-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
173+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
174174
const displayNameText = screen.queryByLabelText(displayNameHintText);
175175

176176
return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D'));
@@ -179,16 +179,16 @@ describe('Tests for group chat name', () => {
179179
it('Should show limited names in LHN when 8 participants are present', () =>
180180
signInAndGetApp('', participantAccountIDs8).then(() => {
181181
// Verify the sidebar links are rendered
182-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
182+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
183183
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
184184
expect(sidebarLinks).toHaveLength(1);
185185

186186
// Verify there is only one option in the sidebar
187-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
187+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
188188
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
189189
expect(optionRows).toHaveLength(1);
190190

191-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
191+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
192192
const displayNameText = screen.queryByLabelText(displayNameHintText);
193193

194194
return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E'));
@@ -198,16 +198,16 @@ describe('Tests for group chat name', () => {
198198
signInAndGetApp('', participantAccountIDs4)
199199
.then(() => {
200200
// Verify the sidebar links are rendered
201-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
201+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
202202
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
203203
expect(sidebarLinks).toHaveLength(1);
204204

205205
// Verify there is only one option in the sidebar
206-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
206+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
207207
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
208208
expect(optionRows).toHaveLength(1);
209209

210-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
210+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
211211
const displayNameText = screen.queryByLabelText(displayNameHintText);
212212

213213
expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D');
@@ -226,16 +226,16 @@ describe('Tests for group chat name', () => {
226226
signInAndGetApp('', participantAccountIDs8)
227227
.then(() => {
228228
// Verify the sidebar links are rendered
229-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
229+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
230230
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
231231
expect(sidebarLinks).toHaveLength(1);
232232

233233
// Verify there is only one option in the sidebar
234-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
234+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
235235
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
236236
expect(optionRows).toHaveLength(1);
237237

238-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
238+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
239239
const displayNameText = screen.queryByLabelText(displayNameHintText);
240240

241241
expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E');
@@ -254,16 +254,16 @@ describe('Tests for group chat name', () => {
254254
signInAndGetApp('Test chat', participantAccountIDs4)
255255
.then(() => {
256256
// Verify the sidebar links are rendered
257-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
257+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
258258
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
259259
expect(sidebarLinks).toHaveLength(1);
260260

261261
// Verify there is only one option in the sidebar
262-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
262+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
263263
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
264264
expect(optionRows).toHaveLength(1);
265265

266-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
266+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
267267
const displayNameText = screen.queryByLabelText(displayNameHintText);
268268

269269
expect(displayNameText?.props?.children?.[0]).toBe('Test chat');
@@ -282,16 +282,16 @@ describe('Tests for group chat name', () => {
282282
signInAndGetApp("Let's talk", participantAccountIDs8)
283283
.then(() => {
284284
// Verify the sidebar links are rendered
285-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
285+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
286286
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
287287
expect(sidebarLinks).toHaveLength(1);
288288

289289
// Verify there is only one option in the sidebar
290-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
290+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
291291
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
292292
expect(optionRows).toHaveLength(1);
293293

294-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
294+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
295295
const displayNameText = screen.queryByLabelText(displayNameHintText);
296296

297297
expect(displayNameText?.props?.children?.[0]).toBe("Let's talk");
@@ -306,37 +306,37 @@ describe('Tests for group chat name', () => {
306306
return waitFor(() => expect(displayNameTexts).toHaveLength(1));
307307
}));
308308

309-
it.skip('Should show last message preview in LHN', () =>
309+
it('Should show last message preview in LHN', () =>
310310
signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => {
311311
// Verify the sidebar links are rendered
312-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
312+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
313313
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
314314
expect(sidebarLinks).toHaveLength(1);
315315

316316
// Verify there is only one option in the sidebar
317-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
317+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
318318
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
319319
expect(optionRows).toHaveLength(1);
320320

321-
const lastChatHintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview');
321+
const lastChatHintText = translateLocal('accessibilityHints.lastChatMessagePreview');
322322
const lastChatText = screen.queryByLabelText(lastChatHintText);
323323

324324
return waitFor(() => expect(lastChatText?.props?.children).toBe('B: Test'));
325325
}));
326326

327-
it.skip('Should sort the names before displaying', () =>
327+
it('Should sort the names before displaying', () =>
328328
signInAndGetApp('', [USER_E_ACCOUNT_ID, ...participantAccountIDs4]).then(() => {
329329
// Verify the sidebar links are rendered
330-
const sidebarLinksHintText = Localize.translateLocal('sidebarScreen.listOfChats');
330+
const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats');
331331
const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText);
332332
expect(sidebarLinks).toHaveLength(1);
333333

334334
// Verify there is only one option in the sidebar
335-
const optionRowsHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
335+
const optionRowsHintText = translateLocal('accessibilityHints.navigatesToChat');
336336
const optionRows = screen.queryAllByAccessibilityHint(optionRowsHintText);
337337
expect(optionRows).toHaveLength(1);
338338

339-
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
339+
const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames');
340340
const displayNameText = screen.queryByLabelText(displayNameHintText);
341341

342342
return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E'));

0 commit comments

Comments
 (0)