-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
textarea.e2e.ts
98 lines (73 loc) · 3.25 KB
/
textarea.e2e.ts
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
87
88
89
90
91
92
93
94
95
96
97
98
import { expect } from '@playwright/test';
import { test, configs } from '@utils/test/playwright';
const IGNORED_KEYS = ['Tab', 'Shift', 'Meta', 'Alt', 'Control'];
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('textarea: clearOnEdit'), () => {
test('should clear when typed into', async ({ page }) => {
await page.setContent(
`<ion-textarea value="abc" clear-on-edit="true" aria-label="textarea"></ion-textarea>`,
config
);
const ionInput = await page.spyOnEvent('ionInput');
const textarea = page.locator('ion-textarea');
await textarea.locator('textarea').type('h');
await ionInput.next();
await expect(textarea).toHaveJSProperty('value', 'h');
});
test('should not clear when tab is pressed', async ({ page }) => {
await page.setContent(
`<ion-textarea value="abc" clear-on-edit="true" aria-label="textarea"></ion-textarea>`,
config
);
const textarea = page.locator('ion-textarea');
await textarea.locator('textarea').focus();
await page.keyboard.press('Tab');
await page.waitForChanges();
await expect(textarea).toHaveJSProperty('value', 'abc');
});
test('should not clear the textarea if it does not have an initial value when typing', async ({ page }) => {
await page.setContent(`<ion-textarea label="textarea" value="" clear-on-edit="true"></ion-textarea>`, config);
const textarea = page.locator('ion-textarea');
await textarea.click();
await textarea.type('hello world');
await expect(textarea).toHaveJSProperty('value', 'hello world');
});
IGNORED_KEYS.forEach((ignoredKey: string) => {
test(`should not clear when ${ignoredKey} is pressed`, async ({ page, skip }) => {
skip.browser(
(browserName: string) => browserName === 'firefox' && ignoredKey === 'Meta',
'Firefox incorrectly adds "OS" to the textarea when pressing the Meta key on Linux'
);
await page.setContent(
`<ion-textarea value="abc" clear-on-edit="true" aria-label="textarea"></ion-textarea>`,
config
);
const textarea = page.locator('ion-textarea');
await textarea.locator('textarea').focus();
await page.keyboard.press(ignoredKey);
await page.waitForChanges();
await expect(textarea).toHaveJSProperty('value', 'abc');
});
});
test('should clear after when pressing valid key after pressing ignored key', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/28633',
});
await page.setContent(
`<ion-textarea value="abc" clear-on-edit="true" aria-label="textarea"></ion-textarea>`,
config
);
const textarea = page.locator('ion-textarea');
await textarea.locator('textarea').focus();
// ignored
await page.keyboard.press('Shift');
await page.waitForChanges();
await expect(textarea).toHaveJSProperty('value', 'abc');
// allowed
await page.keyboard.press('a');
await page.waitForChanges();
await expect(textarea).toHaveJSProperty('value', 'a');
});
});
});