storybook/code/e2e-tests/preview-web.spec.ts
2022-10-28 23:30:52 +11:00

35 lines
1.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';
test.describe('preview-web', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});
test('should pass over shortcuts, but not from play functions, story', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('lib/store/shortcuts', 'keydown-during-play');
await new Promise((r) => setTimeout(r, 1000));
await expect(sbPage.page.locator('.sidebar-container')).toBeVisible();
await sbPage.previewRoot().locator('button').press('s');
await expect(sbPage.page.locator('.sidebar-container')).not.toBeVisible();
});
test('should pass over shortcuts, but not from play functions, docs', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('lib/store/shortcuts', 'docs');
await expect(sbPage.page.locator('.sidebar-container')).toBeVisible();
await new Promise((r) => setTimeout(r, 1000));
await sbPage.previewRoot().getByText('Submit').press('s');
await expect(sbPage.page.locator('.sidebar-container')).not.toBeVisible();
});
});