storybook/code/e2e-tests/addon-backgrounds.spec.ts
Valentin Palkovic becbe97f83 Fix e2e tests
2023-02-01 15:16:33 +01:00

31 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-backgrounds', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});
test('should have a dark background', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('example/button', 'primary');
await sbPage.selectToolbar('[title="Change the background of the preview"]', '#list-item-dark');
await expect(sbPage.getCanvasBodyElement()).toHaveCSS('background-color', 'rgb(51, 51, 51)');
});
test('should apply a grid', async ({ page }) => {
const sbPage = new SbPage(page);
await sbPage.navigateToStory('example/button', 'primary');
await sbPage.selectToolbar('[title="Apply a grid to the preview"]');
await expect(sbPage.getCanvasBodyElement()).toHaveCSS('background-image', /linear-gradient/);
});
});