Skip to content

Commit

Permalink
Add visual regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alizedebray committed Nov 13, 2024
1 parent 337f623 commit e086ced
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Containers', () => {
it('default', () => {
cy.visit('/iframe.html?id=snapshots--containers');
cy.get('.container', { timeout: 30000 }).should('be.visible');

// takes a screenshot for each breakpoint
cy.percySnapshot('Containers', { widths: [320, 720, 960, 1080, 1440] });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Args, StoryContext, StoryObj } from '@storybook/web-components';
import meta from './containers.stories';
import { html } from 'lit';
import { StoryFn } from '@storybook/web-components';

const { id, ...metaWithoutId } = meta;

export default {
...metaWithoutId,
title: 'Snapshots',
};

type Story = StoryObj;

export const Containers: Story = {
render: (_args: Args, context: StoryContext) => {
return html`${['container', 'container-fluid'].map(containerClass =>
meta.render({ containerClass }, context),
)}`;
},
decorators: [
(story: StoryFn, context: StoryContext) => html`
<div class="container-snapshots">${story(context.args, context)}</div>
`,
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const meta: MetaExtended = {
`,
decorators: [
(story: StoryFn, context: StoryContext) => html`
<div class="containers-example">${story(context.args, context)}</div>
<div class="container-examples">${story(context.args, context)}</div>
`,
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $padding-bg: #B8E2F3;
$content-bg: #A69CE1;
$content-fg: #59718B;

.containers-example {
.container-examples {
background: $margin-bg;

.container,
Expand All @@ -19,3 +19,17 @@ $content-fg: #59718B;
}
}
}

.container-snapshots {
.container {
&::before {
content: "Container";
}
}

.container-fluid {
&::before {
content: "Container fluid";
}
}
}

0 comments on commit e086ced

Please sign in to comment.