diff --git a/playwright/e2e/launch/launch.spec.ts b/playwright/e2e/launch/launch.spec.ts index 1154ed7..ce6d4e6 100644 --- a/playwright/e2e/launch/launch.spec.ts +++ b/playwright/e2e/launch/launch.spec.ts @@ -6,6 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only Please see LICENSE files in the repository root for full details. */ +import { platform } from "node:os"; + import { test, expect } from "../../element-desktop-test.js"; declare global { @@ -17,6 +19,7 @@ declare global { supportsEventIndexing(): Promise; } | undefined; + createPickleKey(userId: string, deviceId: string): Promise; }; }; } @@ -24,17 +27,32 @@ declare global { test.describe("App launch", () => { test.slow(); - test("should launch and render the welcome view successfully and support seshat", async ({ page }) => { + + test.beforeEach(async ({ page }) => { await page.locator("#matrixchat").waitFor(); await page.locator(".mx_Welcome").waitFor(); + }); + + test("should launch and render the welcome view successfully", async ({ page }) => { await expect(page).toHaveURL("vector://vector/webapp/#/welcome"); await expect(page).toHaveScreenshot(); + }); - const supported = await page.evaluate(async () => { - const indexManager = window.mxPlatformPeg.get()?.getEventIndexingManager(); - return await indexManager?.supportsEventIndexing(); - }); + test("should launch and render the welcome view successfully and support seshat", async ({ page }) => { + await expect( + page.evaluate(async () => { + return window.mxPlatformPeg.get().getEventIndexingManager()?.supportsEventIndexing(); + }), + ).resolves.toBeTruthy(); + }); - expect(supported).toBe(true); + test("should launch and render the welcome view successfully and support keytar", async ({ page }) => { + test.skip(platform() === "linux", "This test does not yet support Linux"); + + await expect( + page.evaluate(async () => { + return await window.mxPlatformPeg.get().createPickleKey("@user:server", "ABCDEF"); + }), + ).resolves.not.toBeNull(); }); }); diff --git a/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png b/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png new file mode 100644 index 0000000..45b47ba Binary files /dev/null and b/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png differ diff --git a/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-and-support-seshat-1-linux.png b/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-and-support-seshat-1-linux.png deleted file mode 100644 index 48ac90b..0000000 Binary files a/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-and-support-seshat-1-linux.png and /dev/null differ diff --git a/src/ipc.ts b/src/ipc.ts index d7c24a6..d1bc144 100644 --- a/src/ipc.ts +++ b/src/ipc.ts @@ -157,7 +157,9 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) { case "createPickleKey": try { const pickleKey = await randomArray(32); - await keytar?.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey); + // We purposefully throw if keytar is not available so the caller can handle it + // rather than sending them a pickle key we did not store on their behalf. + await keytar!.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey); ret = pickleKey; } catch { ret = null; diff --git a/src/keytar.ts b/src/keytar.ts index 9b61fe3..6029778 100644 --- a/src/keytar.ts +++ b/src/keytar.ts @@ -9,7 +9,7 @@ import type * as Keytar from "keytar"; // Hak dependency type let keytar: typeof Keytar | undefined; try { - keytar = await import("keytar"); + ({ default: keytar } = await import("keytar")); } catch (e) { if ((e).code === "MODULE_NOT_FOUND") { console.log("Keytar isn't installed; secure key storage is disabled.");