test: cover wallet lifecycle through the browser

This commit is contained in:
2026-08-22 16:56:49 +02:00
parent 578613c869
commit a40079200d
4 changed files with 352 additions and 1 deletions
+18
View File
@@ -3,6 +3,15 @@ import { useWalletStore } from '@/stores/wallet';
import { useNostrBackupStore } from '@/stores/nostrBackup';
import { useNwcStore } from '@/stores/nwc';
declare global {
interface Window {
__sattleWalletTest?: {
readonly state: () => ReturnType<typeof useWalletStore>['state'];
readonly forget: () => Promise<void>;
};
}
}
// Wallet lifecycle bootstrap: reflects whatever is on this device into the
// wallet store at app start - a plaintext-stored key unlocks straight away,
// a password-encrypted one lands on 'locked' for the unlock screen, and no
@@ -17,3 +26,12 @@ export default defineBoot(async () => {
// client requests; on lock it stops and drops the key-material closure
useNwcStore();
});
// dev-only e2e hook: lets a spec observe the wallet state and drive the
// forget transition, which has no UI surface. Never in production builds.
if (import.meta.env.DEV && typeof window !== 'undefined') {
window.__sattleWalletTest = {
state: () => useWalletStore().state,
forget: () => useWalletStore().forgetWallet(),
};
}