-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathKeyboard.test.js
More file actions
76 lines (63 loc) · 2.83 KB
/
Keyboard.test.js
File metadata and controls
76 lines (63 loc) · 2.83 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
import { default as TestIDs, default as testIDs } from '../playground/src/testIDs';
import { device } from 'detox';
import Utils from './Utils';
import kbdDriver from './drivers/androidKeyboard';
const { elementByLabel, elementById, sleep } = Utils;
const KBD_OBSCURED_TEXT = 'Keyboard Demo';
describe.e2e('Keyboard', () => {
beforeAll(async () => {
await kbdDriver.init();
await kbdDriver.enableOnScreenKeyboard();
if (device.getPlatform() === 'android') {
// 1st-time Android keyboard appearance is laggy (Android's lazy init?)
await device.launchApp({ newInstance: true });
await elementById(TestIDs.KEYBOARD_SCREEN_BTN).tap();
await elementById(TestIDs.TEXT_INPUT1).tap();
await sleep(2000);
}
});
afterAll(async () => {
await kbdDriver.restoreOnScreenKeyboard();
});
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.KEYBOARD_SCREEN_BTN).tap();
});
it('Push - should close keyboard when Back clicked', async () => {
await expect(elementByLabel(KBD_OBSCURED_TEXT)).toBeVisible();
await elementById(TestIDs.TEXT_INPUT1).tap();
await expect(elementByLabel(KBD_OBSCURED_TEXT)).not.toBeVisible();
await elementById(TestIDs.BACK_BUTTON).tap();
await expect(elementById(testIDs.MAIN_BOTTOM_TABS)).toBeVisible();
});
it('Modal - should close keyboard when close clicked', async () => {
await elementById(TestIDs.MODAL_BTN).tap();
await elementById(TestIDs.TEXT_INPUT1).tap();
await expect(elementByLabel(KBD_OBSCURED_TEXT)).not.toBeVisible();
await elementById(TestIDs.DISMISS_MODAL_TOPBAR_BTN).tap();
await expect(elementById(testIDs.MAIN_BOTTOM_TABS)).toBeVisible();
});
it('focus keyboard continue to resize content', async () => {
await elementById(TestIDs.TEXT_INPUT2).typeText("Hello");
await elementById(TestIDs.TEXT_INPUT2).tapReturnKey();
await expect(elementById(TestIDs.TEXT_INPUT1)).toBeFocused();
await expect(elementById(TestIDs.TEXT_INPUT1)).toBeVisible();
});
it('focus keyboard on push', async () => {
await elementById(TestIDs.PUSH_FOCUSED_KEYBOARD_SCREEN).tap();
await expect(elementById(TestIDs.TEXT_INPUT1)).toBeFocused();
});
it('focus keyboard on show modal', async () => {
await elementById(TestIDs.MODAL_FOCUSED_KEYBOARD_SCREEN).tap();
await expect(elementById(TestIDs.TEXT_INPUT1)).toBeFocused();
});
it('doesnt focus keyboard on show modal', async () => {
await elementById(TestIDs.MODAL_BTN).tap();
await expect(elementById(TestIDs.TEXT_INPUT1)).not.toBeFocused();
});
it(':android: should respect UI with keyboard awareness', async () => {
await elementById(TestIDs.PUSH_KEYBOARD_SCREEN_STICKY_FOOTER).tap();
await elementById(TestIDs.TEXT_INPUT2).tap();
await expect(elementByLabel(KBD_OBSCURED_TEXT)).toBeVisible();
});
});