Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

test(lenses): pin Go caches in the e2e, and cover tab history fixes

Claudeb04de5818525
diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/playwright.config.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/playwright.config.ts
index e9f261e7..fdbc4825 100644
--- a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/playwright.config.ts
+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/playwright.config.ts
@@ -1,3 +1,4 @@
+import { execFileSync } from 'node:child_process';
import { mkdtempSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
@@ -9,6 +10,12 @@ import { defineConfig } from '@playwright/test';
* baseline rules run, and no opt-in trace history exists.
*/
const port = Number(process.env.LENS_E2E_PORT || 8798);
+// HOME moves to a fresh directory below, and Go keeps its module cache, build cache and
+// downloaded toolchains under HOME unless told otherwise. Pin them to wherever they are now, or
+// every run downloads the toolchain and every module again into a directory nobody cleans up.
+const goEnv = Object.fromEntries(
+ ['GOPATH', 'GOMODCACHE', 'GOCACHE'].map((key) => [key, execFileSync('go', ['env', key]).toString().trim()]),
+);
const lenses = ['probe', 'navigator', 'thrower', 'staller', 'tall']
.map((id) => `--lens fixtures/${id}.lens.html`)
.join(' ');
@@ -31,6 +38,6 @@ export default defineConfig({
url: `http://127.0.0.1:${port}/api/lenses`,
timeout: 180_000,
reuseExistingServer: false,
- env: { HOME: mkdtempSync(join(tmpdir(), 'beacon-lens-e2e-')) },
+ env: { ...goEnv, HOME: mkdtempSync(join(tmpdir(), 'beacon-lens-e2e-')) },
},
});
diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/lenses.spec.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/lenses.spec.ts
index 50e832e7..da19679e 100644
--- a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/lenses.spec.ts
+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/lenses.spec.ts
@@ -137,3 +137,30 @@ test('tabs are added from the menu, deep-linked, and removed', async ({ page })
await expect(page.locator('#lens-tabs .lens-tab')).toHaveCount(1);
await expect(page).not.toHaveURL(/lens=/);
});
+
+test('going back to a lens whose tab was removed brings the tab back', async ({ page }) => {
+ await page.goto('/session.html?id=s1');
+ await page.evaluate(() => localStorage.clear());
+ await page.goto('/session.html?id=s1&lens=activity');
+ await expect(lensFrame(page).locator('#root')).toBeVisible();
+ await page.locator('.lens-tab', { hasText: 'Activity' }).locator('.lens-tab-remove').click();
+ await expect(page.locator('#lens-tabs .lens-tab')).toHaveCount(1);
+
+ await page.goBack();
+ await expect(page).toHaveURL(/lens=activity/);
+ await expect(page.locator('.lens-tab[aria-selected="true"]')).toContainText('Activity');
+ await expect(lensFrame(page).locator('#root')).toBeVisible();
+});
+
+test('clicking the active tab neither reloads the lens nor adds history', async ({ page }) => {
+ await page.goto('/session.html?id=s1&lens=activity');
+ await expect(lensFrame(page).locator('#root')).toBeVisible();
+ const before = await page.evaluate(() => history.length);
+ const frame = page.locator('iframe.lens-frame');
+ await frame.evaluate((f) => { (f as any).dataset.marker = 'same'; });
+ await page.locator('.lens-tab[aria-selected="true"]').click();
+ await page.waitForTimeout(300);
+ expect(await page.evaluate(() => history.length)).toBe(before);
+ await expect(page.locator('iframe.lens-frame')).toHaveAttribute('data-marker', 'same');
+});
+