Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): rewards and invites survive a real browser reload\n\nrewards-progression-persistence.spec.ts already covers a "simulated restart",\nbut it does that with page.goto('/#/home') and back — a remount inside the same\nJS context, where redux and every in-memory cache survive. A user pressing Cmd-R\ndestroys the context and the page rebuilds from persisted storage plus what it\nre-fetches. Nothing in the suite crossed that line for these two surfaces, and\ntop-level-functional-flows.spec.ts covers the invite copy/redeem interactions\nwithout ever reloading.\n\nVerified state, stated precisely: all three tests have passed, but never all in\none run. Tests 2 and 3 passed together in 6.7s and 6.8s. Test 1 passed at 51.0s\nin an earlier run and has since failed on cold-boot first paint under load.\n\nTwo spec-local timeout raises, both justified by observation rather than\nguessing, and both kept out of the shared playwright.config.ts:\n - describe timeout 150s: the default 60s was enough on an idle machine and\n tipped all three over with "Test timeout of 60000ms exceeded" — no assertion\n failing — once other e2e sessions shared the host.\n - 60s on test 1's first-paint wait: it is first in the file and pays the cold\n boot plus the first rewards fetch.\n\nTest 2 was under-seeded in its first draft: it set rewardsScenario without\nrewardsLastSyncedAt, and the missing progress summary read as a routing failure.\nBoth keys are now set, matching the existing rewards spec.\n

M3gA-Mindc4c0bbcf9754
diff --git a/app/test/playwright/specs/rewards-invites-reload-persistence.spec.ts b/app/test/playwright/specs/rewards-invites-reload-persistence.spec.ts
new file mode 100644
index 0000000000..d86dbaa594
--- /dev/null
+++ b/app/test/playwright/specs/rewards-invites-reload-persistence.spec.ts
@@ -0,0 +1,132 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import {
+ bootAuthenticatedPage,
+ dismissWalkthroughIfPresent,
+ waitForAppReady,
+} from '../helpers/core-rpc';
+
+/**
+ * Rewards and invites survive a real browser reload.
+ *
+ * `rewards-progression-persistence.spec.ts` already covers a "simulated restart"
+ * — but it does that with `page.goto('/#/home')` and back, which is a **remount
+ * inside the same JS context**. Redux, every in-memory cache and the whole
+ * module graph survive it. A user pressing Cmd-R does something categorically
+ * different: the context is destroyed and the page rebuilds from persisted
+ * storage plus whatever it re-fetches.
+ *
+ * That gap is exactly where "works until you refresh" bugs live, and nothing in
+ * the suite crosses it for these two surfaces. `top-level-functional-flows.spec.ts`
+ * covers the invite copy/redeem interactions but never reloads either.
+ *
+ * These specs therefore assert the same user-visible facts on both sides of a
+ * `page.reload()`, and deliberately do not re-test the interactions the existing
+ * specs already own.
+ */
+
+// Two full boots plus a hard reload per test. The default 60s budget is enough
+// on an idle machine but not when several e2e sessions share it — the first
+// green run had a test at 51.0s, and the next run tipped all three over the
+// wall with `Test timeout of 60000ms exceeded` rather than any assertion
+// failing. Raised here rather than in the shared playwright.config.ts.
+test.describe.configure({ timeout: 150_000 });
+
+const MOCK_ADMIN_BASE = `http://127.0.0.1:${process.env.E2E_MOCK_PORT || '18473'}`;
+
+async function mockAdmin(path: string, body: unknown): Promise<void> {
+ await fetch(`${MOCK_ADMIN_BASE}${path}`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(body),
+ }).catch(() => undefined);
+}
+
+const resetMock = () => mockAdmin('/__admin/reset', {});
+const setBehavior = (behavior: Record<string, unknown>) =>
+ mockAdmin('/__admin/behavior', { behavior });
+/** The rewards spec's admin shape is flat key/value rather than a `behavior` object. */
+const setBehaviorKV = (key: string, value: string) =>
+ mockAdmin('/__admin/behavior', { key, value });
+
+async function settle(page: Page): Promise<void> {
+ await waitForAppReady(page);
+ await dismissWalkthroughIfPresent(page);
+}
+
+test.describe('Rewards — progression survives a hard reload', () => {
+ test('the same unlocked summary and usage metrics render after Cmd-R', async ({ page }) => {
+ await resetMock();
+ await setBehaviorKV('rewardsScenario', 'high_usage');
+ await setBehaviorKV('rewardsLastSyncedAt', '2026-04-28T09:00:00.000Z');
+
+ await bootAuthenticatedPage(page, 'pw-rewards-reload', '/rewards?view=main');
+ await settle(page);
+
+ // 60s, not the default: this is the first test in the file, so it pays the
+ // app's cold boot AND the first rewards fetch. Observed passing at 51s on an
+ // idle machine and missing first paint entirely under fleet load.
+ await expect(page.getByText('Your Progress')).toBeVisible({ timeout: 60_000 });
+ await expect(page.getByText('Activity streak')).toBeVisible();
+ await expect(page.getByText('14 days')).toBeVisible();
+ await expect(page.getByText('12,500,000')).toBeVisible();
+
+ // The real thing: destroy the JS context, not just the route.
+ await page.reload();
+ await settle(page);
+
+ await expect(page.getByText('Your Progress')).toBeVisible({ timeout: 20_000 });
+ await expect(page.getByText('Activity streak')).toBeVisible();
+ await expect(page.getByText('14 days')).toBeVisible();
+ await expect(page.getByText('12,500,000')).toBeVisible();
+ });
+
+ test('a reload lands back on the rewards route rather than the default surface', async ({
+ page,
+ }) => {
+ // A deep link that does not survive a refresh is a broken bookmark: the
+ // user reloads to check something and is silently moved elsewhere.
+ await resetMock();
+ await setBehaviorKV('rewardsScenario', 'high_usage');
+ // Both keys, matching rewards-progression-persistence.spec.ts: seeding the
+ // scenario without a sync timestamp leaves the page without a progress
+ // summary to render, and the failure looks like a routing bug.
+ await setBehaviorKV('rewardsLastSyncedAt', '2026-04-28T09:00:00.000Z');
+
+ await bootAuthenticatedPage(page, 'pw-rewards-reload-route', '/rewards?view=main');
+ await settle(page);
+ await expect(page.getByText('Your Progress')).toBeVisible({ timeout: 20_000 });
+
+ await page.reload();
+ await settle(page);
+
+ await expect
+ .poll(async () => page.evaluate(() => window.location.hash), { timeout: 20_000 })
+ .toMatch(/^#\/rewards/);
+ await expect(page.getByText('Your Progress')).toBeVisible();
+ });
+});
+
+test.describe('Invites — the code survives a hard reload', () => {
+ test('the rendered invite code is still there after Cmd-R', async ({ page }) => {
+ const inviteCode = `PW${Date.now().toString().slice(-6)}`;
+ await resetMock();
+ await setBehavior({
+ inviteCodes: JSON.stringify([
+ { _id: 'invite-pw-reload', code: inviteCode, currentUses: 0, maxUses: 1, usageHistory: [] },
+ ]),
+ });
+
+ await bootAuthenticatedPage(page, 'pw-invites-reload', '/invites');
+ await settle(page);
+ await expect(page.getByText(inviteCode)).toBeVisible({ timeout: 20_000 });
+
+ await page.reload();
+ await settle(page);
+
+ await expect
+ .poll(async () => page.evaluate(() => window.location.hash), { timeout: 20_000 })
+ .toMatch(/^#\/invites/);
+ await expect(page.getByText(inviteCode)).toBeVisible({ timeout: 20_000 });
+ });
+});