mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-28 10:33:02 -05:00
[e2e stability] Check for data-theme before taking a screenshot (#3523)
* Check for data-theme before taking a screenshot * Release notes * Update playwright.config.js * Fix error * Updates VRT * VRT * Revert VRT --------- Co-authored-by: youngcw <calebyoung94@gmail.com>
This commit is contained in:
committed by
GitHub
parent
545c8d5456
commit
3b97d1eec7
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB |
@@ -17,8 +17,17 @@ expect.extend({
|
||||
maxDiffPixels: 5,
|
||||
};
|
||||
|
||||
// Get the data-theme attribute from page.
|
||||
// If there is a page() function, it means that the locator
|
||||
// is not a page object but a locator object.
|
||||
const dataThemeLocator =
|
||||
typeof locator.page === 'function'
|
||||
? locator.page().locator('[data-theme]')
|
||||
: locator.locator('[data-theme]');
|
||||
|
||||
// Check lightmode
|
||||
await locator.evaluate(() => window.Actual.setTheme('auto'));
|
||||
await expect(dataThemeLocator).toHaveAttribute('data-theme', 'auto');
|
||||
const lightmode = await expect(locator).toHaveScreenshot(config);
|
||||
|
||||
if (lightmode && !lightmode.pass) {
|
||||
@@ -27,6 +36,7 @@ expect.extend({
|
||||
|
||||
// Switch to darkmode and check
|
||||
await locator.evaluate(() => window.Actual.setTheme('dark'));
|
||||
await expect(dataThemeLocator).toHaveAttribute('data-theme', 'dark');
|
||||
const darkmode = await expect(locator).toHaveScreenshot(config);
|
||||
|
||||
// Assert on
|
||||
@@ -36,6 +46,7 @@ expect.extend({
|
||||
|
||||
// Switch to midnight theme and check
|
||||
await locator.evaluate(() => window.Actual.setTheme('midnight'));
|
||||
await expect(dataThemeLocator).toHaveAttribute('data-theme', 'midnight');
|
||||
const midnightMode = await expect(locator).toHaveScreenshot(config);
|
||||
|
||||
// Assert on
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
import { useMetadataPref } from '../hooks/useMetadataPref';
|
||||
import { installPolyfills } from '../polyfills';
|
||||
import { ResponsiveProvider } from '../ResponsiveProvider';
|
||||
import { styles, hasHiddenScrollbars, ThemeStyle } from '../style';
|
||||
import { styles, hasHiddenScrollbars, ThemeStyle, useTheme } from '../style';
|
||||
import { ExposeNavigate } from '../util/router-tools';
|
||||
|
||||
import { AppBackground } from './AppBackground';
|
||||
@@ -155,6 +155,8 @@ export function App() {
|
||||
};
|
||||
}, [dispatch]);
|
||||
|
||||
const [theme] = useTheme();
|
||||
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<ExposeNavigate />
|
||||
@@ -166,6 +168,7 @@ export function App() {
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<ScrollProvider>
|
||||
<View
|
||||
data-theme={theme}
|
||||
style={{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
|
||||
6
upcoming-release-notes/3523.md
Normal file
6
upcoming-release-notes/3523.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [joel-jeremy]
|
||||
---
|
||||
|
||||
e2e stability: wait for data-theme to switch before taking a screenshot
|
||||
Reference in New Issue
Block a user