Skip to content

Commit cb656fc

Browse files
thetaPCbrandyscarneyIonitron
authored
test(title): add color and rtl coverage (#31537)
Issue number: resolves 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. --> No test sets `color` on `ion-title`, and no test screenshots a title in the ionic theme in RTL. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Adds a `color` test page and screenshots in the ionic, md and ios themes. - Runs the `basic` screenshots in RTL too. The ios and md RTL snapshots already existed without a test generating them; they now have one. - Adds spec tests for the classes title renders, the inner `.toolbar-title` element the iOS large title animations measure, and the `ionStyle` event. - Snapshots are generated on the current code, so the Modular Ionic migration stacked on this PR shows any visual change it makes. ## 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/docs/CONTRIBUTING.md#footer for more information. --> ## Other information | Check | Preview | What to look for | |---|---|---| | Color, md theme | [preview](https://ionic-framework-git-fw-6863-tests-ionic1.vercel.app/src/components/title/test/color/index.html?ionic:theme=md&ionic:mode=md) | Each title is drawn in the color it names | | Color, ios theme | [preview](https://ionic-framework-git-fw-6863-tests-ionic1.vercel.app/src/components/title/test/color/index.html?ionic:theme=ios&ionic:mode=ios) | Each title is drawn in the color it names | | Color, ionic theme | [preview](https://ionic-framework-git-fw-6863-tests-ionic1.vercel.app/src/components/title/test/color/index.html?ionic:theme=ionic&ionic:mode=md) | Every title stays dark gray. That's the current ionic behavior, recorded so the migration in #31539 shows its fix | | Basic, ionic theme, RTL | [before](https://ionic-framework-git-fw-6863-base-theme-ionic1.vercel.app/src/components/title/test/basic/index.html?ionic:theme=ionic&ionic:mode=md&rtl=true) and [after](https://ionic-framework-git-fw-6863-tests-ionic1.vercel.app/src/components/title/test/basic/index.html?ionic:theme=ionic&ionic:mode=md&rtl=true) | Looks the same on both. This PR only adds its screenshots | --------- Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com> Co-authored-by: ionitron <hi@ionicframework.com>
1 parent ea22dc8 commit cb656fc

16 files changed

Lines changed: 202 additions & 9 deletions

‎core/src/components/title/test/basic/index.html‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<body>
1818
<ion-app>
19-
<div id="header-wrapper">
19+
<div id="container">
2020
<ion-header>
2121
<ion-toolbar>
2222
<ion-title>Settings</ion-title>
@@ -38,7 +38,7 @@
3838
<ion-back-button default-href="#"></ion-back-button>
3939
</ion-buttons>
4040
<ion-title>Title</ion-title>
41-
<ion-title class="hide-ios" size="small">Subtitle</ion-title>
41+
<ion-title class="hide-when-centered" size="small">Subtitle</ion-title>
4242
<ion-buttons slot="end">
4343
<ion-button><ion-icon slot="icon-only" name="search"></ion-icon></ion-button>
4444
<ion-button><ion-icon slot="icon-only" name="menu"></ion-icon></ion-button>
@@ -80,8 +80,9 @@
8080
</ion-app>
8181

8282
<style>
83-
.ios .hide-ios,
84-
.ionic .hide-ios {
83+
/* ios and ionic center the title, so a second title would overlap it */
84+
.ios .hide-when-centered,
85+
.ionic .hide-when-centered {
8586
display: none;
8687
}
8788
</style>

‎core/src/components/title/test/basic/title.e2e.ts‎

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,85 @@
11
import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

4-
configs({ modes: ['ionic-md', 'md', 'ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
4+
configs({ modes: ['ionic-md', 'md', 'ios'] }).forEach(({ title, screenshot, config }) => {
55
test.describe(title('title: basic'), () => {
66
test('should not have visual regressions', async ({ page }) => {
7-
await page.goto('/src/components/title/test/basic', config);
8-
const wrapper = page.locator('#header-wrapper');
7+
await page.setContent(
8+
`
9+
<style>
10+
/* ios and ionic center the title, so a second title would overlap it */
11+
.ios .hide-when-centered,
12+
.ionic .hide-when-centered {
13+
display: none;
14+
}
15+
</style>
16+
17+
<div id="container">
18+
<ion-header>
19+
<ion-toolbar>
20+
<ion-title>Settings</ion-title>
21+
</ion-toolbar>
22+
</ion-header>
23+
24+
<ion-header>
25+
<ion-toolbar>
26+
<ion-title>Browse</ion-title>
27+
<ion-buttons slot="end">
28+
<ion-button>Cancel</ion-button>
29+
</ion-buttons>
30+
</ion-toolbar>
31+
</ion-header>
32+
33+
<ion-header>
34+
<ion-toolbar class="toolbar-title-default">
35+
<ion-buttons slot="start">
36+
<ion-back-button default-href="#"></ion-back-button>
37+
</ion-buttons>
38+
<ion-title>Title</ion-title>
39+
<ion-title class="hide-when-centered" size="small">Subtitle</ion-title>
40+
<ion-buttons slot="end">
41+
<ion-button><ion-icon slot="icon-only" name="search"></ion-icon></ion-button>
42+
<ion-button><ion-icon slot="icon-only" name="menu"></ion-icon></ion-button>
43+
</ion-buttons>
44+
</ion-toolbar>
45+
</ion-header>
46+
47+
<ion-header>
48+
<ion-toolbar>
49+
<ion-title size="small">Choose a contact to add to Favorites</ion-title>
50+
</ion-toolbar>
51+
<ion-toolbar>
52+
<ion-title>Contacts</ion-title>
53+
<ion-buttons slot="end">
54+
<ion-button>Cancel</ion-button>
55+
</ion-buttons>
56+
</ion-toolbar>
57+
</ion-header>
58+
59+
<ion-header>
60+
<ion-toolbar color="secondary">
61+
<ion-title size="small">
62+
Choose multiple contacts to add to your Favorites so this just goes on and on and on
63+
</ion-title>
64+
</ion-toolbar>
65+
<ion-toolbar color="secondary">
66+
<ion-buttons slot="start">
67+
<ion-button>Groups</ion-button>
68+
</ion-buttons>
69+
<ion-title>Contacts</ion-title>
70+
<ion-buttons slot="end">
71+
<ion-button>Cancel</ion-button>
72+
</ion-buttons>
73+
</ion-toolbar>
74+
</ion-header>
75+
</div>
76+
`,
77+
config
78+
);
79+
80+
const container = page.locator('#container');
981

10-
// only screenshot the headers to avoid unnecessary blank space from ion-content
11-
await expect(wrapper).toHaveScreenshot(screenshot(`title-basic`));
82+
await expect(container).toHaveScreenshot(screenshot(`title-basic`));
1283
});
1384
});
1485
});
20 KB
Loading
28.5 KB
Loading
30.6 KB
Loading
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
/**
5+
* This behavior does not vary across directions.
6+
*/
7+
configs({ modes: ['ionic-md', 'md', 'ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
8+
test.describe(title('title: color'), () => {
9+
test('should not have visual regressions', async ({ page }) => {
10+
await page.setContent(
11+
`
12+
<ion-header>
13+
<ion-toolbar>
14+
<ion-title color="primary">Primary</ion-title>
15+
</ion-toolbar>
16+
<ion-toolbar>
17+
<ion-title color="tertiary">Tertiary</ion-title>
18+
</ion-toolbar>
19+
<ion-toolbar>
20+
<ion-title color="warning">Warning</ion-title>
21+
</ion-toolbar>
22+
</ion-header>
23+
`,
24+
config
25+
);
26+
27+
const header = page.locator('ion-header');
28+
29+
await expect(header).toHaveScreenshot(screenshot(`title-color`));
30+
});
31+
});
32+
});
3.87 KB
Loading
5.01 KB
Loading
4.68 KB
Loading
3.88 KB
Loading

0 commit comments

Comments
 (0)