From 6123d2c262d2cc0ea584811daa56c8d5eece514e Mon Sep 17 00:00:00 2001 From: NasgulNexus Date: Fri, 23 Aug 2024 18:23:44 +0200 Subject: [PATCH] test: playwright update change theme and add providers --- playwright/core/expectScreenshotFixture.ts | 18 +++++++----------- playwright/playwright/index.html | 2 +- playwright/playwright/index.tsx | 9 ++++++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/playwright/core/expectScreenshotFixture.ts b/playwright/core/expectScreenshotFixture.ts index 065cb55..73fab3a 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 c9d6eec..a51519b 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 e3a7253..8c35b07 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 ( - + - + + + + );