Skip to content

Commit 6b13e13

Browse files
test: remove hardcoded dark palette from tests (#29357)
Issue number: N/A --------- ## What is the current behavior? Dark palette is hardcoded in style tags in tests. ## What is the new behavior? Updated the following tests: - **datetime/basic** - added an import for `dark.class.css` which works with the checkbox to toggle the `ion-palette-dark` class - does not update the e2e test to include dark palette because this was not tested previously - **datetime/color** - added an import for `dark.class.css` which works with the checkbox to toggle the `ion-palette-dark` class - updates the e2e test to use the dark palette - **modal/dark-mode** - added an import for `dark.always.css` which always applies the dark palette - does not update the e2e test to include dark palette because this test needs to be moved but I am not sure where it should go yet - **toggle/enable-on-off-labels** - added an import for `dark.class.css` which works with the checkbox to toggle the `ion-palette-dark` class - updates the e2e test to use the dark palette & splits the color into a separate screenshot test Did not update the following tests: - **item/buttons** - has already been updated to remove the dark palette - **toggle/legacy/enable-on-off-labels** - test was removed in v8 ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information - We could probably remove the checkbox toggles entirely when we add support for the `palette` query param. --------- Co-authored-by: ionitron <[email protected]>
1 parent eb7ba23 commit 6b13e13

File tree

96 files changed

+84
-675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+84
-675
lines changed

core/src/components/datetime/test/basic/index.html

Lines changed: 3 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title>Datetime - Basic</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
77
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
8+
<link href="../../../../../css/palettes/dark.class.css" rel="stylesheet" />
89
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
910
<script src="../../../../../scripts/testing/scripts.js"></script>
1011
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
@@ -49,158 +50,6 @@
4950
ion-datetime {
5051
width: 350px;
5152
}
52-
53-
body.dark {
54-
--ion-color-primary: #428cff;
55-
--ion-color-primary-rgb: 66, 140, 255;
56-
--ion-color-primary-contrast: #ffffff;
57-
--ion-color-primary-contrast-rgb: 255, 255, 255;
58-
--ion-color-primary-shade: #3a7be0;
59-
--ion-color-primary-tint: #5598ff;
60-
61-
--ion-color-secondary: #50c8ff;
62-
--ion-color-secondary-rgb: 80, 200, 255;
63-
--ion-color-secondary-contrast: #ffffff;
64-
--ion-color-secondary-contrast-rgb: 255, 255, 255;
65-
--ion-color-secondary-shade: #46b0e0;
66-
--ion-color-secondary-tint: #62ceff;
67-
68-
--ion-color-tertiary: #6a64ff;
69-
--ion-color-tertiary-rgb: 106, 100, 255;
70-
--ion-color-tertiary-contrast: #ffffff;
71-
--ion-color-tertiary-contrast-rgb: 255, 255, 255;
72-
--ion-color-tertiary-shade: #5d58e0;
73-
--ion-color-tertiary-tint: #7974ff;
74-
75-
--ion-color-success: #2fdf75;
76-
--ion-color-success-rgb: 47, 223, 117;
77-
--ion-color-success-contrast: #000000;
78-
--ion-color-success-contrast-rgb: 0, 0, 0;
79-
--ion-color-success-shade: #29c467;
80-
--ion-color-success-tint: #44e283;
81-
82-
--ion-color-warning: #ffd534;
83-
--ion-color-warning-rgb: 255, 213, 52;
84-
--ion-color-warning-contrast: #000000;
85-
--ion-color-warning-contrast-rgb: 0, 0, 0;
86-
--ion-color-warning-shade: #e0bb2e;
87-
--ion-color-warning-tint: #ffd948;
88-
89-
--ion-color-danger: #ff4961;
90-
--ion-color-danger-rgb: 255, 73, 97;
91-
--ion-color-danger-contrast: #ffffff;
92-
--ion-color-danger-contrast-rgb: 255, 255, 255;
93-
--ion-color-danger-shade: #e04055;
94-
--ion-color-danger-tint: #ff5b71;
95-
96-
--ion-color-dark: #f4f5f8;
97-
--ion-color-dark-rgb: 244, 245, 248;
98-
--ion-color-dark-contrast: #000000;
99-
--ion-color-dark-contrast-rgb: 0, 0, 0;
100-
--ion-color-dark-shade: #d7d8da;
101-
--ion-color-dark-tint: #f5f6f9;
102-
103-
--ion-color-medium: #989aa2;
104-
--ion-color-medium-rgb: 152, 154, 162;
105-
--ion-color-medium-contrast: #000000;
106-
--ion-color-medium-contrast-rgb: 0, 0, 0;
107-
--ion-color-medium-shade: #86888f;
108-
--ion-color-medium-tint: #a2a4ab;
109-
110-
--ion-color-light: #222428;
111-
--ion-color-light-rgb: 34, 36, 40;
112-
--ion-color-light-contrast: #ffffff;
113-
--ion-color-light-contrast-rgb: 255, 255, 255;
114-
--ion-color-light-shade: #1e2023;
115-
--ion-color-light-tint: #383a3e;
116-
}
117-
118-
/*
119-
* iOS Dark Theme
120-
* -------------------------------------------
121-
*/
122-
123-
.ios body.dark {
124-
--ion-background-color: #000000;
125-
--ion-background-color-rgb: 0, 0, 0;
126-
127-
--ion-text-color: #ffffff;
128-
--ion-text-color-rgb: 255, 255, 255;
129-
130-
--ion-color-step-50: #0d0d0d;
131-
--ion-color-step-100: #1a1a1a;
132-
--ion-color-step-150: #262626;
133-
--ion-color-step-200: #333333;
134-
--ion-color-step-250: #404040;
135-
--ion-color-step-300: #4d4d4d;
136-
--ion-color-step-350: #595959;
137-
--ion-color-step-400: #666666;
138-
--ion-color-step-450: #737373;
139-
--ion-color-step-500: #808080;
140-
--ion-color-step-550: #8c8c8c;
141-
--ion-color-step-600: #999999;
142-
--ion-color-step-650: #a6a6a6;
143-
--ion-color-step-700: #b3b3b3;
144-
--ion-color-step-750: #bfbfbf;
145-
--ion-color-step-800: #cccccc;
146-
--ion-color-step-850: #d9d9d9;
147-
--ion-color-step-900: #e6e6e6;
148-
--ion-color-step-950: #f2f2f2;
149-
150-
--ion-item-background: #000000;
151-
152-
--ion-card-background: #1c1c1d;
153-
}
154-
155-
.ios body.dark ion-modal {
156-
--ion-background-color: var(--ion-color-step-100);
157-
--ion-toolbar-background: var(--ion-color-step-150);
158-
--ion-toolbar-border-color: var(--ion-color-step-250);
159-
--ion-item-background: var(--ion-color-step-150);
160-
}
161-
162-
/*
163-
* Material Design Dark Theme
164-
* -------------------------------------------
165-
*/
166-
167-
.md body.dark {
168-
--ion-background-color: #121212;
169-
--ion-background-color-rgb: 18, 18, 18;
170-
171-
--ion-text-color: #ffffff;
172-
--ion-text-color-rgb: 255, 255, 255;
173-
174-
--ion-border-color: #222222;
175-
176-
--ion-color-step-50: #1e1e1e;
177-
--ion-color-step-100: #2a2a2a;
178-
--ion-color-step-150: #363636;
179-
--ion-color-step-200: #414141;
180-
--ion-color-step-250: #4d4d4d;
181-
--ion-color-step-300: #595959;
182-
--ion-color-step-350: #656565;
183-
--ion-color-step-400: #717171;
184-
--ion-color-step-450: #7d7d7d;
185-
--ion-color-step-500: #898989;
186-
--ion-color-step-550: #949494;
187-
--ion-color-step-600: #a0a0a0;
188-
--ion-color-step-650: #acacac;
189-
--ion-color-step-700: #b8b8b8;
190-
--ion-color-step-750: #c4c4c4;
191-
--ion-color-step-800: #d0d0d0;
192-
--ion-color-step-850: #dbdbdb;
193-
--ion-color-step-900: #e7e7e7;
194-
--ion-color-step-950: #f3f3f3;
195-
196-
--ion-item-background: #1e1e1e;
197-
198-
--ion-toolbar-background: #1f1f1f;
199-
200-
--ion-tab-bar-background: #1f1f1f;
201-
202-
--ion-card-background: #1e1e1e;
203-
}
20453
</style>
20554
</head>
20655
<body>
@@ -335,12 +184,9 @@ <h2>formatOptions</h2>
335184

336185
const darkModeCheckbox = document.querySelector('ion-checkbox');
337186
darkModeCheckbox.addEventListener('ionChange', (ev) => {
338-
if (ev.detail.checked) {
339-
document.body.classList.add('dark');
340-
} else {
341-
document.body.classList.remove('dark');
342-
}
187+
document.documentElement.classList.toggle('ion-palette-dark');
343188
});
189+
344190
color.addEventListener('ionChange', (ev) => {
345191
datetime.color = ev.target.value;
346192
buttons.forEach((button) => {

core/src/components/datetime/test/color/datetime.e2e.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ import { configs, test } from '@utils/test/playwright';
44
/**
55
* This behavior does not vary across directions
66
*/
7-
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7+
configs({ directions: ['ltr'], palettes: ['light', 'dark'] }).forEach(({ title, screenshot, config }) => {
88
test.describe(title('datetime: color'), () => {
99
test('should not have visual regressions', async ({ page }) => {
10-
await page.goto('/src/components/datetime/test/color', config);
10+
await page.setContent(
11+
`
12+
<div id="container" style="width: 250px;">
13+
<ion-datetime
14+
color="danger"
15+
value="2022-05-03"
16+
show-default-title="true"
17+
show-default-buttons="true"
18+
></ion-datetime>
19+
</div>
20+
`,
21+
config
22+
);
1123

12-
const datetime = page.locator('#color-datetime');
24+
const container = page.locator('#container');
1325

14-
await expect(datetime).toHaveScreenshot(screenshot(`datetime-color`));
26+
await page.locator('.datetime-ready').waitFor();
1527

16-
await page.evaluate(() => document.body.classList.toggle('dark'));
17-
await page.waitForChanges();
18-
19-
await expect(datetime).toHaveScreenshot(screenshot(`datetime-color-dark`));
28+
await expect(container).toHaveScreenshot(screenshot(`datetime-color`));
2029
});
2130
});
2231
});
-22.7 KB
Binary file not shown.
-27.1 KB
Binary file not shown.
-20.8 KB
Binary file not shown.
-20.6 KB
Binary file not shown.
-23.9 KB
Binary file not shown.
-17.6 KB
Binary file not shown.
-558 Bytes
Loading
-190 Bytes
Loading

0 commit comments

Comments
 (0)