-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathReadReceipt.test.ts
More file actions
80 lines (70 loc) · 3.21 KB
/
ReadReceipt.test.ts
File metadata and controls
80 lines (70 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { expect } from '@playwright/test';
import { temporarilyShowHiddenChatComposite } from '../../common/hermeticChatTestHelpers';
import { sendMessage, waitForMessageDelivered, waitForMessageSeen } from '../../common/chatTestHelpers';
import {
dataTestId,
dataUiId,
perStepLocalTimeout,
screenshotOnFailure,
stableScreenshot,
waitForSelector
} from '../../common/utils';
import { buildUrlForChatAppUsingFakeAdapter, DEFAULT_FAKE_CHAT_ADAPTER_ARGS, test } from './fixture';
test.describe('Chat Composite E2E Tests', () => {
test('participant can receive message and send readReceipt to message sender', async ({ serverUrl, page }) => {
const messageReader = DEFAULT_FAKE_CHAT_ADAPTER_ARGS.remoteParticipants[0];
if (!messageReader) {
throw new Error('No remote participants found');
}
page.goto(
buildUrlForChatAppUsingFakeAdapter(serverUrl, {
...DEFAULT_FAKE_CHAT_ADAPTER_ARGS,
participantsWithHiddenComposites: [messageReader]
})
);
await sendMessage(page, 'How the turn tables');
await waitForMessageDelivered(page);
expect(await stableScreenshot(page, { stubMessageTimestamps: true })).toMatchSnapshot('sent-messages.png');
await temporarilyShowHiddenChatComposite(page, messageReader);
await waitForMessageSeen(page);
// Can't use `pageClick()` here because we want the tooltips to be shown.
// `pageClick()` moves the mouse away explicitly to dismiss the tooltips.
await screenshotOnFailure(
page,
async () => await page.click(dataUiId('chat-composite-message-status-icon'), { timeout: perStepLocalTimeout() })
);
await waitForSelector(page, dataUiId('chat-composite-message-tooltip'));
expect(await stableScreenshot(page, { stubMessageTimestamps: true, dismissTooltips: false })).toMatchSnapshot(
'read-message-tooltip-text.png'
);
});
test('participant can receive read receipts and readers should show in contextual menu', async ({
serverUrl,
page
}) => {
page.goto(
buildUrlForChatAppUsingFakeAdapter(serverUrl, {
...DEFAULT_FAKE_CHAT_ADAPTER_ARGS,
participantsWithHiddenComposites: DEFAULT_FAKE_CHAT_ADAPTER_ARGS.remoteParticipants
})
);
await sendMessage(page, 'How the turn tables');
await waitForMessageDelivered(page);
for (const participant of DEFAULT_FAKE_CHAT_ADAPTER_ARGS.remoteParticipants) {
await temporarilyShowHiddenChatComposite(page, participant);
}
await waitForMessageSeen(page);
await screenshotOnFailure(page, async () => {
await page.locator(dataTestId('chat-composite-message')).first().click();
await page.locator(dataTestId('chat-composite-message-action-icon')).first().click();
await page.waitForSelector(dataTestId('chat-composite-message-contextual-menu-edit-action'));
await page.locator(dataUiId('chat-composite-message-contextual-menu-read-info')).click();
await page.waitForSelector(dataUiId('chat-composite-message-contextual-menu-read-name-list-item'));
});
expect(await stableScreenshot(page, { stubMessageTimestamps: true })).toMatchSnapshot(
'read-message-contextualMenu.png'
);
});
});