chore(playwright): throw error when using themes config with page.goto

This commit is contained in:
Sean Perkins
2023-12-05 13:41:52 -05:00
parent dc696695ce
commit fefaa8b57c

View File

@@ -1,5 +1,5 @@
import type { Page, TestInfo } from '@playwright/test';
import type { E2EPageOptions, Mode, Direction } from '@utils/test/playwright';
import type { E2EPageOptions, Mode, Direction, Theme } from '@utils/test/playwright';
/**
* This is an extended version of Playwright's
@@ -28,13 +28,22 @@ configs().forEach(({ config, title }) => {
let mode: Mode;
let direction: Direction;
let theme: Theme;
if (options == undefined) {
mode = testInfo.project.metadata.mode;
direction = testInfo.project.metadata.rtl ? 'rtl' : 'ltr';
theme = testInfo.project.metadata.theme;
} else {
mode = options.mode;
direction = options.direction;
theme = options.theme;
}
if (theme !== 'light') {
throw new Error(
'The "themes" config option is only supported when using "page.setContent". Remove the theme from the config and manually set the theme in the test template.'
);
}
const rtlString = direction === 'rtl' ? 'true' : undefined;