mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
/* eslint-disable jest/no-disabled-tests */
|
|
/* eslint-disable no-await-in-loop */
|
|
import { test, expect } from '@playwright/test';
|
|
import process from 'process';
|
|
import { SbPage } from './util';
|
|
|
|
const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';
|
|
const templateName = process.env.STORYBOOK_TEMPLATE_NAME || '';
|
|
|
|
test.describe('addon-docs', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto(storybookUrl);
|
|
await new SbPage(page).waitUntilLoaded();
|
|
});
|
|
|
|
test('should provide source snippet', async ({ page }) => {
|
|
test.skip(
|
|
/^vue3/.test(templateName),
|
|
`Skipping ${templateName}, which does not support dynamic source snippets`
|
|
);
|
|
|
|
const sbPage = new SbPage(page);
|
|
await sbPage.navigateToStory('example-button', 'docs');
|
|
const root = sbPage.previewRoot();
|
|
const toggles = root.locator('.docblock-code-toggle');
|
|
|
|
const toggleCount = await toggles.count();
|
|
for (let i = 0; i < toggleCount; i += 1) {
|
|
const toggle = await toggles.nth(i);
|
|
await toggle.click({ force: true });
|
|
}
|
|
|
|
const codes = root.locator('pre.prismjs');
|
|
const codeCount = await codes.count();
|
|
for (let i = 0; i < codeCount; i += 1) {
|
|
const code = await codes.nth(i);
|
|
const text = await code.innerText();
|
|
await expect(text).not.toMatch(/^\(args\) => /);
|
|
}
|
|
});
|
|
});
|