Skip to content

Commit 858d856

Browse files
authored
v10.4.3
2 parents 915f449 + f2aeeee commit 858d856

File tree

21 files changed

+4966
-770
lines changed

21 files changed

+4966
-770
lines changed

docusaurus/docs/React/hooks/message-list-hooks.mdx

Lines changed: 0 additions & 45 deletions
This file was deleted.

e2e/attachment-sizing.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test.describe('add height to video and image attachments', () => {
3131
expect(result).toBeTruthy();
3232
await user
3333
.sees(MessageList)
34-
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
34+
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer}`);
3535
});
3636

3737
test('should add height for single image attachments', async ({ page, user }) => {
@@ -45,7 +45,7 @@ test.describe('add height to video and image attachments', () => {
4545
expect(result).toBe(true);
4646
await user
4747
.sees(MessageList)
48-
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
48+
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer}`);
4949
});
5050

5151
test('should add height for gallery image attachments', async ({ page, user }) => {
@@ -61,6 +61,6 @@ test.describe('add height to video and image attachments', () => {
6161
expect(result).toBe(true);
6262
await user
6363
.sees(MessageList)
64-
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
64+
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer}`);
6565
});
6666
});

e2e/navigate-long-message-lists.test.ts

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable jest/expect-expect */
2-
import { Page } from '@playwright/test';
2+
import { expect, Page } from '@playwright/test';
33
import * as dotenv from 'dotenv';
44

55
import selectors from './user/selectors';
@@ -29,7 +29,7 @@ const USER1_CHAT_VIEW_CLASSNAME = `.${user1Id}`;
2929
const NEW_MESSAGE_NOTIFICATION_TEXT = 'New Messages!' as const;
3030
const LAST_REPLY_TEXT = 'Message 299';
3131
const MESSAGES_WITH_REPLIES = ['Message 149', 'Message 137', 'Message 124', 'Message 99'];
32-
32+
const FIRST_MESSAGE_FIRST_PAGE = 'Message 125';
3333
const QUOTED_MESSAGES = ['Message 99', 'Message 137'];
3434

3535
const scrollInSteps = async (user: TestingUser, msgNumbers = ['142', '135', '128'], cycles = 3) => {
@@ -157,7 +157,7 @@ test.describe('scroll to the bottom', () => {
157157
test.afterEach(async ({ controller, page }) => {
158158
const lastMessage = await page
159159
.locator(
160-
`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList} li:last-of-type ${selectors.messageText}`,
160+
`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer} li:last-of-type ${selectors.messageText}`,
161161
)
162162
.textContent();
163163
if (!lastMessage) return;
@@ -183,7 +183,7 @@ test.describe('scroll to the bottom', () => {
183183
// check that you are at the bottom
184184
await user
185185
.sees(MessageList)
186-
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
186+
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer}`);
187187
});
188188

189189
test('after loading more messages on new message notification click', async ({
@@ -196,7 +196,7 @@ test.describe('scroll to the bottom', () => {
196196

197197
// trigger load more messages
198198
const firstLoadedMessage = await page.locator(
199-
`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList} li:first-of-type`,
199+
`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer} li:first-of-type`,
200200
);
201201
await firstLoadedMessage.scrollIntoViewIfNeeded();
202202
await controller.sendOtherUserMessage();
@@ -208,6 +208,48 @@ test.describe('scroll to the bottom', () => {
208208
// check that you are at the bottom
209209
await user
210210
.sees(MessageList)
211-
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
211+
.isScrolledToBottom(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageListContainer}`);
212+
});
213+
});
214+
215+
test.describe('pagination', () => {
216+
test.beforeEach(async ({ controller, user }) => {
217+
await controller.openStory(
218+
'navigate-long-message-lists--user1',
219+
selectors.channelPreviewButton,
220+
);
221+
await user.clicks(ChannelPreview).text(CHANNEL_NAME);
222+
});
223+
224+
test('does not lead to the viewport content change', async ({ page, user }) => {
225+
const messageList = await page.locator(`${USER1_CHAT_VIEW_CLASSNAME} ${selectors.messageList}`);
226+
227+
const firstMessageFirstPage = await user.get(Message)(FIRST_MESSAGE_FIRST_PAGE);
228+
229+
let firstLoadedMessageBoxBeforePagination;
230+
const msgListBoxBeforePagination = await messageList.boundingBox();
231+
232+
// get message position before the next page of messages is received
233+
page.once('request', async () => {
234+
firstLoadedMessageBoxBeforePagination = await firstMessageFirstPage.boundingBox();
235+
});
236+
237+
await Promise.all([
238+
page.waitForResponse((r) => r.url().includes('/query') && r.ok()),
239+
firstMessageFirstPage.scrollIntoViewIfNeeded(),
240+
]);
241+
242+
const msgListBoxAfterPagination = await messageList.boundingBox();
243+
const firstLoadedMessageBoxAfterPagination = await firstMessageFirstPage.boundingBox();
244+
245+
const firstMessageShiftDistanceYToViewport =
246+
firstLoadedMessageBoxBeforePagination.y - firstLoadedMessageBoxAfterPagination.y;
247+
expect(firstMessageShiftDistanceYToViewport).toBeLessThanOrEqual(
248+
firstLoadedMessageBoxBeforePagination.height,
249+
);
250+
expect(firstMessageShiftDistanceYToViewport).toBeGreaterThanOrEqual(
251+
-firstLoadedMessageBoxBeforePagination.height,
252+
);
253+
expect(msgListBoxBeforePagination.height).not.toStrictEqual(msgListBoxAfterPagination.height);
212254
});
213255
});

e2e/user/components/MessageList/MessageList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import selectors from '../../selectors';
44
import { getMessage } from '../Message/MessageSimple';
55

66
export function getMessageList(page: Page) {
7-
return page.locator(selectors.messageList);
7+
return page.locator(selectors.messageListContainer);
88
}
99

1010
export default (page: Page) => ({

e2e/user/selectors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default {
2424
messageData: `.str-chat__message-data`,
2525
messageInput: 'data-testid=message-input',
2626
messageInputTextareaThread: '.str-chat__message-input [data-testid="message-input"]',
27-
messageList: '.str-chat__list',
27+
messageList: '.str-chat__ul',
28+
messageListContainer: '.str-chat__list',
2829
messageNotification: '.str-chat__message-notification',
2930
messageRepliesButton: '.str-chat__message-simple-reply-button',
3031
messageSimple: '.str-chat__message-simple',

0 commit comments

Comments
 (0)