-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(documentation-v7): add select snapshot test (#1817)
Co-authored-by: Oliver Schürch <[email protected]>
- Loading branch information
1 parent
ee91d41
commit e2f3357
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/documentation-v7/cypress/snapshots/components/select.snapshot.ts
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,6 @@ | ||
describe('Select', () => { | ||
it('default', () => { | ||
cy.visit('./iframe.html?id=snapshots--select'); | ||
cy.percySnapshot('Selects', { widths: [400] }); | ||
}); | ||
}); |
116 changes: 116 additions & 0 deletions
116
packages/documentation-v7/src/stories/components/select/select.snapshot.stories.ts
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,116 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import meta, { Default, FloatingLabel } from './select.stories'; | ||
import { html } from 'lit'; | ||
import { bombArgs } from '../../../utils/bombArgs'; | ||
|
||
export default { | ||
...meta, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Select: Story = { | ||
render: (_args: Args, context: StoryContext) => { | ||
//Arguments for Default Version | ||
const bombArgsGeneratedDefault = [ | ||
...bombArgs({ | ||
label: [ | ||
context.args.label, | ||
'Label - Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor', | ||
], | ||
hint: [''], | ||
}), | ||
...bombArgs({ | ||
hiddenLabel: [true], | ||
hint: ['Hintus textus', context.args.hint], | ||
}), | ||
...bombArgs({ | ||
size: context.argTypes.size.options, | ||
disabled: [false, true], | ||
validation: context.argTypes.validation.options, | ||
}), | ||
] | ||
// remove disabled & validated examples | ||
.filter((args: Args) => !(args.disabled && args.validation !== 'null')); | ||
|
||
//Arguments for Multiple Version | ||
const bombArgsGeneratedMultiple = [ | ||
...bombArgs({ | ||
multiple: [true], | ||
label: [ | ||
context.args.label, | ||
'Label - Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor', | ||
], | ||
hint: [''], | ||
}), | ||
...bombArgs({ | ||
multiple: [true], | ||
hiddenLabel: [true], | ||
hint: ['', 'Hintus textus', context.args.hint], | ||
}), | ||
...bombArgs({ | ||
multiple: [true], | ||
size: context.argTypes.size.options, | ||
disabled: [false, true], | ||
validation: context.argTypes.validation.options, | ||
}), | ||
] | ||
// remove disabled & validated examples | ||
.filter((args: Args) => !(args.disabled && args.validation !== 'null')); | ||
|
||
return html` | ||
<div class="d-flex gap-3 flex-column"> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => | ||
html` | ||
<div class="${bg} d-flex gap-3 flex-column p-3"> | ||
<h2>Default</h2> | ||
${bombArgsGeneratedDefault.map( | ||
(args: Args) => | ||
html` | ||
<div> | ||
${Default.render?.({ ...context.args, ...Default.args, ...args }, context)} | ||
</div> | ||
`, | ||
)} | ||
<h2>Floating Label</h2> | ||
${bombArgsGeneratedDefault.map( | ||
(args: Args) => | ||
html` | ||
<div> | ||
${FloatingLabel.render?.( | ||
{ ...context.args, ...FloatingLabel.args, ...args }, | ||
context, | ||
)} | ||
</div> | ||
`, | ||
)} | ||
<h2>Multiple - Default</h2> | ||
${bombArgsGeneratedMultiple.map( | ||
(args: Args) => | ||
html` | ||
<div> | ||
${Default.render?.({ ...context.args, ...Default.args, ...args }, context)} | ||
</div> | ||
`, | ||
)} | ||
<h2>Multiple - Floating Label</h2> | ||
${bombArgsGeneratedMultiple.map( | ||
(args: Args) => | ||
html` | ||
<div> | ||
${FloatingLabel.render?.( | ||
{ ...context.args, ...FloatingLabel.args, ...args }, | ||
context, | ||
)} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |