storybook/code/e2e-tests/addon-actions.spec.ts

28 lines
861 B
TypeScript
Raw Normal View History

2022-08-14 17:48:13 +08:00
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.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
2022-08-14 17:48:13 +08:00
});
test('should trigger an action', async ({ page }) => {
const sbPage = new SbPage(page);
2022-10-27 22:53:41 +11:00
await sbPage.navigateToStory('example/button', 'primary');
2022-08-14 17:48:13 +08:00
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: 'onClick',
});
await expect(logItem).toBeVisible();
});
});