-
Notifications
You must be signed in to change notification settings - Fork 29
test(TextEllipsis): add screenshot tests #2304
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
Bracciata
wants to merge
4
commits into
develop
Choose a base branch
from
feat/add-screenshot-tests-for-text-ellipsis
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import { test, expect } from '@playwright/experimental-ct-react17'; | ||
| import { setTheme } from './helpers/playwright'; | ||
|
|
||
| test.beforeEach(({ page }) => { | ||
| setTheme(page, 'light'); | ||
| test.beforeEach(async ({ page }) => { | ||
| await setTheme(page, 'light'); | ||
| }); | ||
|
|
||
| export { test, expect }; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions
109
packages/react/src/components/TextEllipsis/screenshots.e2e.tsx
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,109 @@ | ||
| import React from 'react'; | ||
| import { test, expect } from '../../../../../e2e/screenshots'; | ||
| import { setTheme } from '../../../../../e2e/helpers/playwright'; | ||
| import { TextEllipsis } from '../../../'; | ||
|
|
||
| const overflowText = | ||
| 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; | ||
|
|
||
| test('should have screenshot for TextEllipsis', async ({ mount, page }) => { | ||
| const component = await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis>{overflowText}</TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| await expect(component).toHaveScreenshot('text-ellipsis'); | ||
| await setTheme(page, 'dark'); | ||
| await expect(component).toHaveScreenshot('dark--text-ellipsis'); | ||
| }); | ||
|
Bracciata marked this conversation as resolved.
|
||
|
|
||
| test('should have screenshot for TextEllipsis tooltip on hover', async ({ | ||
| mount, | ||
| page | ||
| }) => { | ||
| await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis>{overflowText}</TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| const ellipsis = page.getByRole('button'); | ||
| await ellipsis.waitFor(); | ||
| await ellipsis.hover(); | ||
| await expect(page.locator('.Tooltip')).toBeVisible(); | ||
|
|
||
| await expect(page).toHaveScreenshot('text-ellipsis-tooltip'); | ||
| await setTheme(page, 'dark'); | ||
| await expect(page).toHaveScreenshot('dark--text-ellipsis-tooltip'); | ||
| }); | ||
|
|
||
| test('should have screenshot for TextEllipsis[maxLines=2]', async ({ | ||
| mount, | ||
| page | ||
| }) => { | ||
| const component = await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis maxLines={2}>{overflowText}</TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| await expect(component).toHaveScreenshot('text-ellipsis[maxLines=2]'); | ||
| await setTheme(page, 'dark'); | ||
| await expect(component).toHaveScreenshot('dark--text-ellipsis[maxLines=2]'); | ||
| }); | ||
|
|
||
| test('should have screenshot for TextEllipsis[hideTooltip]', async ({ | ||
| mount, | ||
| page | ||
| }) => { | ||
| await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis hideTooltip>{overflowText}</TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| const ellipsis = page.locator('.TextEllipsis'); | ||
| await ellipsis.hover(); | ||
| await expect(page.locator('.Tooltip')).toHaveCount(0); | ||
|
|
||
| await expect(page).toHaveScreenshot('text-ellipsis[hideTooltip]'); | ||
| await setTheme(page, 'dark'); | ||
| await expect(page).toHaveScreenshot('dark--text-ellipsis[hideTooltip]'); | ||
| }); | ||
|
|
||
| test('should have screenshot for TextEllipsis[hideTooltip][maxLines=2]', async ({ | ||
|
Bracciata marked this conversation as resolved.
|
||
| mount, | ||
| page | ||
| }) => { | ||
| const component = await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis hideTooltip maxLines={2}> | ||
| {overflowText} | ||
| </TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| await expect(component).toHaveScreenshot( | ||
| 'text-ellipsis[hideTooltip][maxLines=2]' | ||
| ); | ||
| await setTheme(page, 'dark'); | ||
| await expect(component).toHaveScreenshot( | ||
| 'dark--text-ellipsis[hideTooltip][maxLines=2]' | ||
| ); | ||
| }); | ||
|
|
||
| test('should have screenshot for TextEllipsis without overflow', async ({ | ||
| mount, | ||
| page | ||
| }) => { | ||
| const component = await mount( | ||
| <div style={{ width: '200px' }}> | ||
| <TextEllipsis>Short text</TextEllipsis> | ||
| </div> | ||
| ); | ||
|
|
||
| await expect(component).toHaveScreenshot('text-ellipsis-no-overflow'); | ||
| await setTheme(page, 'dark'); | ||
| await expect(component).toHaveScreenshot('dark--text-ellipsis-no-overflow'); | ||
| }); | ||
|
Bracciata marked this conversation as resolved.
|
||
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.