-
Notifications
You must be signed in to change notification settings - Fork 98
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
test(FilePreview): Add smoke tests/file preview #2026
Open
itwillwork
wants to merge
6
commits into
main
Choose a base branch
from
add-smoke-tests/FilePreview
base: main
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 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2482af6
test(FilePreview): add visual tests
itwillwork 18a650a
test(FilePreview): add smoke tests
itwillwork d86a507
test(FilePreview): update snapshots
itwillwork 15872e2
test(FilePreview): remove debug code
itwillwork 323268c
test(FilePreview): fix ts & refactoring
itwillwork 9b7a1e2
test(FilePreview): fix ts & refactoring
itwillwork 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
Binary file added
BIN
+41.6 KB
...ual.test.tsx-snapshots/FilePreview-render-story-Collage-dark-chromium-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
+40.1 KB
...al.test.tsx-snapshots/FilePreview-render-story-Collage-light-chromium-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
+4.51 KB
...ual.test.tsx-snapshots/FilePreview-render-story-Default-dark-chromium-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
+4.37 KB
...al.test.tsx-snapshots/FilePreview-render-story-Default-light-chromium-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
+15 KB
...napshots/FilePreview-smoke-actions-show-action-tooltip-light-chromium-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
+10.1 KB
...tsx-snapshots/FilePreview-smoke-actions-show-actionsdf-light-chromium-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 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
48 changes: 48 additions & 0 deletions
48
src/components/FilePreview/__tests__/FilePreview.visual.test.tsx
This file contains 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,48 @@ | ||
import {expect} from '@playwright/experimental-ct-react'; | ||
|
||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {FilePreviewWithAllActions} from './helpers'; | ||
import {FilePreviewStories} from './helpersPlaywright'; | ||
|
||
test.describe('FilePreview', {tag: '@FilePreview'}, () => { | ||
test(`render story: <Default>`, async ({mount, expectScreenshot}) => { | ||
await mount(<FilePreviewStories.Default />); | ||
|
||
await expectScreenshot({}); | ||
}); | ||
|
||
test(`render story: <Collage>`, async ({mount, page, expectScreenshot}) => { | ||
await mount(<FilePreviewStories.Collage />); | ||
|
||
// wait download image | ||
await page.waitForLoadState('networkidle'); | ||
|
||
await expectScreenshot({}); | ||
}); | ||
|
||
smokeTest('actions', async ({mount, page, expectScreenshot}) => { | ||
await mount( | ||
<div style={{padding: 50}}> | ||
<FilePreviewWithAllActions /> | ||
</div>, | ||
); | ||
|
||
await page.getByTestId('file-preview').hover(); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
nameSuffix: 'show actionsdf', | ||
}); | ||
|
||
await page.locator('button[aria-label="Close"]').hover(); | ||
await expect(page.getByTestId('action-1-tooltip')).toBeVisible({ | ||
timeout: 3000, | ||
}); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
nameSuffix: 'show action tooltip', | ||
}); | ||
}); | ||
}); |
This file contains 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,57 @@ | ||
import {Link, Xmark} from '@gravity-ui/icons'; | ||
|
||
import {FilePreview} from '../FilePreview'; | ||
import type {FilePreviewProps} from '../FilePreview'; | ||
|
||
export const FilePreviewWithAllActions = ( | ||
props: Partial<Omit<FilePreviewProps, 'actions' | 'onClose'>>, | ||
) => { | ||
return ( | ||
<FilePreview | ||
qa="file-preview" | ||
file={{name: 'File', type: 'text/docs'} as File} | ||
onClick={() => { | ||
// nothing | ||
}} | ||
actions={[ | ||
{ | ||
icon: null, | ||
title: 'Without icon action', | ||
onClick: () => { | ||
// nothing | ||
}, | ||
}, | ||
{ | ||
icon: <Link width={14} height={14} />, | ||
disabled: true, | ||
title: 'Disabled action', | ||
onClick: () => { | ||
// nothing | ||
}, | ||
}, | ||
{ | ||
icon: <Link width={14} height={14} />, | ||
href: '#', | ||
title: 'Link action', | ||
onClick: () => { | ||
// nothing | ||
}, | ||
}, | ||
{ | ||
icon: <Xmark width={14} height={14} />, | ||
title: 'Close', | ||
onClick: () => { | ||
// nothing | ||
}, | ||
extraProps: { | ||
qa: 'action-1-trigger', | ||
}, | ||
tooltipExtraProps: { | ||
qa: 'action-1-tooltip', | ||
}, | ||
}, | ||
]} | ||
{...props} | ||
/> | ||
); | ||
}; |
This file contains 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,5 @@ | ||
import {composeStories} from '@storybook/react'; | ||
|
||
import * as DefaultFilePreviewStories from '../__stories__/FilePreview.stories'; | ||
|
||
export const FilePreviewStories = composeStories(DefaultFilePreviewStories); |
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.
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.
It's worth waiting for me to fix the icons(