Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Dec 17, 2024
1 parent d256b45 commit 604b3f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
13 changes: 12 additions & 1 deletion ui-tests/tests/notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ test.describe('#notifications', () => {
test('should receive notification on unread message', async ({ page }) => {
const chatPanel = await openChat(page, FILENAME);
const messages = chatPanel.locator('.jp-chat-message');
await messages.first().scrollIntoViewIfNeeded();

// Navigate to the last to set all messages as read.
await messages.last().scrollIntoViewIfNeeded();

await messages.first().scrollIntoViewIfNeeded();
await sendMessage(guestPage, FILENAME, MSG_CONTENT);
await page.waitForCondition(
async () => (await page.notifications).length > 0
Expand All @@ -110,6 +113,10 @@ test.describe('#notifications', () => {
}) => {
const chatPanel = await openChat(page, FILENAME);
const messages = chatPanel.locator('.jp-chat-message');

// Navigate to the last to set all messages as read.
await messages.last().scrollIntoViewIfNeeded();

Check failure on line 118 in ui-tests/tests/notifications.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/notifications.spec.ts:111:7 › #notifications › should remove notification when the message is read

4) tests/notifications.spec.ts:111:7 › #notifications › should remove notification when the message is read Error: locator.scrollIntoViewIfNeeded: Element is not attached to the DOM Call log: - attempting scroll into view action - waiting for element to be stable 116 | 117 | // Navigate to the last to set all messages as read. > 118 | await messages.last().scrollIntoViewIfNeeded(); | ^ 119 | 120 | await messages.first().scrollIntoViewIfNeeded(); 121 | at /home/runner/work/jupyter-chat/jupyter-chat/ui-tests/tests/notifications.spec.ts:118:27

await messages.first().scrollIntoViewIfNeeded();

await sendMessage(guestPage, FILENAME, MSG_CONTENT);
Expand All @@ -130,6 +137,10 @@ test.describe('#notifications', () => {
}) => {
const chatPanel = await openChat(page, FILENAME);
const messages = chatPanel.locator('.jp-chat-message');

// Navigate to the last to set all messages as read.
await messages.last().scrollIntoViewIfNeeded();

await messages.first().scrollIntoViewIfNeeded();

await sendMessage(guestPage, FILENAME, MSG_CONTENT);
Expand Down
16 changes: 9 additions & 7 deletions ui-tests/tests/unread.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ test.describe('#messagesNavigation', () => {
const messages = chatPanel.locator('.jp-chat-message');
const navigationBottom = chatPanel.locator('.jp-chat-navigation-bottom');

// Navigate to the last to set all messages as read.
await messages.last().scrollIntoViewIfNeeded();

// Move to the first message.
await messages.first().scrollIntoViewIfNeeded();

await expect(navigationBottom).toBeAttached();

// FIXME: This test uses the fact that some messages are marked as read even if
// they are not displayed, because the unread state is computed before the full
// rendering of all messages.
// If the unread state wait for the rendermimeMarkdown, this test should fail
// because the last messages will be marked as unread.
expect(navigationBottom).not.toHaveClass(/jp-chat-navigation-unread/);
expect(await navigationBottom.screenshot()).toMatchSnapshot(
'navigation-bottom.png'
Expand Down Expand Up @@ -179,9 +177,13 @@ test.describe('#messagesNavigation', () => {

test('should have unread icon for new messages', async ({ page }) => {
const chatPanel = await openChat(page, FILENAME);
const message = chatPanel.locator('.jp-chat-message').first();
const messages = chatPanel.locator('.jp-chat-message');

// Navigate to the last to set all messages as read.
await messages.last().scrollIntoViewIfNeeded();

const navigationBottom = chatPanel.locator('.jp-chat-navigation-bottom');
await message.scrollIntoViewIfNeeded();
await messages.first().scrollIntoViewIfNeeded();

await expect(navigationBottom).toBeAttached();
expect(navigationBottom).not.toHaveClass(/jp-chat-navigation-unread/);
Expand Down

0 comments on commit 604b3f5

Please sign in to comment.