Skip to content

Commit

Permalink
adds screenshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
langz committed Oct 18, 2024
1 parent f8d689b commit 5681111
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,35 @@ export const UploadPrefilledFileList = () => (
</ComponentBox>
)

export const UploadHideFileExtenstionText = () => (
<ComponentBox
data-visual-test="upload-hides-file-extension-text"
scope={{ useMockFiles }}
>
{() => {
const Component = () => {
const { files, setFiles } = Upload.useUpload('my-file-list')

if (files.length) {
console.log('files', files)
}

useMockFiles(setFiles, {})

return (
<Upload
acceptedFileTypes={['jpg', 'png']}
id="my-file-list"
displayFileExtensionText={false}
/>
)
}

return <Component />
}}
</ComponentBox>
)

export const UploadBasic = () => (
<ComponentBox data-visual-test="upload-basic">
<Upload acceptedFileTypes={['jpg', 'png']} id="upload-basic" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
UploadDisabledFileMaxSize,
UploadFileMaxSizeBasedOnFileType,
UploadFileMaxSizeBasedOnFileTypeDisabled,
UploadHideFileExtenstionText,
} from 'Docs/uilib/components/upload/Examples'

## Demos
Expand Down Expand Up @@ -75,3 +76,7 @@ This can also be used to manually implement more complex file max size verificat
<VisibleWhenNotVisualTest>
<UploadDisabledFileMaxSize />
</VisibleWhenNotVisualTest>

<VisibleWhenVisualTest>
<UploadHideFileExtenstionText />
</VisibleWhenVisualTest>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ describe.each(['ui', 'sbanken'])('Upload for %s', (themeName) => {
expect(screenshot).toMatchImageSnapshot()
})

it('have to hide the file extension text', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="upload-hides-file-extension-text"]',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match file max size based on file type table', async () => {
const screenshot = await makeScreenshot({
selector:
Expand Down
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.

0 comments on commit 5681111

Please sign in to comment.