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

31 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-08-14 17:48:35 +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-backgrounds', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
2022-08-14 17:48:35 +08:00
});
test('should have a dark background', async ({ page }) => {
const sbPage = new SbPage(page);
2022-10-27 22:53:41 +11:00
await sbPage.navigateToStory('example/button', 'primary');
2023-01-26 13:47:46 +01:00
await sbPage.selectToolbar('[title="Change the background of the preview"]', '#list-item-dark');
2022-08-14 17:48:35 +08:00
await expect(sbPage.getCanvasBodyElement()).toHaveCSS('background-color', 'rgb(51, 51, 51)');
});
test('should apply a grid', 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:35 +08:00
await sbPage.selectToolbar('[title="Apply a grid to the preview"]');
await expect(sbPage.getCanvasBodyElement()).toHaveCSS('background-image', /linear-gradient/);
});
});