From 159bdb8b23439754ba2c9106a85b7fc5ada72e00 Mon Sep 17 00:00:00 2001
From: Gregor Adams <1148334+pixelass@users.noreply.github.com>
Date: Thu, 22 Feb 2024 13:38:11 +0100
Subject: [PATCH] test: add main window (#53)
## Motivation
Use environment variables to bypass the installer
It allow us to control the target screens and also offers an approach to
handling further barriers in the app.
## Issues closed
---
.../{index.test.ts => installer.test.ts} | 2 +-
...e-painting.test.ts => main-window.test.ts} | 26 ++++++++++--
src/client/organisms/layout/index.tsx | 40 ++++++++++++++++---
src/electron/future/main.ts | 4 +-
4 files changed, 60 insertions(+), 12 deletions(-)
rename playwright/{index.test.ts => installer.test.ts} (95%)
rename playwright/{live-painting.test.ts => main-window.test.ts} (51%)
diff --git a/playwright/index.test.ts b/playwright/installer.test.ts
similarity index 95%
rename from playwright/index.test.ts
rename to playwright/installer.test.ts
index 55adf008a..0facb6a1e 100644
--- a/playwright/index.test.ts
+++ b/playwright/installer.test.ts
@@ -19,7 +19,7 @@ test.afterAll(async () => {
await electronApp.close();
});
-test("Renders the first page", async () => {
+test("Renders the installer page", async () => {
page = await electronApp.firstWindow();
const title = await page.title();
expect(title).toBe("Blibla");
diff --git a/playwright/live-painting.test.ts b/playwright/main-window.test.ts
similarity index 51%
rename from playwright/live-painting.test.ts
rename to playwright/main-window.test.ts
index 25d11fc74..28f7b7c21 100644
--- a/playwright/live-painting.test.ts
+++ b/playwright/main-window.test.ts
@@ -1,12 +1,20 @@
+import process from "process";
+
import type { ElectronApplication, Page } from "@playwright/test";
import { test, expect } from "@playwright/test";
import { _electron as electron } from "playwright";
-
let electronApp: ElectronApplication;
let page: Page;
test.beforeAll(async () => {
- electronApp = await electron.launch({ args: ["."] });
+ electronApp = await electron.launch({
+ args: ["."],
+ env: {
+ ...process.env,
+ TEST_VERSION: "upToDate",
+ TEST_APP_STATUS: "DONE",
+ },
+ });
const isPackaged = await electronApp.evaluate(async ({ app }) => app.isPackaged);
expect(isPackaged).toBe(false);
@@ -16,9 +24,21 @@ test.afterAll(async () => {
await electronApp.close();
});
-test.skip("Open Live Painting", async () => {
+test("Renders the dashboard page", async () => {
+ page = await electronApp.firstWindow();
+ await expect(page.url()).toContain("dashboard");
+});
+
+test("Open Live Painting", async () => {
page = await electronApp.firstWindow();
await page.getByTestId("sidebar-live-painting").click();
await expect(page.url()).toContain("live-painting");
});
+
+test("Open Settings", async () => {
+ page = await electronApp.firstWindow();
+
+ await page.getByTestId("sidebar-settings").click();
+ await expect(page.url()).toContain("settings");
+});
diff --git a/src/client/organisms/layout/index.tsx b/src/client/organisms/layout/index.tsx
index ac2920ba9..80e022223 100644
--- a/src/client/organisms/layout/index.tsx
+++ b/src/client/organisms/layout/index.tsx
@@ -35,19 +35,43 @@ export function Layout({ children }: { children?: ReactNode }) {
>
- }>
+ }
+ data-testid="sidebar-dashboard"
+ >
{t("labels:dashboard")}
- }>
+ }
+ data-testid="sidebar-datasets"
+ >
{t("common:datasets")}
- }>
+ }
+ data-testid="sidebar-marketplace"
+ >
{t("common:marketplace")}
- }>
+ }
+ data-testid="sidebar-inventory"
+ >
{t("common:inventory")}
- }>
+ }
+ data-testid="sidebar-training"
+ >
{t("common:training")}
}>
{t("common:feedback")}
- }>
+ }
+ data-testid="sidebar-settings"
+ >
{t("common:settings")}
diff --git a/src/electron/future/main.ts b/src/electron/future/main.ts
index 1697ef880..cc2be3db7 100644
--- a/src/electron/future/main.ts
+++ b/src/electron/future/main.ts
@@ -92,8 +92,8 @@ export async function main() {
const lastAppVersion = appSettingsStore.get("version");
const appStatus = appSettingsStore.get("status");
- const isUpToDate = version === lastAppVersion;
- const isReady = appStatus === DownloadState.DONE;
+ const isUpToDate = version === lastAppVersion || process.env.TEST_VERSION === "upToDate";
+ const isReady = appStatus === DownloadState.DONE || process.env.TEST_APP_STATUS === "DONE";
// Remove the default application menu in production
if (isProduction) {