Skip to content

Commit 9675b89

Browse files
committed
test(css): convert to playwright tests
1 parent 596b9e4 commit 9675b89

File tree

5 files changed

+149
-256
lines changed

5 files changed

+149
-256
lines changed

core/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@
9090
"prerender.e2e": "node scripts/testing/prerender.js",
9191
"prettier": "prettier \"./src/**/*.{html,ts,tsx,js,jsx}\"",
9292
"start": "npm run build.css && stencil build --dev --watch --serve",
93-
"test": "npm run test.css && npm run test.spec && npm run test.e2e",
94-
"test.css": "sh -c 'for f in src/css/test/*.mjs; do node \"$f\"; done'",
93+
"test": "npm run test.spec && npm run test.e2e",
9594
"test.spec": "stencil test --spec --max-workers=2",
9695
"test.e2e": "npx playwright test",
9796
"test.e2e.update-snapshots": "npm run test.e2e -- --update-snapshots='changed'",

core/src/css/test/display.e2e.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { test, expect } from '@playwright/test';
2+
import fs from 'fs';
3+
import path from 'path';
4+
5+
test.describe('display css utility classes', () => {
6+
let css: string;
7+
8+
test.beforeAll(() => {
9+
css = fs.readFileSync(path.resolve(__dirname, '../../../css/display.css'), 'utf8');
10+
});
11+
12+
const INFIXES = ['', '-sm', '-md', '-lg', '-xl'];
13+
14+
// TODO(FW-6697): remove `ion-hide classes` test
15+
test('ion-hide classes', () => {
16+
expect(css).toContain('.ion-hide');
17+
18+
const values = ['up', 'down'];
19+
20+
for (const value of values) {
21+
for (const infix of INFIXES) {
22+
expect(css).toContain(`.ion-hide${infix}-${value}`);
23+
}
24+
}
25+
});
26+
27+
test('ion-display classes', () => {
28+
const values = [
29+
'none',
30+
'inline',
31+
'inline-block',
32+
'block',
33+
'flex',
34+
'inline-flex',
35+
'grid',
36+
'inline-grid',
37+
'table',
38+
'table-cell',
39+
'table-row',
40+
];
41+
42+
for (const value of values) {
43+
for (const infix of INFIXES) {
44+
expect(css).toContain(`.ion-display${infix}-${value}`);
45+
}
46+
}
47+
});
48+
});

core/src/css/test/display.test.mjs

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

core/src/css/test/flex-utils.e2e.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { test, expect } from '@playwright/test';
2+
import fs from 'fs';
3+
import path from 'path';
4+
5+
test.describe('flex-utils css utility classes', () => {
6+
let css: string;
7+
8+
test.beforeAll(() => {
9+
css = fs.readFileSync(path.resolve(__dirname, '../../../css/flex-utils.css'), 'utf8');
10+
});
11+
12+
const INFIXES = ['', '-sm', '-md', '-lg', '-xl'];
13+
14+
test('align-content classes', () => {
15+
const values = ['start', 'end', 'center', 'between', 'around', 'stretch'];
16+
for (const value of values) {
17+
for (const infix of INFIXES) {
18+
expect(css).toContain(`.ion-align-content${infix}-${value}`);
19+
}
20+
}
21+
});
22+
23+
test('align-items classes', () => {
24+
const values = ['start', 'center', 'end', 'stretch', 'baseline'];
25+
for (const value of values) {
26+
for (const infix of INFIXES) {
27+
expect(css).toContain(`.ion-align-items${infix}-${value}`);
28+
}
29+
}
30+
});
31+
32+
test('align-self classes', () => {
33+
const values = ['start', 'end', 'center', 'stretch', 'baseline', 'auto'];
34+
for (const value of values) {
35+
for (const infix of INFIXES) {
36+
expect(css).toContain(`.ion-align-self${infix}-${value}`);
37+
}
38+
}
39+
});
40+
41+
test('justify-content classes', () => {
42+
const values = ['start', 'center', 'end', 'around', 'between', 'evenly'];
43+
for (const value of values) {
44+
for (const infix of INFIXES) {
45+
expect(css).toContain(`.ion-justify-content${infix}-${value}`);
46+
}
47+
}
48+
});
49+
50+
test('flex-direction classes', () => {
51+
const values = ['row', 'row-reverse', 'column', 'column-reverse'];
52+
for (const value of values) {
53+
for (const infix of INFIXES) {
54+
expect(css).toContain(`.ion-flex${infix}-${value}`);
55+
}
56+
}
57+
});
58+
59+
test('flex-wrap classes', () => {
60+
const values = ['wrap', 'nowrap', 'wrap-reverse'];
61+
// TODO(FW-6697): remove all `ion-wrap-*` expects
62+
for (const value of values) {
63+
expect(css).toContain(`.ion-${value}`);
64+
}
65+
for (const value of values) {
66+
for (const infix of INFIXES) {
67+
expect(css).toContain(`.ion-flex${infix}-${value}`);
68+
}
69+
}
70+
});
71+
72+
test('flex-fill classes', () => {
73+
const values = ['1', 'auto', 'initial', 'none'];
74+
for (const value of values) {
75+
for (const infix of INFIXES) {
76+
expect(css).toContain(`.ion-flex${infix}-${value}`);
77+
}
78+
}
79+
});
80+
81+
test('flex-grow and flex-shrink classes', () => {
82+
const values = ['grow', 'shrink'];
83+
for (const value of values) {
84+
for (const infix of INFIXES) {
85+
expect(css).toContain(`.ion-flex${infix}-${value}-0`);
86+
expect(css).toContain(`.ion-flex${infix}-${value}-1`);
87+
}
88+
}
89+
});
90+
91+
test('flex-order classes', () => {
92+
for (const infix of INFIXES) {
93+
expect(css).toContain(`.ion-order${infix}-first`);
94+
expect(css).toContain(`.ion-order${infix}-last`);
95+
for (let i = 0; i <= 12; i++) {
96+
expect(css).toContain(`.ion-order${infix}-${i}`);
97+
}
98+
}
99+
});
100+
});

0 commit comments

Comments
 (0)