Skip to content

Commit ce993e4

Browse files
committed
test: add another chat multiselect test
1 parent 1bf5e54 commit ce993e4

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

packages/e2e-tests/tests/chat-list-multiselect.spec.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,86 @@ test("selection doesn't reset if items get reordered", async () => {
437437
)
438438
})
439439

440+
test('when chats get removed from the list, they get unselected', async () => {
441+
// Using the "search" function is perhaps not
442+
// the most appropriate display of items getting removed from the list,
443+
// but it's probably the best one we can get by using a single device
444+
// and not being able to receive messages on command.
445+
446+
// This is a pretty stupid hack to ensure that the search results
447+
// get "cached". When we perform the search for the first time,
448+
// there is a moment when it shows 0 chats before the results get loaded,
449+
// resulting in all chats getting unselected, which we don't want.
450+
await page.getByRole('textbox', { name: 'Search' }).fill('5')
451+
await expect(chatList.getByRole('tab', { name: 'Some chat ' })).toContainText(
452+
['Some chat 5']
453+
)
454+
await page.getByRole('textbox', { name: 'Search' }).clear()
455+
456+
await getChat(9).click()
457+
await expectSelectedChats([9])
458+
await getChat(1).click({
459+
modifiers: ['Shift'],
460+
})
461+
await expectSelectedChats([9, 8, 7, 6, 5, 4, 3, 2, 1])
462+
463+
await page.getByRole('textbox', { name: 'Search' }).fill('5')
464+
await expect(chatList.getByRole('tab', { name: 'Some chat ' })).toContainText(
465+
['Some chat 5']
466+
)
467+
await expectSelectedChats([5])
468+
469+
// Check that the action only affects a single chat.
470+
await getChat(5).click({
471+
button: 'right',
472+
})
473+
await page.getByRole('menuitem', { name: 'Pin Chat' }).click()
474+
await page.getByRole('textbox', { name: 'Search' }).clear()
475+
await expect(chatList.getByRole('tab', { name: 'Some chat ' })).toContainText(
476+
[
477+
'Some chat 5',
478+
479+
'Some chat 9',
480+
'Some chat 8',
481+
'Some chat 7',
482+
'Some chat 6',
483+
'Some chat 4',
484+
'Some chat 3',
485+
'Some chat 2',
486+
'Some chat 1',
487+
]
488+
)
489+
await expect(
490+
chatList.getByRole('tab', { name: 'Some chat ' }).getByLabel('Pin')
491+
).toHaveCount(1)
492+
493+
// Now verify that the previously selected chats are not selected
494+
// after they have been brought back.
495+
// Why? See the comment
496+
// "Remove chats from selection that have been removed from `chatListIds`"
497+
// in the code base.
498+
await expectSelectedChats([5])
499+
500+
await getChat(5).click({
501+
button: 'right',
502+
})
503+
// Unpin all, to restore state for other tests.
504+
await page.getByRole('menuitem', { name: 'Unpin Chat' }).click()
505+
await expect(chatList.getByRole('tab', { name: 'Some chat ' })).toContainText(
506+
[
507+
'Some chat 9',
508+
'Some chat 8',
509+
'Some chat 7',
510+
'Some chat 6',
511+
'Some chat 5',
512+
'Some chat 4',
513+
'Some chat 3',
514+
'Some chat 2',
515+
'Some chat 1',
516+
]
517+
)
518+
})
519+
440520
test('delete several', async () => {
441521
await getChat(7).click()
442522
await expectSelectedChats([7])

0 commit comments

Comments
 (0)