Skip to content

Commit

Permalink
Add example and visual test
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker authored and langz committed Dec 13, 2024
1 parent d3f363c commit 02b453d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,29 @@ export const OnFileClick = () => {
</ComponentBox>
)
}

export const DisplayFileAsNonClickable = () => {
return (
<ComponentBox
hideCode
scope={{ createMockFile }}
data-visual-test="upload-value-display-file-as-non-clickable"
>
<Value.Upload
label="Label text"
value={[
{
file: createMockFile('35217511.jpg', 0, 'image/png'),
exists: false,
id: '1',
},
{
file: createMockFile('1501870.jpg', undefined, 'image/png'),
exists: false,
id: '2',
},
]}
/>
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ import * as Examples from './Examples'

<Examples.OnFileClick />

### Display files as non-clickable

When file size is 0 or not given (`new File([], name, { type })`), the file is displayed as a span instead of an anchor. How ever, when `onFileClick` is given, the file will be clickable as a button.

<Examples.DisplayFileAsNonClickable />

<VisibleWhenVisualTest>
<Examples.LabelAndValueOnFileClick />
<Examples.ListVariantsOnFileClick />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ describe('Value.Upload', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match files as non-clickable', async () => {
const screenshot = await makeScreenshot({
selector:
'[data-visual-test="upload-value-display-file-as-non-clickable"]',
})
expect(screenshot).toMatchImageSnapshot()
})
})
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 02b453d

Please sign in to comment.