-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathflipperButton.html
More file actions
65 lines (54 loc) · 2.39 KB
/
flipperButton.html
File metadata and controls
65 lines (54 loc) · 2.39 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
WebChat.renderWebChat(
{
directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }),
store: testHelpers.createStore()
},
document.getElementById('webchat')
);
await pageConditions.uiConnected();
await pageObjects.sendMessageViaSendBox('carousel');
await pageConditions.numActivitiesShown(2);
// GIVEN: Carousel is at left most position.
const carouselLayout = document.querySelector('.webchat__carousel-layout');
const carouselFilmstrip = carouselLayout.querySelector('.webchat__carousel-filmstrip');
expect(carouselFilmstrip.scrollLeft).toBe(0);
// WHEN: Right flipper is clicked.
const rightFlipper = carouselLayout.querySelector('[aria-label="Next"]');
// Improve test reliability by hover before click on flipper button.
await host.hover(rightFlipper);
await testHelpers.sleep(500);
await host.click(rightFlipper);
// THEN: It should scroll right.
await pageConditions.became('Carousel should scroll right', () => carouselFilmstrip.scrollLeft > 100, 1000);
await testHelpers.sleep(500); // Wait both flippers to fade in.
await host.snapshot('local');
// WHEN: Left flipper is clicked.
const leftFlipper = carouselLayout.querySelector('[aria-label="Previous"]');
// Improve test reliability by hover before click on flipper button.
await host.hover(leftFlipper);
await testHelpers.sleep(500);
await host.click(leftFlipper);
// THEN: It should scroll left.
await pageConditions.became(
'Carousel should scroll left',
() => Math.abs(carouselFilmstrip.scrollLeft) < 1,
1000
); // 1 pixel for tolerance.
await testHelpers.sleep(500); // Wait for right flipper to fade away.
await host.snapshot('local');
});
</script>
</body>
</html>