Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add main window #53

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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