feat(pairing): QR offer + app scanner

This commit is contained in:
Mohamed Boudra
2026-01-22 09:24:08 +07:00
parent ca8d09434b
commit 7157a43a74
15 changed files with 636 additions and 29 deletions
+32 -7
View File
@@ -20,14 +20,24 @@ test('host removal removes the host from UI and persists after reload', async ({
updatedAt: nowIso,
};
const seededTestDaemon = {
id: 'e2e-test-daemon',
label: 'localhost',
endpoints: [`127.0.0.1:${daemonPort}`],
relay: null,
metadata: null,
createdAt: nowIso,
updatedAt: nowIso,
};
const seedOnceKey = `@paseo:e2e-host-removal-seeded:${Math.random().toString(36).slice(2)}`;
// Add a second host once (fixtures seed the primary host on every navigation).
await page.addInitScript(
({ daemon }) => {
const seedOnceKey = '@paseo:e2e-extra-daemon-seeded-once';
({ daemon, seededTestDaemon, seedOnceKey }) => {
if (localStorage.getItem(seedOnceKey)) {
return;
}
localStorage.setItem(seedOnceKey, '1');
const raw = localStorage.getItem('@paseo:daemon-registry');
let parsed: any[] = [];
@@ -38,10 +48,23 @@ test('host removal removes the host from UI and persists after reload', async ({
parsed = [];
}
}
const next = Array.isArray(parsed) ? [...parsed, daemon] : [daemon];
const list = Array.isArray(parsed) ? parsed : [];
localStorage.setItem(seedOnceKey, '1');
const next = [...list];
const hasSeeded = next.some((entry: any) => entry && entry.id === seededTestDaemon.id);
if (!hasSeeded) {
next.push(seededTestDaemon);
}
const alreadyPresent = next.some((entry: any) => entry && entry.id === daemon.id);
if (!alreadyPresent) {
next.push(daemon);
}
localStorage.setItem('@paseo:daemon-registry', JSON.stringify(next));
},
{ daemon: extraDaemon }
{ daemon: extraDaemon, seededTestDaemon, seedOnceKey }
);
await page.goto('/settings');
@@ -72,8 +95,10 @@ test('host removal removes the host from UI and persists after reload', async ({
);
// Prevent the fixture from overwriting storage on reload; verify persistence.
await page.evaluate(() => localStorage.setItem('@paseo:e2e-disable-default-seed-once', '1'));
await page.evaluate(() => {
const nonce = localStorage.getItem('@paseo:e2e-seed-nonce') ?? '1';
localStorage.setItem('@paseo:e2e-disable-default-seed-once', nonce);
});
await page.reload();
await expect(page.getByText(extraEndpoint, { exact: true })).toHaveCount(0);
});