storybook/code/e2e-tests/addon-actions.spec.ts
2023-07-10 11:35:58 +02:00

33 lines
1.0 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('addon-actions', () => {
test.afterEach(async ({ page }) => {
await page.evaluate(() => window.localStorage.clear());
await page.evaluate(() => window.sessionStorage.clear());
});
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});
test('should trigger an action', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('example/button', 'primary');
const root = sbPage.previewRoot();
const button = root.locator('button', { hasText: 'Button' });
await button.click();
await sbPage.viewAddonPanel('Actions');
const logItem = await page.locator('#storybook-panel-root #panel-tab-content', {
hasText: 'click',
});
await expect(logItem).toBeVisible();
});
});