Skip to content

Commit

Permalink
Fix electron app path (#639)
Browse files Browse the repository at this point in the history
- It doesn't like the trailing path separator.
- Add check in simple smoke test to make sure we catch the load error in
the future by checking the URL that is loaded.
- Add smoke test to exercise `startShell` which the nightly shell test
depends on.
  • Loading branch information
curtisman authored Jan 30, 2025
1 parent 24863ce commit b7aacdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
12 changes: 7 additions & 5 deletions ts/packages/shell/test/simple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ import test, {
} from "@playwright/test";
import {
exitApplication,
getAppPath,
getLaunchArgs,
sendUserRequestAndWaitForResponse,
startShell,
} from "./testHelper";

test("dummy", async () => {
// do nothing
});
import { fileURLToPath } from "node:url";

test("simple", { tag: "@smoke" }, async ({}, testInfo) => {
console.log(`Running test '${testInfo.title}`);
const app: ElectronApplication = await electron.launch({
args: getLaunchArgs(),
});
const mainWindow: Page = await app.firstWindow();
await mainWindow.bringToFront();
expect(fileURLToPath(mainWindow.url())).toContain(getAppPath());
await app.close();
});

test("startShell", { tag: "@smoke" }, async ({}) => {
await startShell();
});

test.skip("why is the sky blue?", { tag: "@smoke" }, async ({}, testInfo) => {
console.log(`Running test '${testInfo.title}`);

Expand Down
13 changes: 7 additions & 6 deletions ts/packages/shell/test/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
// Licensed under the MIT License.

import {
_electron,
_electron as electron,
ElectronApplication,
Locator,
Page,
TestDetails,
} from "@playwright/test";
import { profile } from "node:console";
import fs from "node:fs";
import path from "node:path";
import os from "node:os";
Expand Down Expand Up @@ -136,8 +133,13 @@ export async function exitApplication(page: Page): Promise<void> {
* Gets the shell package path.
* @returns The root path to the project containing the playwright configuration
*/
function getAppPath(): string {
return new URL("..", import.meta.url).toString();
export function getAppPath(): string {
const packagePath = fileURLToPath(new URL("..", import.meta.url));
const appPath = packagePath.endsWith(path.sep)
? packagePath.slice(0, -1)
: packagePath;

return appPath;
}

/**
Expand All @@ -146,7 +148,6 @@ function getAppPath(): string {
*/
export function getLaunchArgs(): string[] {
const appPath = getAppPath();
console.log(appPath);
// Ubuntu 24.04+ needs --no-sandbox, see https://github.com/electron/electron/issues/18265
return os.platform() === "linux" ? [appPath, "--no-sandbox"] : [appPath];
}
Expand Down

0 comments on commit b7aacdd

Please sign in to comment.