Skip to content
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

feat(documentation-v7): add select snapshot test #1817

Merged
merged 9 commits into from
Aug 17, 2023
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] });
});
});
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>
`;
},
};