diff --git a/playwright/core/expectScreenshotFixture.ts b/playwright/core/expectScreenshotFixture.ts index 065cb55b..73fab3ae 100644 --- a/playwright/core/expectScreenshotFixture.ts +++ b/playwright/core/expectScreenshotFixture.ts @@ -12,13 +12,7 @@ export const expectScreenshotFixture: PlaywrightFixture screenshotName, ...pageScreenshotOptions } = {}) => { - const captureScreenshot = async (theme: string) => { - const root = page.locator('#root'); - - await root.evaluate((el, theme) => { - el.classList.value = `g-root g-root_theme_${theme}`; - }, theme); - + const captureScreenshot = async () => { return (component || page.locator('.playwright-wrapper-test')).screenshot({ animations: 'disabled', ...pageScreenshotOptions, @@ -27,12 +21,14 @@ export const expectScreenshotFixture: PlaywrightFixture const nameScreenshot = testInfo.titlePath.slice(1).join(' '); - expect(await captureScreenshot('dark')).toMatchSnapshot({ - name: `${screenshotName || nameScreenshot} dark.png`, + expect(await captureScreenshot()).toMatchSnapshot({ + name: `${screenshotName || nameScreenshot} light.png`, }); - expect(await captureScreenshot('light')).toMatchSnapshot({ - name: `${screenshotName || nameScreenshot} light.png`, + await page.emulateMedia({colorScheme: 'dark'}); + + expect(await captureScreenshot()).toMatchSnapshot({ + name: `${screenshotName || nameScreenshot} dark.png`, }); }; diff --git a/playwright/playwright/index.html b/playwright/playwright/index.html index c9d6eecc..a51519b7 100644 --- a/playwright/playwright/index.html +++ b/playwright/playwright/index.html @@ -5,6 +5,6 @@ Test component page - + diff --git a/playwright/playwright/index.tsx b/playwright/playwright/index.tsx index e3a7253d..8c35b071 100644 --- a/playwright/playwright/index.tsx +++ b/playwright/playwright/index.tsx @@ -1,15 +1,18 @@ import React from 'react'; -import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit'; +import {MobileProvider, ThemeProvider, ToasterComponent, ToasterProvider} from '@gravity-ui/uikit'; import {beforeMount} from '@playwright/experimental-ct-react/hooks'; import './index.scss'; beforeMount(async ({App}) => { return ( - + - + + + + );