storybook/code/e2e-tests/json-files.spec.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-02-06 12:44:17 +01:00
/* eslint-disable jest/no-disabled-tests */
2022-10-12 12:54:24 +02:00
import { test, expect } from '@playwright/test';
import process from 'process';
const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';
2023-02-06 12:44:17 +01:00
const templateName = process.env.STORYBOOK_TEMPLATE_NAME;
2022-10-12 12:54:24 +02:00
test.describe('JSON files', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
});
test('should have index.json', async ({ page }) => {
2023-02-06 12:44:17 +01:00
test.skip(
// eslint-disable-next-line jest/valid-title
templateName.includes('ssv6'),
'Only run this test for Sandboxes with StoryStoreV7 enabled'
);
2022-10-12 12:54:24 +02:00
const json = await page.evaluate(() => fetch('/index.json').then((res) => res.json()));
expect(json).toEqual({
2022-10-12 14:35:17 +02:00
v: expect.any(Number),
2022-10-12 12:54:24 +02:00
entries: expect.objectContaining({
'example-button--primary': expect.objectContaining({
2022-10-12 12:54:24 +02:00
id: 'example-button--primary',
importPath: expect.stringContaining('Button.stories'),
2022-10-12 12:54:24 +02:00
name: 'Primary',
title: 'Example/Button',
type: 'story',
}),
2022-10-12 12:54:24 +02:00
}),
});
});
});