forked from edgarmsilva/QAEngineeringChallenge2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
other.test.js
66 lines (56 loc) · 3.12 KB
/
other.test.js
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
import { expect, by, device, element, waitFor } from 'detox';
import { LOG_PART_TAB } from './test-assets/screens/logPartTab';
import { MACHINE_STATE_TAB } from './test-assets/screens/machineStateTab';
import { elementIsVisible } from './test-assets/utils/interactions';
describe('Start Tests', () => {
it('Should load up', async () => {
//app loads by default on machine state tab so tab should be visible
await waitFor(MACHINE_STATE_TAB.TAB_TITLE).toBeVisible();
//log part tab should be visible
await waitFor(LOG_PART_TAB.TAB_TITLE).toBeVisible();
//reset machine data and calculate health buttons should be visible
await waitFor(MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_ID).toBeVisible();
await waitFor(MACHINE_STATE_TAB.CALCULATE_HEALTH_ELEMENT_BY_ID).toBeVisible();
//the app should ask to log a part when there is none
if (await elementIsVisible(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID)) {
await MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_ID.tap();
} else {
await MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_TEXT.tap();
}
await waitFor(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID).toBeVisible();
//asserts of all elements visibility
await expect(MACHINE_STATE_TAB.TAB_TITLE).toBeVisible();
await expect(LOG_PART_TAB.TAB_TITLE).toBeVisible();
await expect(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID).toBeVisible();
await expect(MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_ID).toBeVisible();
});
it('Should navigate between tabs accordingly', async () => {
await LOG_PART_TAB.navigateTo();
await expect(LOG_PART_TAB.TAB_TITLE).toBeVisible();
await expect(LOG_PART_TAB.PART_VALUE_INPUT_ELEMENT_BY_ID).toBeVisible();
await expect(MACHINE_STATE_TAB.TAB_TITLE).toBeVisible();
await MACHINE_STATE_TAB.navigateTo();
await expect(MACHINE_STATE_TAB.TAB_TITLE).toBeVisible();
await expect(MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_ID).toBeVisible();
await expect(LOG_PART_TAB.TAB_TITLE).toBeVisible();
});
it('Tap to please log a part should navigate to log part tab', async () => {
await waitFor(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID).toBeVisible();
if (await elementIsVisible(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID)) {
await MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID.tap();
} else {
await MACHINE_STATE_TAB.RESET_MACHINE_DATA_ELEMENT_BY_TEXT.tap();
}
await waitFor(LOG_PART_TAB.TAB_TITLE).toBeVisible();
await waitFor(LOG_PART_TAB.PART_VALUE_INPUT_ELEMENT_BY_ID).toBeVisible();
await waitFor(LOG_PART_TAB.SAVE_BUTTON_ELEMENT_BY_TEXT).toBeVisible();
await expect(LOG_PART_TAB.PART_VALUE_INPUT_ELEMENT_BY_ID).toBeVisible();
await expect(LOG_PART_TAB.SAVE_BUTTON_ELEMENT_BY_TEXT).toBeVisible();
});
it('Should not crash if calculate health with no parts logged', async () => {
await MACHINE_STATE_TAB.resetMachineData();
await MACHINE_STATE_TAB.calculateHealth();
await waitFor(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID).toBeVisible();
await expect(MACHINE_STATE_TAB.PLEASE_LOG_PART_ELEMENT_BY_ID).toBeVisible();
});
});