Skip to content

Commit 29456ef

Browse files
committed
test(checkbox, toggle): add screenshots
1 parent 7410227 commit 29456ef

File tree

2 files changed

+84
-48
lines changed

2 files changed

+84
-48
lines changed

core/src/components/checkbox/test/basic/checkbox.e2e.ts

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,48 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
135135
});
136136

137137
test.describe(title('checkbox: ionFocus'), () => {
138+
test('should not have visual regressions', async ({ page, pageUtils }) => {
139+
await page.setContent(
140+
`
141+
<style>
142+
#container {
143+
display: inline-block;
144+
padding: 10px;
145+
}
146+
</style>
147+
148+
<div id="container">
149+
<ion-checkbox>Unchecked</ion-checkbox>
150+
</div>
151+
`,
152+
config
153+
);
154+
155+
await pageUtils.pressKeys('Tab');
156+
157+
const container = page.locator('#container');
158+
159+
await expect(container).toHaveScreenshot(screenshot(`checkbox-focus`));
160+
});
161+
162+
test('should not have visual regressions when interacting with checkbox in item', async ({ page, pageUtils }) => {
163+
await page.setContent(
164+
`
165+
<ion-item class="ion-focused">
166+
<ion-checkbox>Unchecked</ion-checkbox>
167+
</ion-item>
168+
`,
169+
config
170+
);
171+
172+
// Test focus with keyboard navigation.
173+
await pageUtils.pressKeys('Tab');
174+
175+
const item = page.locator('ion-item');
176+
177+
await expect(item).toHaveScreenshot(screenshot(`checkbox-in-item-focus`));
178+
});
179+
138180
test('should fire ionFocus when checkbox is focused', async ({ page, pageUtils }) => {
139181
await page.setContent(
140182
`
@@ -212,30 +254,6 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
212254
await checkbox.evaluate((el: HTMLIonCheckboxElement) => (el.checked = true));
213255
expect(ionFocus).not.toHaveReceivedEvent();
214256
});
215-
216-
test('should not have visual regressions', async ({ page, pageUtils }) => {
217-
await page.setContent(
218-
`
219-
<style>
220-
#container {
221-
display: inline-block;
222-
padding: 10px;
223-
}
224-
</style>
225-
226-
<div id="container">
227-
<ion-checkbox>Unchecked</ion-checkbox>
228-
</div>
229-
`,
230-
config
231-
);
232-
233-
await pageUtils.pressKeys('Tab');
234-
235-
const container = page.locator('#container');
236-
237-
await expect(container).toHaveScreenshot(screenshot(`checkbox-focus`));
238-
});
239257
});
240258

241259
test.describe(title('checkbox: ionBlur'), () => {

core/src/components/toggle/test/basic/toggle.e2e.ts

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,48 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
9292
});
9393

9494
test.describe(title('toggle: ionFocus'), () => {
95+
test('should not have visual regressions', async ({ page, pageUtils }) => {
96+
await page.setContent(
97+
`
98+
<style>
99+
#container {
100+
display: inline-block;
101+
padding: 10px;
102+
}
103+
</style>
104+
105+
<div id="container">
106+
<ion-toggle>Unchecked</ion-toggle>
107+
</div>
108+
`,
109+
config
110+
);
111+
112+
await pageUtils.pressKeys('Tab');
113+
114+
const container = page.locator('#container');
115+
116+
await expect(container).toHaveScreenshot(screenshot(`toggle-focus`));
117+
});
118+
119+
test('should not have visual regressions when interacting with toggle in item', async ({ page, pageUtils }) => {
120+
await page.setContent(
121+
`
122+
<ion-item class="ion-focused">
123+
<ion-toggle>Unchecked</ion-toggle>
124+
</ion-item>
125+
`,
126+
config
127+
);
128+
129+
// Test focus with keyboard navigation.
130+
await pageUtils.pressKeys('Tab');
131+
132+
const item = page.locator('ion-item');
133+
134+
await expect(item).toHaveScreenshot(screenshot(`toggle-in-item-focus`));
135+
});
136+
95137
test('should fire ionFocus when toggle is focused', async ({ page, pageUtils }) => {
96138
await page.setContent(
97139
`
@@ -169,29 +211,5 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
169211
await toggle.evaluate((el: HTMLIonToggleElement) => (el.checked = true));
170212
expect(ionFocus).not.toHaveReceivedEvent();
171213
});
172-
173-
test('should not have visual regressions', async ({ page, pageUtils }) => {
174-
await page.setContent(
175-
`
176-
<style>
177-
#container {
178-
display: inline-block;
179-
padding: 10px;
180-
}
181-
</style>
182-
183-
<div id="container">
184-
<ion-toggle>Unchecked</ion-toggle>
185-
</div>
186-
`,
187-
config
188-
);
189-
190-
await pageUtils.pressKeys('Tab');
191-
192-
const container = page.locator('#container');
193-
194-
await expect(container).toHaveScreenshot(screenshot(`toggle-focus`));
195-
});
196214
});
197215
});

0 commit comments

Comments
 (0)