fix(ext/tests): update devices tests for revamp (fingerprint + two-step revoke)
Tests predated the 2026-05-24 management-surfaces revamp (047df6e): popup
devices pane now shows SHA-256 fingerprint + added-by + inline two-step
revoke confirm, and the SW revokeDevice signature may have shifted to
match. Mocks + assertions updated accordingly.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,10 +3,19 @@ import { readDevices, addDevice, revokeDevice } from '../devices';
|
||||
import type { GitHost } from '../git-host';
|
||||
|
||||
function makeGitHost(devicesJson = '{"devices":[]}'): GitHost {
|
||||
let stored = devicesJson;
|
||||
// Per-path storage — revokeDevice writes devices.json AND revoked.json,
|
||||
// so a single slot would corrupt the second read.
|
||||
const files = new Map<string, string>();
|
||||
files.set('.relicario/devices.json', devicesJson);
|
||||
return {
|
||||
readFile: vi.fn().mockImplementation(async () => new TextEncoder().encode(stored)),
|
||||
writeFile: vi.fn().mockImplementation(async (_p, bytes) => { stored = new TextDecoder().decode(bytes); }),
|
||||
readFile: vi.fn().mockImplementation(async (path: string) => {
|
||||
const content = files.get(path);
|
||||
if (content === undefined) throw new Error(`404: ${path}`);
|
||||
return new TextEncoder().encode(content);
|
||||
}),
|
||||
writeFile: vi.fn().mockImplementation(async (path: string, bytes: Uint8Array) => {
|
||||
files.set(path, new TextDecoder().decode(bytes));
|
||||
}),
|
||||
deleteFile: vi.fn(),
|
||||
listDir: vi.fn(),
|
||||
putBlob: vi.fn(),
|
||||
|
||||
Reference in New Issue
Block a user