Skip to content

Commit b866eca

Browse files
committed
test(alert): update to move spec test logic to existing e2e test
1 parent d913f13 commit b866eca

File tree

2 files changed

+21
-54
lines changed

2 files changed

+21
-54
lines changed

core/src/components/alert/test/a11y/alert.e2e.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ const testAria = async (
1717

1818
const alert = page.locator('ion-alert');
1919

20+
const header = alert.locator('.alert-title');
21+
const subHeader = alert.locator('.alert-sub-title');
22+
23+
// If a header exists, it should be an h2 element
24+
if (await header.count() > 0) {
25+
const headerTagName = await header.evaluate((el) => el.tagName);
26+
expect(headerTagName).toBe('H2');
27+
}
28+
29+
// If a header and subHeader exist, the subHeader should be an h3 element
30+
if (await header.count() > 0 && await subHeader.count() > 0) {
31+
const subHeaderTagName = await subHeader.evaluate((el) => el.tagName);
32+
expect(subHeaderTagName).toBe('H3');
33+
}
34+
35+
// If a subHeader exists without a header, the subHeader should be an h2 element
36+
if (await header.count() === 0 && await subHeader.count() > 0) {
37+
const subHeaderTagName = await subHeader.evaluate((el) => el.tagName);
38+
expect(subHeaderTagName).toBe('H2');
39+
}
40+
2041
/**
2142
* expect().toHaveAttribute() can't check for a null value, so grab and check
2243
* the values manually instead.

core/src/components/alert/test/alert-aria.spec.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)