Skip to content

Commit

Permalink
Adding e2e to test Svelte documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
j3rem1e committed Sep 9, 2023
1 parent 4f6667d commit 8ed50ff
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
30 changes: 30 additions & 0 deletions code/e2e-tests/framework-svelte.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable jest/no-disabled-tests */
import type { Locator } from '@playwright/test';
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006';
const templateName = process.env.STORYBOOK_TEMPLATE_NAME;

test.describe('Svelte', () => {
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName?.includes('svelte'),
'Only run this test on Svelte'
);

test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});

test('Story have a documentation', async ({ page }) => {
const sbPage = new SbPage(page);

sbPage.navigateToStory('example/button', 'docs');
const root = sbPage.previewRoot();
const argsTable = root.locator('.docblock-argstable');
await expect(argsTable).toContainText('Is this the principal call to action on the page');
});
});
3 changes: 2 additions & 1 deletion code/renderers/svelte/template/cli/js/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
$: text = label?.toString(); // Test parsing of Elvis Operator
</script>
<button
Expand All @@ -32,5 +33,5 @@
{style}
on:click
>
{label}
{text}
</button>
3 changes: 2 additions & 1 deletion code/renderers/svelte/template/cli/ts-3-8/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
$: text = label?.toString(); // Test parsing of Elvis Operator
</script>

<button
Expand All @@ -30,5 +31,5 @@
{style}
on:click
>
{label}
{text}
</button>
3 changes: 2 additions & 1 deletion code/renderers/svelte/template/cli/ts-4-9/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
$: text = label?.toString(); // Test parsing of Elvis Operator
</script>

<button
Expand All @@ -30,5 +31,5 @@
{style}
on:click
>
{label}
{text}
</button>
3 changes: 2 additions & 1 deletion code/renderers/svelte/template/components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
$: text = label?.toString(); // Test parsing of Elvis Operator
const dispatch = createEventDispatcher();
Expand All @@ -41,5 +42,5 @@
{style}
on:click={onClick}
>
{label}
{text}
</button>

0 comments on commit 8ed50ff

Please sign in to comment.