Skip to content

Commit d67fdcc

Browse files
test(item): use themes options in config (#29168)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> In #27134 we fixed a bug for item button colors on dark mode. We added a test for this in dark mode, but it was created before we had the infrastructure to test dark mode within Playwright. As a result, the dark mode theme is hard coded into the test. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - This test has been simplified to only test the things we need to test - It also relies on the built-in dark theme testing instead of hard coding the theme. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: ionitron <hi@ionicframework.com>
1 parent 9ed692c commit d67fdcc

14 files changed

+24
-169
lines changed

core/src/components/item/test/buttons/index.html

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -12,165 +12,6 @@
1212
<script src="../../../../../scripts/testing/scripts.js"></script>
1313
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
1414
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
15-
16-
<style>
17-
/*
18-
* Dark Colors
19-
* -------------------------------------------
20-
*/
21-
22-
body.dark {
23-
--ion-color-primary: #428cff;
24-
--ion-color-primary-rgb: 66, 140, 255;
25-
--ion-color-primary-contrast: #ffffff;
26-
--ion-color-primary-contrast-rgb: 255, 255, 255;
27-
--ion-color-primary-shade: #3a7be0;
28-
--ion-color-primary-tint: #5598ff;
29-
30-
--ion-color-secondary: #50c8ff;
31-
--ion-color-secondary-rgb: 80, 200, 255;
32-
--ion-color-secondary-contrast: #ffffff;
33-
--ion-color-secondary-contrast-rgb: 255, 255, 255;
34-
--ion-color-secondary-shade: #46b0e0;
35-
--ion-color-secondary-tint: #62ceff;
36-
37-
--ion-color-tertiary: #6a64ff;
38-
--ion-color-tertiary-rgb: 106, 100, 255;
39-
--ion-color-tertiary-contrast: #ffffff;
40-
--ion-color-tertiary-contrast-rgb: 255, 255, 255;
41-
--ion-color-tertiary-shade: #5d58e0;
42-
--ion-color-tertiary-tint: #7974ff;
43-
44-
--ion-color-success: #2fdf75;
45-
--ion-color-success-rgb: 47, 223, 117;
46-
--ion-color-success-contrast: #000000;
47-
--ion-color-success-contrast-rgb: 0, 0, 0;
48-
--ion-color-success-shade: #29c467;
49-
--ion-color-success-tint: #44e283;
50-
51-
--ion-color-warning: #ffd534;
52-
--ion-color-warning-rgb: 255, 213, 52;
53-
--ion-color-warning-contrast: #000000;
54-
--ion-color-warning-contrast-rgb: 0, 0, 0;
55-
--ion-color-warning-shade: #e0bb2e;
56-
--ion-color-warning-tint: #ffd948;
57-
58-
--ion-color-danger: #ff4961;
59-
--ion-color-danger-rgb: 255, 73, 97;
60-
--ion-color-danger-contrast: #ffffff;
61-
--ion-color-danger-contrast-rgb: 255, 255, 255;
62-
--ion-color-danger-shade: #e04055;
63-
--ion-color-danger-tint: #ff5b71;
64-
65-
--ion-color-dark: #f4f5f8;
66-
--ion-color-dark-rgb: 244, 245, 248;
67-
--ion-color-dark-contrast: #000000;
68-
--ion-color-dark-contrast-rgb: 0, 0, 0;
69-
--ion-color-dark-shade: #d7d8da;
70-
--ion-color-dark-tint: #f5f6f9;
71-
72-
--ion-color-medium: #989aa2;
73-
--ion-color-medium-rgb: 152, 154, 162;
74-
--ion-color-medium-contrast: #000000;
75-
--ion-color-medium-contrast-rgb: 0, 0, 0;
76-
--ion-color-medium-shade: #86888f;
77-
--ion-color-medium-tint: #a2a4ab;
78-
79-
--ion-color-light: #222428;
80-
--ion-color-light-rgb: 34, 36, 40;
81-
--ion-color-light-contrast: #ffffff;
82-
--ion-color-light-contrast-rgb: 255, 255, 255;
83-
--ion-color-light-shade: #1e2023;
84-
--ion-color-light-tint: #383a3e;
85-
}
86-
87-
/*
88-
* iOS Dark Theme
89-
* -------------------------------------------
90-
*/
91-
92-
.ios body.dark {
93-
--ion-background-color: #000000;
94-
--ion-background-color-rgb: 0, 0, 0;
95-
96-
--ion-text-color: #ffffff;
97-
--ion-text-color-rgb: 255, 255, 255;
98-
99-
--ion-color-step-50: #0d0d0d;
100-
--ion-color-step-100: #1a1a1a;
101-
--ion-color-step-150: #262626;
102-
--ion-color-step-200: #333333;
103-
--ion-color-step-250: #404040;
104-
--ion-color-step-300: #4d4d4d;
105-
--ion-color-step-350: #595959;
106-
--ion-color-step-400: #666666;
107-
--ion-color-step-450: #737373;
108-
--ion-color-step-500: #808080;
109-
--ion-color-step-550: #8c8c8c;
110-
--ion-color-step-600: #999999;
111-
--ion-color-step-650: #a6a6a6;
112-
--ion-color-step-700: #b3b3b3;
113-
--ion-color-step-750: #bfbfbf;
114-
--ion-color-step-800: #cccccc;
115-
--ion-color-step-850: #d9d9d9;
116-
--ion-color-step-900: #e6e6e6;
117-
--ion-color-step-950: #f2f2f2;
118-
119-
--ion-item-background: #000000;
120-
121-
--ion-card-background: #1c1c1d;
122-
}
123-
124-
.ios body.dark ion-modal {
125-
--ion-background-color: var(--ion-color-step-100);
126-
--ion-toolbar-background: var(--ion-color-step-150);
127-
--ion-toolbar-border-color: var(--ion-color-step-250);
128-
--ion-item-background: var(--ion-color-step-150);
129-
}
130-
131-
/*
132-
* Material Design Dark Theme
133-
* -------------------------------------------
134-
*/
135-
136-
.md body.dark {
137-
--ion-background-color: #121212;
138-
--ion-background-color-rgb: 18, 18, 18;
139-
140-
--ion-text-color: #ffffff;
141-
--ion-text-color-rgb: 255, 255, 255;
142-
143-
--ion-border-color: #222222;
144-
145-
--ion-color-step-50: #1e1e1e;
146-
--ion-color-step-100: #2a2a2a;
147-
--ion-color-step-150: #363636;
148-
--ion-color-step-200: #414141;
149-
--ion-color-step-250: #4d4d4d;
150-
--ion-color-step-300: #595959;
151-
--ion-color-step-350: #656565;
152-
--ion-color-step-400: #717171;
153-
--ion-color-step-450: #7d7d7d;
154-
--ion-color-step-500: #898989;
155-
--ion-color-step-550: #949494;
156-
--ion-color-step-600: #a0a0a0;
157-
--ion-color-step-650: #acacac;
158-
--ion-color-step-700: #b8b8b8;
159-
--ion-color-step-750: #c4c4c4;
160-
--ion-color-step-800: #d0d0d0;
161-
--ion-color-step-850: #dbdbdb;
162-
--ion-color-step-900: #e7e7e7;
163-
--ion-color-step-950: #f3f3f3;
164-
165-
--ion-item-background: #1e1e1e;
166-
167-
--ion-toolbar-background: #1f1f1f;
168-
169-
--ion-tab-bar-background: #1f1f1f;
170-
171-
--ion-card-background: #1e1e1e;
172-
}
173-
</style>
17415
</head>
17516

17617
<body>
@@ -347,12 +188,6 @@ <h3>Avatar Start</h3>
347188
</style>
348189

349190
<script>
350-
// TODO FW-4005
351-
const params = new URL(window.location).searchParams;
352-
const dark = params.get('dark');
353-
if (dark !== null) {
354-
document.body.classList.add('dark');
355-
}
356191
const attach = document.getElementById('attachClick');
357192

358193
attach.addEventListener('click', (ev) => {

core/src/components/item/test/buttons/item.e2e.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,34 @@ configs().forEach(({ title, screenshot, config }) => {
1919
});
2020
});
2121

22-
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
22+
configs({ directions: ['ltr'], themes: ['dark'] }).forEach(({ title, screenshot, config }) => {
2323
test.describe(title('item: buttons dark'), () => {
2424
test('should not have visual regressions in dark', async ({ page }) => {
25-
await page.goto(`/src/components/item/test/buttons?dark=true`, config);
25+
test.info().annotations.push({
26+
type: 'issue',
27+
description: 'https://github.com/ionic-team/ionic-framework/issues/27130',
28+
});
2629

27-
await page.setIonViewport();
30+
await page.setContent(
31+
`
32+
<ion-list>
33+
<ion-item button="true">
34+
<ion-label>Button Item</ion-label>
35+
</ion-item>
36+
<ion-item button="true" class="ion-activated">
37+
<ion-label>Activated Button Item</ion-label>
38+
</ion-item>
39+
<ion-item button="true" class="ion-focused">
40+
<ion-label>Focused Button Item</ion-label>
41+
</ion-item>
42+
</ion-list>
43+
`,
44+
config
45+
);
46+
47+
const list = page.locator('ion-list');
2848

29-
await expect(page).toHaveScreenshot(screenshot(`item-buttons-dark-diff`));
49+
await expect(list).toHaveScreenshot(screenshot(`item-buttons-dark-diff`));
3050
});
3151
});
3252
});
-70.8 KB
Binary file not shown.
-82.4 KB
Binary file not shown.
-62.4 KB
Binary file not shown.
7.72 KB
Loading
7.97 KB
Loading
6.85 KB
Loading
-66.4 KB
Binary file not shown.
-78.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)