Skip to content

Commit d55caf4

Browse files
paazmayapashidlos
authored andcommitted
Separate screens to each test case
Use dark mode if user has set it as preferred
1 parent aecdebd commit d55caf4

File tree

9 files changed

+127
-75
lines changed

9 files changed

+127
-75
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { test } from "fixtures";
2+
import { TEST_PROJECT } from "~client/_test/test.data.helper";
3+
import { mockGetProjects } from "utils/mocks";
4+
5+
// Run tests in this file with dark mode preferred
6+
test.use({ colorScheme: "dark" });
7+
8+
const project = TEST_PROJECT;
9+
10+
test.beforeEach(async ({ page }) => {
11+
await mockGetProjects(page, [project]);
12+
});
13+
14+
test("dark mode login", async ({ page, vrt }) => {
15+
await page.goto("/login");
16+
await vrt.trackPage(page, "Login page - Dark mode");
17+
});
18+
19+
test("dark mode projects", async ({ page, vrt }) => {
20+
await page.goto("/projects");
21+
await vrt.trackPage(page, "Projects list page - Dark mode");
22+
});
23+
24+
test("dark mode profile", async ({ page, vrt }) => {
25+
await page.goto("/profile");
26+
await vrt.trackPage(page, "User profile page - Dark mode");
27+
});
28+
29+
test("dark mode register", async ({ page, vrt }) => {
30+
await page.goto("/register");
31+
await vrt.trackPage(page, "Register page - Dark mode");
32+
});
33+
34+
test("dark mode users", async ({ page, vrt }) => {
35+
await page.goto("/users");
36+
await vrt.trackPage(page, "User list page - Dark mode");
37+
});

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default defineConfig({
1717
actionTimeout: 5000,
1818
navigationTimeout: 5000,
1919
trace: "retry-with-trace",
20+
colorScheme: 'light',
2021
},
2122
retries: process.env.CI ? 1 : 0,
2223
forbidOnly: !!process.env.CI,

src/App.tsx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from "react";
22
import { SnackbarProvider } from "notistack";
3-
import { Box } from "@mui/material";
3+
import { Box, useMediaQuery } from "@mui/material";
4+
import CssBaseline from '@mui/material/CssBaseline';
45
import {
56
ThemeProvider,
67
StyledEngineProvider,
78
createTheme,
89
} from "@mui/material/styles";
9-
import { indigo, purple } from "@mui/material/colors";
10+
import { grey, purple, lightBlue } from "@mui/material/colors";
1011
import Header from "./components/Header";
1112
import {
1213
UserProvider,
@@ -18,29 +19,49 @@ import {
1819
} from "./contexts";
1920
import Router from "./Router";
2021

21-
// https://mui.com/material-ui/customization/color/#2014-material-design-color-palettes
22-
const theme = createTheme({
23-
palette: {
24-
primary: indigo,
25-
secondary: purple,
26-
},
27-
});
28-
2922
function App() {
23+
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
24+
25+
// Update the theme only if the mode changes
26+
// https://mui.com/material-ui/customization/color/#2014-material-design-color-palettes
27+
const theme = React.useMemo(() => createTheme({
28+
palette: {
29+
primary: {
30+
main: lightBlue[600],
31+
light: lightBlue[900],
32+
dark: lightBlue[100],
33+
},
34+
secondary: {
35+
main: purple[500],
36+
},
37+
text: {
38+
primary: prefersDarkMode ? grey[100] : grey[900],
39+
secondary: prefersDarkMode ? grey[200] : grey[800],
40+
},
41+
background: {
42+
default: prefersDarkMode ? grey[800] : grey[200],
43+
paper: prefersDarkMode ? grey[700] : grey[300],
44+
},
45+
mode: prefersDarkMode ? 'dark' : 'light',
46+
},
47+
}
48+
), [prefersDarkMode]);
49+
3050
return (
3151
<StyledEngineProvider injectFirst>
32-
<ThemeProvider theme={theme}>
52+
<ThemeProvider theme={theme}>
53+
<CssBaseline />
3354
<SnackbarProvider maxSnack={3}>
3455
<UserProvider>
3556
<ProjectProvider>
3657
<BuildProvider>
3758
<TestRunProvider>
3859
<SocketProvider>
3960
<HelpProvider>
40-
<Box sx={{ height: "10%" }}>
61+
<Box sx={{ height: "10%", bgcolor: theme.palette.background.paper }}>
4162
<Header />
4263
</Box>
43-
<Box sx={{ height: "90%" }}>
64+
<Box sx={{ height: "90%", bgcolor: theme.palette.background.default, color: theme.palette.text.primary }}>
4465
<Router />
4566
</Box>
4667
</HelpProvider>

src/components/LoginForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const LoginForm = () => {
7878
<Button
7979
type="submit"
8080
color="primary"
81-
variant="outlined"
81+
variant="contained"
8282
data-testid="loginBtn"
8383
>
8484
Login

src/components/RegisterForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ const RegisterForm = () => {
109109
<Button
110110
type="submit"
111111
color="primary"
112-
variant="outlined"
112+
variant="contained"
113113
data-testid="submit"
114114
>
115-
Submit
115+
Register
116116
</Button>
117117
</Grid>
118118
</Grid>

src/components/TestDetailsDialog/DrawArea.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@ import React, { FunctionComponent, useCallback } from "react";
33
import { Stage, Layer, Image } from "react-konva";
44
import Rectangle, { MIN_RECT_SIDE_PIXEL } from "../Rectangle";
55
import { IgnoreArea } from "../../types/ignoreArea";
6-
import { Grid, CircularProgress, type Theme } from "@mui/material";
6+
import { Grid, CircularProgress } from "@mui/material";
77
import { NoImagePlaceholder } from "./NoImageAvailable";
88
import Konva from "konva";
99
import { makeStyles } from "@mui/styles";
1010

11-
const useStyles = makeStyles((theme: Theme) => ({
11+
const useStyles = makeStyles(() => ({
1212
canvasContainer: {
1313
overflow: "auto",
14-
backgroundColor: "white",
15-
},
16-
imageDetailsContainer: {
17-
position: "absolute",
18-
backgroundColor: "white",
19-
zIndex: 1,
20-
padding: theme.spacing(1),
21-
height: "48px",
2214
},
2315
progressContainer: {
2416
minHeight: "300px",

src/components/TestDetailsDialog/ImageDetails.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const useStyles = makeStyles(() => ({
99
container: {
1010
display: "flex",
1111
alignItems: "center",
12-
color: "darkslategrey",
1312
},
1413
branchName: {
1514
cursor: "pointer",
@@ -45,7 +44,7 @@ const ImageDetails: React.FunctionComponent<ImageDetailsProps> = ({
4544
imageName && (
4645
<Typography
4746
variant="caption"
48-
style={{ marginRight: 3, fontSize: "0.7rem" }}
47+
sx={{mr: 0.5, fontSize: "0.7rem"}}
4948
data-testid="image-size"
5049
>
5150
{image ? `(${image?.width} x ${image?.height})` : "Loading..."}
@@ -55,7 +54,7 @@ const ImageDetails: React.FunctionComponent<ImageDetailsProps> = ({
5554
};
5655
return (
5756
<Grid item className={classes.container}>
58-
<Typography variant="overline" style={{ marginRight: 3 }}>
57+
<Typography variant="overline" sx={{mr: 0.5}}>
5958
{type === "Baseline" ? "Baseline" : "Checkpoint"}
6059
</Typography>
6160
{imageSize()}

src/components/TestDetailsDialog/TestDetailsModal.tsx

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
NavigateNext,
3939
NavigateBefore,
4040
} from "@mui/icons-material";
41+
import { useTheme } from '@mui/material/styles';
4142
import { TestRunDetails } from "./TestRunDetails";
4243
import useImage from "use-image";
4344
import { routes } from "../../constants";
@@ -53,50 +54,6 @@ import ImageDetails, { ImageDetailsProps } from "./ImageDetails";
5354
import { calculateScale } from "../../_helpers/scale.helper";
5455
import TestStatusChip from "../TestStatusChip";
5556

56-
const useStyles = makeStyles(() => ({
57-
header: {
58-
position: "relative",
59-
textAlign: "left",
60-
background: "#efefef",
61-
paddingLeft: 8,
62-
paddingBottom: 8,
63-
},
64-
footer: {
65-
background: "#efefef",
66-
},
67-
scaleActions: {
68-
display: "flex",
69-
alignItems: "center",
70-
},
71-
testRunActions: {
72-
display: "flex",
73-
alignItems: "center",
74-
alignContent: "center",
75-
},
76-
testRunName: {
77-
fontWeight: 300,
78-
},
79-
closeIcon: {
80-
position: "absolute",
81-
right: "8px",
82-
},
83-
testRunDetails: {
84-
paddingLeft: 8,
85-
},
86-
drawAreaContainer: {
87-
width: "100%",
88-
height: "100%",
89-
},
90-
drawAreaItem: {
91-
padding: "0 4px",
92-
height: "100%",
93-
},
94-
imageToolbar: {
95-
paddingLeft: 5,
96-
height: 52,
97-
},
98-
}));
99-
10057
const defaultStagePos = {
10158
x: 0,
10259
y: 0,
@@ -121,6 +78,51 @@ const TestDetailsModal: React.FunctionComponent<TestDetailsModalProps> = ({
12178
handleNext,
12279
handleClose,
12380
}) => {
81+
82+
const theme = useTheme();
83+
const useStyles = makeStyles(() => ({
84+
header: {
85+
position: "relative",
86+
textAlign: "left",
87+
background: theme.palette.divider,
88+
paddingLeft: 8,
89+
paddingBottom: 8,
90+
},
91+
footer: {
92+
background: theme.palette.divider,
93+
},
94+
scaleActions: {
95+
display: "flex",
96+
alignItems: "center",
97+
},
98+
testRunActions: {
99+
display: "flex",
100+
alignItems: "center",
101+
alignContent: "center",
102+
},
103+
testRunName: {
104+
fontWeight: 300,
105+
},
106+
closeIcon: {
107+
position: "absolute",
108+
right: "8px",
109+
},
110+
testRunDetails: {
111+
paddingLeft: 8,
112+
},
113+
drawAreaContainer: {
114+
width: "100%",
115+
height: "100%",
116+
},
117+
drawAreaItem: {
118+
padding: "0 4px",
119+
height: "100%",
120+
},
121+
imageToolbar: {
122+
paddingLeft: 5,
123+
height: 52,
124+
},
125+
}));
124126
const classes = useStyles();
125127
const { enqueueSnackbar } = useSnackbar();
126128
const testRunDispatch = useTestRunDispatch();

src/pages/ProfilePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const ProfilePage = () => {
181181
<Button
182182
type="submit"
183183
color="primary"
184-
variant="outlined"
184+
variant="contained"
185185
data-testid="submit"
186186
>
187187
Update
@@ -216,7 +216,7 @@ const ProfilePage = () => {
216216
<Button
217217
type="submit"
218218
color="primary"
219-
variant="outlined"
219+
variant="contained"
220220
data-testid="submit"
221221
>
222222
Update

0 commit comments

Comments
 (0)