Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

test(e2e): stabilize entitlement and storage checks

Louis Beaumont65092cb8f0b7
diff --git a/apps/screenpipe-app-tauri/e2e/specs/windows-user-journey.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/windows-user-journey.spec.ts
index e3d0e5cfe..ac830f3d8 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/windows-user-journey.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/windows-user-journey.spec.ts
@@ -858,29 +858,30 @@ describe("Windows user journey", function () {
await waitForBodyText(
(bodyText) =>
- bodyText.includes("local disk, cloud archive, and sync") &&
+ bodyText.includes("local disk usage and storage controls") &&
bodyText.includes("storage policy") &&
bodyText.includes("drop video + audio"),
"Storage settings did not show the local retention controls",
);
+ const retentionModeOff = await $('[data-testid="retention-mode-off"]');
+ await retentionModeOff.waitForExist({ timeout: t(20_000) });
+ const retentionModeMedia = await $('[data-testid="retention-mode-media"]');
+ await retentionModeMedia.waitForExist({ timeout: t(20_000) });
+
// Fresh installs default to media retention, and selecting the already
// active mode early-returns without a dialog. Switch to "off" first
// (idempotent when already off) so the media click below always opens
// the confirmation dialog.
- const offRetentionMode = await $('[data-testid="retention-mode-off"]');
- await offRetentionMode.waitForExist({ timeout: t(20_000) });
- await offRetentionMode.scrollIntoView();
- await offRetentionMode.click();
+ await retentionModeOff.scrollIntoView();
+ await retentionModeOff.click();
await waitForBodyText(
(bodyText) => bodyText.includes("currently: keeping everything forever."),
"Storage settings did not switch retention off before the media preview",
);
- const mediaRetentionMode = await $('[data-testid="retention-mode-media"]');
- await mediaRetentionMode.waitForExist({ timeout: t(20_000) });
- await mediaRetentionMode.scrollIntoView();
- await mediaRetentionMode.click();
+ await retentionModeMedia.scrollIntoView();
+ await retentionModeMedia.click();
const confirmation = await $('[data-testid="retention-mode-confirm-dialog"]');
await confirmation.waitForDisplayed({ timeout: t(20_000) });
diff --git a/apps/screenpipe-app-tauri/e2e/specs/zz-app-entitlement-gate.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/zz-app-entitlement-gate.spec.ts
index 4ee863cfe..8ce991c5a 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/zz-app-entitlement-gate.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/zz-app-entitlement-gate.spec.ts
@@ -168,35 +168,60 @@ describe('App entitlement gate', () => {
});
it('blocks an unentitled session and restores access when cleared', async () => {
- // 1. Force the gate on. With no entitled user, the paywall must show and the
- // app navigation must be hidden.
- await setForceGate(true);
-
- const choosePlan = await $('button*=choose plan');
- await choosePlan.waitForExist({ timeout: t(15000) });
- expect(await choosePlan.isExisting()).toBe(true);
- expect(await (await $('[data-testid="nav-home"]')).isExisting()).toBe(false);
-
- // 2. Clear the flag (back to the bypassed e2e build) and the app returns.
- await setForceGate(false);
-
- const navHome = await $('[data-testid="nav-home"]');
- await navHome.waitForExist({ timeout: t(15000) });
- expect(await navHome.isExisting()).toBe(true);
- expect(await (await $('button*=choose plan')).isExisting()).toBe(false);
+ try {
+ // 1. Force the gate on. With no entitled user, the paywall must show and the
+ // app navigation must be hidden.
+ await setForceGate(true);
+
+ const choosePlan = await $('button*=choose plan');
+ await choosePlan.waitForExist({ timeout: t(15000) });
+ expect(await choosePlan.isExisting()).toBe(true);
+ expect(await (await $('[data-testid="nav-home"]')).isExisting()).toBe(false);
+
+ // 2. Clear the flag (back to the bypassed e2e build) and the app returns.
+ await setForceGate(false);
+
+ const navHome = await $('[data-testid="nav-home"]');
+ await navHome.waitForExist({ timeout: t(15000) });
+ expect(await navHome.isExisting()).toBe(true);
+ expect(await (await $('button*=choose plan')).isExisting()).toBe(false);
+ } finally {
+ await setForceGate(false).catch(() => {});
+ }
});
it('blocks a cloud_subscribed account when the server denies app entitlement', async () => {
- await setForceGate(true);
- await patchFetchForCloudSubscribedAppDeniedUser();
- await emitDeepLink(`screenpipe://login?api_key=${FAKE_DENIED_TOKEN}`);
-
- const title = await $('h1=subscription required');
- await title.waitForExist({ timeout: t(15000) });
- expect(await title.isExisting()).toBe(true);
- expect(await (await $('[data-testid="nav-home"]')).isExisting()).toBe(false);
-
- await restoreFetch();
- await setForceGate(false);
+ try {
+ await setForceGate(true);
+ await patchFetchForCloudSubscribedAppDeniedUser();
+ await emitDeepLink(`screenpipe://login?api_key=${FAKE_DENIED_TOKEN}`);
+
+ await browser.waitUntil(
+ async () => {
+ const state = (await browser.execute((email: string) => {
+ const body = document.body.innerText.toLowerCase();
+ return {
+ hasSubscriptionRequired: body.includes("subscription required"),
+ hasDeniedEmail: body.includes(email.toLowerCase()),
+ hasNavHome: Boolean(document.querySelector('[data-testid="nav-home"]')),
+ };
+ }, FAKE_DENIED_EMAIL)) as {
+ hasSubscriptionRequired: boolean;
+ hasDeniedEmail: boolean;
+ hasNavHome: boolean;
+ };
+
+ return state.hasSubscriptionRequired && state.hasDeniedEmail && !state.hasNavHome;
+ },
+ {
+ timeout: t(15000),
+ interval: 250,
+ timeoutMsg: "Cloud-subscribed but app-denied account did not stay behind the entitlement gate",
+ },
+ );
+ } finally {
+ await restoreFetch().catch(() => {});
+ await setForceGate(false).catch(() => {});
+ }
});
});