|
| 1 | +import type { IRoom } from '@rocket.chat/core-typings'; |
| 2 | + |
| 3 | +import { Users } from './fixtures/userStates'; |
| 4 | +import { HomeChannel } from './page-objects'; |
| 5 | +import { createTargetChannelAndReturnFullRoom } from './utils'; |
| 6 | +import { sendFillerMessages } from './utils/sendMessage'; |
| 7 | +import type { BaseTest } from './utils/test'; |
| 8 | +import { expect, test } from './utils/test'; |
| 9 | + |
| 10 | +test.use({ storageState: Users.admin.state }); |
| 11 | + |
| 12 | +test.describe.serial('Thread persistence on navigation', () => { |
| 13 | + let poHomeChannel: HomeChannel; |
| 14 | + let targetChannel: IRoom; |
| 15 | + let threadParentMessageId: string; |
| 16 | + |
| 17 | + const setupChannelData = async (api: BaseTest['api']) => { |
| 18 | + const rid = targetChannel._id; |
| 19 | + |
| 20 | + const { message: parentMessage } = await (await api.post('/chat.postMessage', { roomId: rid, text: 'Thread parent message' })).json(); |
| 21 | + threadParentMessageId = parentMessage._id; |
| 22 | + |
| 23 | + await api.post('/chat.postMessage', { |
| 24 | + roomId: rid, |
| 25 | + text: 'Thread reply that should persist after navigation', |
| 26 | + tmid: parentMessage._id, |
| 27 | + }); |
| 28 | + |
| 29 | + await sendFillerMessages(api, rid); |
| 30 | + }; |
| 31 | + |
| 32 | + test.beforeAll(async ({ api }) => { |
| 33 | + const { channel } = await createTargetChannelAndReturnFullRoom(api); |
| 34 | + targetChannel = channel; |
| 35 | + await setupChannelData(api); |
| 36 | + }); |
| 37 | + |
| 38 | + test.afterAll(({ api }) => api.post('/channels.delete', { roomId: targetChannel._id })); |
| 39 | + |
| 40 | + test.beforeEach(async ({ page }) => { |
| 41 | + poHomeChannel = new HomeChannel(page); |
| 42 | + }); |
| 43 | + |
| 44 | + test('expect thread content to persist after clicking Jump to recent messages', async ({ page }) => { |
| 45 | + await page.goto(`/channel/${targetChannel.name}?msg=${threadParentMessageId}`); |
| 46 | + await poHomeChannel.content.waitForChannel(); |
| 47 | + |
| 48 | + await expect(page).toHaveURL(/.*thread/); |
| 49 | + await expect(poHomeChannel.content.threadMessageList).toBeVisible(); |
| 50 | + const threadMessageCount = await poHomeChannel.content.threadMessageListItems.count(); |
| 51 | + expect(threadMessageCount).toBeGreaterThan(0); |
| 52 | + |
| 53 | + const jumpToRecentButton = page.getByRole('button', { name: 'Jump to recent messages' }); |
| 54 | + await expect(jumpToRecentButton).toBeVisible(); |
| 55 | + await jumpToRecentButton.click(); |
| 56 | + |
| 57 | + await expect(page).toHaveURL(/.*thread/); |
| 58 | + await expect(poHomeChannel.content.threadMessageList).toBeVisible(); |
| 59 | + await expect(poHomeChannel.content.threadMessageListItems).toHaveCount(threadMessageCount); |
| 60 | + await expect(poHomeChannel.content.threadMessageList).toContainText('Thread reply that should persist after navigation'); |
| 61 | + }); |
| 62 | +}); |
0 commit comments