-
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): adds visual regression tests for range input (#1852
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/documentation/cypress/snapshots/components/range.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('Range', () => { | ||
it('default', () => { | ||
cy.visit('./iframe.html?id=snapshots--range'); | ||
cy.percySnapshot('Ranges', { widths: [400] }); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
packages/documentation/src/stories/components/range/range.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,56 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import meta from './range.stories'; | ||
import { html } from 'lit'; | ||
import { bombArgs } from '../../../utils/bombArgs'; | ||
|
||
export default { | ||
...meta, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Range: Story = { | ||
render: (_args: Args, context: StoryContext) => { | ||
return html` | ||
<div class="d-flex flex-wrap align-items-start gap-regular"> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div | ||
class="${bg} d-flex flex-wrap align-items-start flex-column gap-regular p-regular" | ||
> | ||
${[ | ||
...bombArgs({ | ||
label: [ | ||
'Label', | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero mollitia magnam quo quam saepe. Aliquam tempore non deleniti culpa reprehenderit.', | ||
], | ||
disabled: [false, true], | ||
validation: context.argTypes.validation.options, | ||
showValue: context.argTypes.showValue.options, | ||
}) | ||
//makes sure only one of those 3 Properties has a non default value | ||
.filter( | ||
(args: Args) => | ||
(!args.disabled || args.validation === 'null') && | ||
(!args.disabled || args.showValue === 'none') && | ||
(args.validation === 'null' || args.showValue === 'none'), | ||
) | ||
// makes sure only one label with long text | ||
.filter( | ||
(args: Args) => | ||
(args.validation === 'null' && args.showValue === 'none' && !args.disabled) || | ||
args.label !== | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero mollitia magnam quo quam saepe. Aliquam tempore non deleniti culpa reprehenderit.', | ||
), | ||
...bombArgs({ | ||
hiddenLabel: [true], | ||
}), | ||
].map((args: Args) => meta.render?.({ ...context.args, ...args }, context))} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |