Skip to content

Commit aed941f

Browse files
committed
test(themes): re-enable tests with correct checks
1 parent caf3c2d commit aed941f

File tree

4 files changed

+94
-57
lines changed

4 files changed

+94
-57
lines changed

core/src/themes/functions.color.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,29 @@
186186
// --ion-color-primary-contrast-rgb: 255, 255, 255;
187187
// --ion-color-primary-shade: #0f54da;
188188
// --ion-color-primary-tint: #94a5f4;
189+
// --ion-color-primary-foreground: #105cef;
189190
// --ion-color-primary-subtle: #f2f4fd;
190191
// --ion-color-primary-subtle-rgb: 242, 244, 253;
191192
// --ion-color-primary-subtle-contrast: #105cef;
192193
// --ion-color-primary-subtle-contrast-rgb: 16, 92, 239;
193194
// --ion-color-primary-subtle-shade: #d0d7fa;
194195
// --ion-color-primary-subtle-tint: #e9ecfc;
196+
// --ion-color-primary-foreground: #105cef;
195197
// ...
196198
// --ion-color-dark: #292929;
197199
// --ion-color-dark-rgb: 41, 41, 41;
198200
// --ion-color-dark-contrast: #ffffff;
199201
// --ion-color-dark-contrast-rgb: 255, 255, 255;
200202
// --ion-color-dark-shade: #242424;
201203
// --ion-color-dark-tint: #4e4e4e;
204+
// --ion-color-dark-foreground: #242424;
202205
// --ion-color-dark-subtle: #f5f5f5;
203206
// --ion-color-dark-subtle-rgb: 245, 245, 245;
204207
// --ion-color-dark-subtle-contrast: #292929;
205208
// --ion-color-dark-subtle-contrast-rgb: 41, 41, 41;
206209
// --ion-color-dark-subtle-shade: #e0e0e0;
207210
// --ion-color-dark-subtle-tint: #efefef;
211+
// --ion-color-dark-subtle-foreground: #242424;
208212
// }
209213
// --------------------------------------------------------------------------------------------
210214
@mixin generate-color-variables() {

core/src/themes/ionic/ionic.theme.default.scss

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $ionic-colors: (
3434
contrast-rgb: globals.$ion-text-inverse-rgb,
3535
shade: globals.$ion-bg-primary-base-press,
3636
// TODO this is not a verified value
37-
tint: globals.$ion-semantics-primary-500,
37+
tint: globals.$ion-semantics-primary-600,
3838
foreground: globals.$ion-text-primary,
3939
),
4040
subtle: (
@@ -82,7 +82,7 @@ $ionic-colors: (
8282
contrast-rgb: globals.$ion-text-inverse-rgb,
8383
shade: globals.$ion-bg-success-base-press,
8484
// TODO this is not a verified value
85-
tint: globals.$ion-semantics-success-700,
85+
tint: globals.$ion-semantics-success-800,
8686
foreground: globals.$ion-text-success,
8787
),
8888
subtle: (
@@ -98,24 +98,24 @@ $ionic-colors: (
9898
),
9999
warning: (
100100
bold: (
101-
base: globals.$ion-bg-warning-base-default,
102-
base-rgb: globals.$ion-bg-warning-base-default-rgb,
101+
base: #FFD600,
102+
base-rgb: '255, 214, 0',
103103
contrast: globals.$ion-text-default,
104104
contrast-rgb: globals.$ion-text-default-rgb,
105-
shade: globals.$ion-bg-warning-base-press,
105+
shade: #C3A400,
106106
// TODO this is not a verified value
107107
tint: globals.$ion-primitives-yellow-300,
108-
foreground: globals.$ion-text-warning,
108+
foreground: #966503,
109109
),
110110
subtle: (
111-
base: globals.$ion-bg-warning-subtle-default,
112-
base-rgb: globals.$ion-bg-warning-subtle-default-rgb,
113-
contrast: globals.$ion-text-warning,
114-
contrast-rgb: globals.$ion-text-warning-rgb,
111+
base: #FFF5DB,
112+
base-rgb: '255, 245, 219',
113+
contrast: #966503,
114+
contrast-rgb: '150, 101, 3',
115115
shade: globals.$ion-bg-warning-subtle-press,
116116
// TODO this is not a verified value
117117
tint: globals.$ion-primitives-yellow-100,
118-
foreground: globals.$ion-text-warning,
118+
foreground: #966503,
119119
),
120120
),
121121
danger: (
@@ -126,7 +126,7 @@ $ionic-colors: (
126126
contrast-rgb: globals.$ion-text-inverse-rgb,
127127
shade: globals.$ion-bg-danger-base-press,
128128
// TODO this is not a verified value
129-
tint: globals.$ion-semantics-danger-600,
129+
tint: globals.$ion-semantics-danger-700,
130130
foreground: globals.$ion-text-danger,
131131
),
132132
subtle: (
@@ -146,11 +146,13 @@ $ionic-colors: (
146146
bold: (
147147
base: globals.$ion-bg-neutral-base-default,
148148
base-rgb: globals.$ion-bg-neutral-base-default-rgb,
149-
contrast: globals.$ion-text-inverse,
150-
contrast-rgb: globals.$ion-text-inverse-rgb,
151-
shade: globals.$ion-bg-neutral-base-press,
149+
contrast: globals.$ion-text-default,
150+
contrast-rgb: globals.$ion-text-default-rgb,
151+
// TODO this fails AA testing
152+
// shade: globals.$ion-bg-neutral-base-press,
153+
shade: globals.$ion-primitives-neutral-600,
152154
// TODO this is not a verified value
153-
tint: globals.$ion-primitives-neutral-800,
155+
tint: globals.$ion-primitives-neutral-400,
154156
foreground: globals.$ion-text-default,
155157
),
156158
subtle: (
@@ -174,7 +176,7 @@ $ionic-colors: (
174176
contrast-rgb: globals.$ion-text-inverse-rgb,
175177
shade: globals.$ion-bg-neutral-bold-press,
176178
// TODO this is not a verified value
177-
tint: globals.$ion-primitives-neutral-800,
179+
tint: globals.$ion-primitives-neutral-900,
178180
foreground: globals.$ion-text-default,
179181
),
180182
subtle: (
@@ -198,8 +200,8 @@ $ionic-colors: (
198200
contrast-rgb: globals.$ion-text-inverse-rgb,
199201
// TODO $ion-bg-neutral-boldest-press does not exist
200202
shade: globals.$ion-bg-neutral-bold-press,
201-
tint: globals.$ion-primitives-neutral-800,
202203
// TODO this is not a verified value
204+
tint: globals.$ion-primitives-neutral-1100,
203205
foreground: globals.$ion-text-default,
204206
),
205207
subtle: (
@@ -208,8 +210,8 @@ $ionic-colors: (
208210
contrast: globals.$ion-text-subtle,
209211
contrast-rgb: globals.$ion-text-subtle-rgb,
210212
shade: globals.$ion-bg-neutral-subtle-press,
211-
tint: globals.$ion-primitives-neutral-100,
212213
// TODO this is not a verified value
214+
tint: globals.$ion-primitives-neutral-100,
213215
foreground: globals.$ion-text-default,
214216
),
215217
),

core/src/themes/ionic/test/colors/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@
6464
color: var(--ion-color-contrast);
6565
}
6666

67-
.ion-color-background-16 {
68-
background: rgb(var(--ion-color-base-rgb), 0.16);
69-
color: var(--ion-color-base);
70-
}
71-
7267
.ion-color-subtle {
7368
color: var(--ion-color-subtle-foreground);
7469
}

core/src/themes/ionic/test/colors/theme.e2e.ts

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,72 @@ import { configs, test } from '@utils/test/playwright';
99
const styleTestHelpers = `
1010
<style>
1111
main {
12-
background: var(--ion-color-contrast);
1312
font-size: 14pt;
1413
}
15-
.ion-background {
14+
15+
.ion-color {
16+
color: var(--ion-color-foreground);
17+
}
18+
19+
.ion-color-background {
1620
background: var(--ion-color-base);
21+
color: var(--ion-color-contrast);
1722
}
18-
.ion-background-shade {
23+
24+
.ion-color-background-shade {
1925
background: var(--ion-color-shade);
26+
color: var(--ion-color-contrast);
2027
}
21-
.ion-background-tint {
28+
29+
.ion-color-background-tint {
2230
background: var(--ion-color-tint);
31+
color: var(--ion-color-contrast);
2332
}
24-
.ion-background-opacity-08 {
25-
background: rgba(var(--ion-color-base-rgb), 0.08);
26-
}
27-
.ion-background-opacity-12 {
28-
background: rgba(var(--ion-color-base-rgb), 0.12);
33+
34+
.ion-color-subtle {
35+
color: var(--ion-color-subtle-foreground);
2936
}
30-
.ion-background-opacity-16 {
31-
background: rgba(var(--ion-color-base-rgb), 0.16);
37+
38+
.ion-color-subtle-background {
39+
background: var(--ion-color-subtle-base);
40+
color: var(--ion-color-subtle-contrast);
3241
}
33-
.ion-color {
34-
color: var(--ion-color-base);
42+
43+
.ion-color-subtle-background-shade {
44+
background: var(--ion-color-subtle-shade);
45+
color: var(--ion-color-subtle-contrast);
3546
}
36-
.ion-color-contrast {
37-
color: var(--ion-color-contrast);
47+
48+
.ion-color-subtle-background-tint {
49+
background: var(--ion-color-subtle-tint);
50+
color: var(--ion-color-subtle-contrast);
3851
}
3952
</style>
4053
`;
4154

4255
/**
4356
* All colors should be tested in the following scenarios:
44-
* 1) The base color as the text color against the contrast color as the background color
57+
* 1) The foreground color as the text color against the default background color
4558
* 2) The contrast color as the text color against the base color as the background color
4659
* 3) The contrast color as the text color against the shade color as the background color
4760
* 4) The contrast color as the text color against the tint color as the background color
48-
* 5) The base color as the text color against the base color at 0.08 opacity as the background color
49-
* 6) The base color as the text color against the base color at 0.12 opacity as the background color
50-
* 7) The base color as the text color against the base color at 0.16 opacity as the background color
61+
* 5) The subtle foreground color as the text color against the default background color
62+
* 6) The subtle contrast color as the text color against the subtle base color as the background color
63+
* 7) The subtle contrast color as the text color against the subtle shade color as the background color
64+
* 8) The subtle contrast color as the text color against the subtle tint color as the background color
5165
*/
5266
configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark'] }).forEach(({ config, title }) => {
53-
const colors = ['primary', 'neutral', 'success', 'warning', 'danger', 'light'];
67+
const colors = ['primary', 'secondary', 'success', 'warning', 'danger', 'light', 'medium', 'dark'];
5468

55-
// TODO(ROU-10778): Re-enable this test once the colors have been finalized
56-
test.describe.skip(title('theme'), () => {
69+
test.describe(title('palette colors: bold'), () => {
5770
test.beforeEach(({ skip }) => {
5871
skip.browser('firefox', 'Color contrast ratio is consistent across browsers');
5972
skip.browser('webkit', 'Color contrast ratio is consistent across browsers');
6073
});
6174

6275
for (const color of colors) {
63-
test(`color "${color}" should pass AA guidelines`, async ({ page }) => {
76+
// 1) The foreground color as the text color against the default background color
77+
test(`foreground color "${color}" should pass AA guidelines`, async ({ page }) => {
6478
await page.setContent(
6579
`${styleTestHelpers}
6680
<main class="ion-color-${color}">
@@ -73,11 +87,12 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
7387
expect(results.violations).toEqual([]);
7488
});
7589

90+
// 2) The contrast color as the text color against the base color as the background color
7691
test(`contrast color on "${color}" background should pass AA guidelines`, async ({ page }) => {
7792
await page.setContent(
7893
`${styleTestHelpers}
7994
<main class="ion-color-${color}">
80-
<p class="ion-color-contrast ion-background">Hello World</p>
95+
<p class="ion-color-background">Hello World</p>
8196
</main>`,
8297
config
8398
);
@@ -86,11 +101,27 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
86101
expect(results.violations).toEqual([]);
87102
});
88103

104+
// 3) The contrast color as the text color against the shade color as the background color
89105
test(`contrast color on "${color}" background shade should pass AA guidelines`, async ({ page }) => {
90106
await page.setContent(
91107
`${styleTestHelpers}
92108
<main class="ion-color-${color}">
93-
<p class="ion-color-contrast ion-background-shade">Hello World</p>
109+
<p class="ion-color-background-shade">Hello World</p>
110+
</main>`,
111+
config
112+
);
113+
114+
const results = await new AxeBuilder({ page }).analyze();
115+
expect(results.violations).toEqual([]);
116+
});
117+
118+
// 4) The contrast color as the text color against the tint color as the background color
119+
// TODO(ROU-10778): Re-enable this test once the colors have been finalized
120+
test.skip(`contrast color on "${color}" background tint should pass AA guidelines`, async ({ page }) => {
121+
await page.setContent(
122+
`${styleTestHelpers}
123+
<main class="ion-color-${color}">
124+
<p class="ion-color-background-tint">Hello World</p>
94125
</main>`,
95126
config
96127
);
@@ -99,11 +130,12 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
99130
expect(results.violations).toEqual([]);
100131
});
101132

102-
test(`contrast color on "${color}" background tint should pass AA guidelines`, async ({ page }) => {
133+
// 5) The subtle foreground color as the text color against the default background color
134+
test(`subtle foreground color "${color}" should pass AA guidelines`, async ({ page }) => {
103135
await page.setContent(
104136
`${styleTestHelpers}
105137
<main class="ion-color-${color}">
106-
<p class="ion-color-contrast ion-background-tint">Hello World</p>
138+
<p class="ion-color-subtle">Hello World</p>
107139
</main>`,
108140
config
109141
);
@@ -112,11 +144,12 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
112144
expect(results.violations).toEqual([]);
113145
});
114146

115-
test(`color "${color}" on 0.08 opacity background should pass AA guidelines`, async ({ page }) => {
147+
// 6) The subtle contrast color as the text color against the subtle base color as the background color
148+
test(`subtle contrast color on "${color}" subtle background should pass AA guidelines`, async ({ page }) => {
116149
await page.setContent(
117150
`${styleTestHelpers}
118151
<main class="ion-color-${color}">
119-
<p class="ion-color ion-background-opacity-08">Hello World</p>
152+
<p class="ion-color-subtle-background">Hello World</p>
120153
</main>`,
121154
config
122155
);
@@ -125,11 +158,13 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
125158
expect(results.violations).toEqual([]);
126159
});
127160

128-
test(`color "${color}" on 0.12 opacity background should pass AA guidelines`, async ({ page }) => {
161+
// 7) The subtle contrast color as the text color against the subtle shade color as the background color
162+
// TODO(ROU-10778): Re-enable this test once the colors have been finalized
163+
test.skip(`subtle contrast color on "${color}" subtle background shade should pass AA guidelines`, async ({ page }) => {
129164
await page.setContent(
130165
`${styleTestHelpers}
131166
<main class="ion-color-${color}">
132-
<p class="ion-color ion-background-opacity-12">Hello World</p>
167+
<p class="ion-color-subtle-background-shade">Hello World</p>
133168
</main>`,
134169
config
135170
);
@@ -138,11 +173,12 @@ configs({ modes: ['ionic-md'], directions: ['ltr'], palettes: ['light', 'dark']
138173
expect(results.violations).toEqual([]);
139174
});
140175

141-
test(`color "${color}" on 0.16 opacity background should pass AA guidelines`, async ({ page }) => {
176+
// 8) The subtle contrast color as the text color against the subtle tint color as the background color
177+
test(`subtle contrast color on "${color}" subtle background tint should pass AA guidelines`, async ({ page }) => {
142178
await page.setContent(
143179
`${styleTestHelpers}
144180
<main class="ion-color-${color}">
145-
<p class="ion-color ion-background-opacity-16">Hello World</p>
181+
<p class="ion-color-subtle-background-tint">Hello World</p>
146182
</main>`,
147183
config
148184
);

0 commit comments

Comments
 (0)