-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathrenderItems.e2e.test.js
More file actions
86 lines (71 loc) · 3.91 KB
/
renderItems.e2e.test.js
File metadata and controls
86 lines (71 loc) · 3.91 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
81
82
83
84
85
86
const { device, expect, element, by, waitFor } = require('detox');
const SCREENS = {
zero: 'container_swiper_renderItem_screen_0',
one: 'container_swiper_renderItem_screen_1',
two: 'container_swiper_renderItem_screen_2',
three: 'container_swiper_renderItem_screen_3',
fourth: 'container_swiper_renderItem_screen_4',
};
const DELAY = 2 * 1000;
const ANIMATION_SETTLE_TIMEOUT = 500;
describe('example with renderItems and data', () => {
beforeAll(async () => {
await device.launchApp();
});
beforeEach(async () => {
await device.reloadReactNative();
// TODO: add menu with steps!
// await element(by.id('renderItem')).tap();
});
it('should see screen', async () => {
await expect(element(by.id('container_swiper_renderItem'))).toBeVisible();
});
it('should execute autoplay every 2.0s', async () => {
// 0s => screen with zero
await expect(element(by.id(SCREENS.zero))).toBeVisible();
await waitFor(element(by.id(SCREENS.zero)))
.toBeVisible()
.withTimeout(DELAY);
await waitFor(element(by.id(SCREENS.one))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.two))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.three))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.fourth))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
// after 2s => screen with one
await new Promise((_) => setTimeout(_, DELAY / 2));
await waitFor(element(by.id(SCREENS.one)))
.toBeVisible()
.withTimeout(DELAY);
await waitFor(element(by.id(SCREENS.zero))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.two))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.three))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.fourth))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
// after 4s => screen with two
await new Promise((_) => setTimeout(_, DELAY / 2));
await waitFor(element(by.id(SCREENS.two)))
.toBeVisible()
.withTimeout(DELAY);
await waitFor(element(by.id(SCREENS.zero))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.one))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.three))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.fourth))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
// after 6s => screen with three
await new Promise((_) => setTimeout(_, DELAY / 2));
await waitFor(element(by.id(SCREENS.three)))
.toBeVisible()
.withTimeout(DELAY);
await waitFor(element(by.id(SCREENS.zero))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.one))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.two))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.fourth))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
// after 8s => screen with fourth
await new Promise((_) => setTimeout(_, DELAY / 2));
await waitFor(element(by.id(SCREENS.fourth)))
.toBeVisible()
.withTimeout(DELAY);
await waitFor(element(by.id(SCREENS.zero))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.one))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.two))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
await waitFor(element(by.id(SCREENS.three))).toBeNotVisible().withTimeout(ANIMATION_SETTLE_TIMEOUT);
});
// https://github.com/wix/Detox/blob/master/docs/APIRef.ActionsOnElement.md#swipedirection-speed-percentage
});