Skip to content

Commit

Permalink
test: allow testing of main window
Browse files Browse the repository at this point in the history
Use environment variables to bypass the installer
  • Loading branch information
pixelass committed Feb 22, 2024
1 parent 416d0aa commit 95d7553
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion playwright/index.test.ts → playwright/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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");
});
40 changes: 34 additions & 6 deletions src/client/organisms/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,43 @@ export function Layout({ children }: { children?: ReactNode }) {
>
<TitleBar />
<Stack sx={{ overflow: "hidden" }}>
<SidebarButton href="/dashboard" startDecorator={<DashboardIcon />}>
<SidebarButton
href="/dashboard"
startDecorator={<DashboardIcon />}
data-testid="sidebar-dashboard"
>
{t("labels:dashboard")}
</SidebarButton>
<SidebarButton disabled href="/home" startDecorator={<CollectionsIcon />}>
<SidebarButton
disabled
href="/home"
startDecorator={<CollectionsIcon />}
data-testid="sidebar-datasets"
>
{t("common:datasets")}
</SidebarButton>
<SidebarButton disabled href="/marketplace" startDecorator={<StorefrontIcon />}>
<SidebarButton
disabled
href="/marketplace"
startDecorator={<StorefrontIcon />}
data-testid="sidebar-marketplace"
>
{t("common:marketplace")}
</SidebarButton>
<SidebarButton disabled href="/inventory" startDecorator={<InventoryIcon />}>
<SidebarButton
disabled
href="/inventory"
startDecorator={<InventoryIcon />}
data-testid="sidebar-inventory"
>
{t("common:inventory")}
</SidebarButton>
<SidebarButton disabled href="/training" startDecorator={<FitnessCenterIcon />}>
<SidebarButton
disabled
href="/training"
startDecorator={<FitnessCenterIcon />}
data-testid="sidebar-training"
>
{t("common:training")}
</SidebarButton>
<SidebarButton
Expand All @@ -71,7 +95,11 @@ export function Layout({ children }: { children?: ReactNode }) {
<SidebarButton disabled href="/feedback" startDecorator={<RateReviewIcon />}>
{t("common:feedback")}
</SidebarButton>
<SidebarButton href="/settings" startDecorator={<SettingsIcon />}>
<SidebarButton
href="/settings"
startDecorator={<SettingsIcon />}
data-testid="sidebar-settings"
>
{t("common:settings")}
</SidebarButton>
</Stack>
Expand Down
4 changes: 2 additions & 2 deletions src/electron/future/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 95d7553

Please sign in to comment.