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

38 lines
1.3 KiB
TypeScript

import { expect, test } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';
test.describe('addon-toolbars', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page, expect).waitUntilLoaded();
});
test('should have locale button in the toolbar', async ({ page }) => {
const sbPage = new SbPage(page, expect);
// Click on viewport button and select spanish
await sbPage.navigateToStory('core/toolbars/globals', 'basic');
await sbPage.selectToolbar('[title="Internationalization locale"]', '#list-item-es');
// Check that spanish is selected
await expect(sbPage.previewRoot()).toContainText('Hola');
});
test('locale button should be disabled for story that overrides locale global', async ({
page,
}) => {
const sbPage = new SbPage(page, expect);
// Click on viewport button and select spanish
await sbPage.navigateToStory('core/toolbars/globals', 'override-locale');
await expect(sbPage.previewRoot()).toContainText('안녕하세요');
const button = sbPage.page.getByTitle('Internationalization locale');
await expect(button).toBeDisabled();
});
});