Repository navigation
test(title): add color and rtl coverage #31537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+188
−3
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
219e067
test(title): add color and rtl coverage
thetaPC c6a3eae
test(title): use the standard direction comment and test title
thetaPC df0b85c
test(title): render the color test with setContent
thetaPC f4f22ea
test(title): render the basic test with setContent
thetaPC b365e48
test(title): cover the style event on first connect
thetaPC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+20 KB
...c/title.e2e.ts-snapshots/title-basic-ionic-md-rtl-light-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.5 KB
.../title.e2e.ts-snapshots/title-basic-ionic-md-rtl-light-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.6 KB
...c/title.e2e.ts-snapshots/title-basic-ionic-md-rtl-light-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import { configs, test } from '@utils/test/playwright'; | ||
|
|
||
| /** | ||
| * This behavior does not vary across directions. | ||
| */ | ||
| configs({ modes: ['ionic-md', 'md', 'ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| test.describe(title('title: color'), () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title color="primary">Primary</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| `, | ||
| config | ||
| ); | ||
|
|
||
| const header = page.locator('ion-header'); | ||
|
|
||
| await expect(header).toHaveScreenshot(screenshot(`title-color`)); | ||
| }); | ||
| }); | ||
| }); |
Binary file added
BIN
+1.3 KB
...r/title.e2e.ts-snapshots/title-color-ionic-md-ltr-light-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 KB
.../title.e2e.ts-snapshots/title-color-ionic-md-ltr-light-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.56 KB
...r/title.e2e.ts-snapshots/title-color-ionic-md-ltr-light-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.37 KB
...e/test/color/title.e2e.ts-snapshots/title-color-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.66 KB
.../test/color/title.e2e.ts-snapshots/title-color-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.58 KB
...e/test/color/title.e2e.ts-snapshots/title-color-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.42 KB
...le/test/color/title.e2e.ts-snapshots/title-color-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.78 KB
...e/test/color/title.e2e.ts-snapshots/title-color-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.7 KB
...le/test/color/title.e2e.ts-snapshots/title-color-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { newSpecPage } from '@stencil/core/testing'; | ||
|
|
||
| import { ToolbarTitle } from '../title'; | ||
|
|
||
| describe('title: classes', () => { | ||
| it('should add the default size class when size is not set', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title>Title</ion-title>`, | ||
| }); | ||
|
|
||
| expect(page.root!.classList.contains('title-default')).toBe(true); | ||
| }); | ||
|
|
||
| it('should add the size class when size is set', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title size="large">Title</ion-title><ion-title size="small">Title</ion-title>`, | ||
| }); | ||
|
|
||
| const [large, small] = Array.from(page.body.querySelectorAll('ion-title')); | ||
| expect(large.classList.contains('title-large')).toBe(true); | ||
| expect(small.classList.contains('title-small')).toBe(true); | ||
| }); | ||
|
|
||
| it('should add the color classes when color is set', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title color="primary">Title</ion-title>`, | ||
| }); | ||
|
|
||
| expect(page.root!.classList.contains('ion-color')).toBe(true); | ||
| expect(page.root!.classList.contains('ion-color-primary')).toBe(true); | ||
| }); | ||
|
|
||
| it('should add the rtl class when the document is rtl', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title>Title</ion-title>`, | ||
| direction: 'rtl', | ||
| }); | ||
|
|
||
| expect(page.root!.classList.contains('title-rtl')).toBe(true); | ||
| }); | ||
|
|
||
| /** | ||
| * The iOS collapsing header and page transition look up this | ||
| * element and measure it, so it must keep its class. | ||
| */ | ||
| it('should render the inner title element', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title>Title</ion-title>`, | ||
| }); | ||
|
|
||
| expect(page.root!.shadowRoot!.querySelector('.toolbar-title')).not.toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('title: style event', () => { | ||
| it('should emit the size class when it first connects', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: '', | ||
| }); | ||
|
|
||
| const ionStyle = jest.fn(); | ||
| page.body.addEventListener('ionStyle', (ev: Event) => ionStyle((ev as CustomEvent).detail)); | ||
|
|
||
| await page.setContent(`<ion-title size="large">Title</ion-title>`); | ||
|
|
||
| expect(ionStyle).toHaveBeenCalledWith({ 'title-large': true }); | ||
| }); | ||
|
|
||
| it('should emit the size class when size changes', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [ToolbarTitle], | ||
| html: `<ion-title>Title</ion-title>`, | ||
| }); | ||
|
|
||
| const ionStyle = jest.fn(); | ||
| page.root!.addEventListener('ionStyle', (ev: Event) => ionStyle((ev as CustomEvent).detail)); | ||
|
|
||
| page.root!.setAttribute('size', 'large'); | ||
| await page.waitForChanges(); | ||
|
|
||
| expect(ionStyle).toHaveBeenCalledWith({ 'title-large': true }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also cover this event being emit on the first connect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b365e48.