2023-02-05 13:41:18 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-02-17 10:33:32 +03:00
|
|
|
|
2023-02-17 05:43:52 +03:00
|
|
|
import { loadPage } from './libs/load-page';
|
2023-02-17 10:33:32 +03:00
|
|
|
import { test } from './libs/playwright';
|
2022-11-10 15:51:06 +03:00
|
|
|
|
2022-11-28 16:17:34 +03:00
|
|
|
loadPage();
|
2022-11-10 15:51:06 +03:00
|
|
|
|
2023-02-05 12:53:14 +03:00
|
|
|
test.describe('Change Theme', () => {
|
2023-03-01 10:40:01 +03:00
|
|
|
// default could be anything according to the system
|
2023-03-08 02:08:33 +03:00
|
|
|
test('default white', async ({ browser }) => {
|
|
|
|
const context = await browser.newContext({
|
|
|
|
colorScheme: 'light',
|
|
|
|
});
|
|
|
|
const page = await context.newPage();
|
|
|
|
await page.goto('http://localhost:8080');
|
|
|
|
// waiting for page loading end
|
|
|
|
await page.waitForSelector('#__next');
|
2022-12-30 16:40:15 +03:00
|
|
|
await page.waitForSelector('html');
|
2022-11-10 15:51:06 +03:00
|
|
|
const root = page.locator('html');
|
|
|
|
const themeMode = await root.evaluate(element =>
|
2023-03-08 02:08:33 +03:00
|
|
|
element.getAttribute('data-theme')
|
2022-11-10 15:51:06 +03:00
|
|
|
);
|
2022-12-30 16:40:15 +03:00
|
|
|
expect(themeMode).toBe('light');
|
2022-11-10 15:51:06 +03:00
|
|
|
|
2023-03-08 02:08:33 +03:00
|
|
|
const lightButton = page.locator('[data-testid=change-theme-dark]');
|
|
|
|
expect(await lightButton.isVisible()).toBe(false);
|
2022-11-10 15:51:06 +03:00
|
|
|
});
|
|
|
|
|
2023-03-09 10:26:07 +03:00
|
|
|
// test('change theme to dark', async ({ page }) => {
|
|
|
|
// const changeThemeContainer = page.locator(
|
|
|
|
// '[data-testid=change-theme-container]'
|
|
|
|
// );
|
|
|
|
// const box = await changeThemeContainer.boundingBox();
|
|
|
|
// expect(box?.x).not.toBeUndefined();
|
|
|
|
//
|
|
|
|
// await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
|
|
|
// await page.waitForTimeout(1000);
|
|
|
|
// const darkButton = page.locator('[data-testid=change-theme-dark]');
|
|
|
|
// const darkButtonPositionTop = await darkButton.evaluate(
|
|
|
|
// element => element.getBoundingClientRect().y
|
|
|
|
// );
|
|
|
|
// expect(darkButtonPositionTop).toBe(box?.y);
|
|
|
|
//
|
|
|
|
// await page.mouse.click((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
|
|
|
// const root = page.locator('html');
|
|
|
|
// const themeMode = await root.evaluate(element =>
|
|
|
|
// element.getAttribute('data-theme')
|
|
|
|
// );
|
|
|
|
// expect(themeMode).toBe('dark');
|
|
|
|
// });
|
2022-11-10 15:51:06 +03:00
|
|
|
});
|