-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathMessageThread.spec.tsx
More file actions
51 lines (46 loc) · 2.1 KB
/
MessageThread.spec.tsx
File metadata and controls
51 lines (46 loc) · 2.1 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import React from 'react';
import { expect } from '@playwright/experimental-ct-react';
import { test as betaTest } from './FlavoredBaseTest';
import { Message, MessageThread } from '../../src';
betaTest.describe('MessageThread inline image tests', () => {
betaTest.skip(({ isBetaBuild }) => !isBetaBuild, 'The tests should be run for beta flavor only');
betaTest('MessageThread inline image should show grey box when loading', async ({ mount }) => {
const component = await mount(<MessageThread userId={'1'} messages={getMessages('')} />);
await component.evaluate(() => document.fonts.ready);
await expect(component).toHaveScreenshot('message-thread-inline-image-loading-stage.png');
});
betaTest('MessageThread inline image should show broken image icon with invalid src', async ({ mount }) => {
const component = await mount(<MessageThread userId={'1'} messages={getMessages('http://')} />);
await component.evaluate(() => document.fonts.ready);
await expect(component).toHaveScreenshot('message-thread-inline-image-broken-image.png');
});
const getMessages = (imgSrc: string): Message[] => {
const messages: Message[] = [
{
messageType: 'chat',
senderId: 'user3',
content: `<p>How should I design my new house?</p><p><img alt="image" src="${imgSrc}" itemscope="png" width="374" height="250" id="SomeImageId2" style="vertical-align:bottom; aspect-ratio: 374 / 250"></p><p> </p>`,
senderDisplayName: 'Miguel Garcia',
messageId: Math.random().toString(),
createdOn: new Date('2019-04-13T00:00:00.000+08:09'),
mine: false,
attached: false,
contentType: 'html'
},
{
messageType: 'chat',
senderId: 'user2',
senderDisplayName: 'Robert Tolbert',
messageId: Math.random().toString(),
content: 'Cool, I love the second one!',
createdOn: new Date('2019-04-13T00:00:00.000+08:10'),
mine: true,
attached: false,
contentType: 'text'
}
];
return messages;
};
});