mirror of
https://github.com/tompro/sattle.git
synced 2026-08-27 07:15:59 +00:00
test: cover wallet lifecycle through the browser
This commit is contained in:
@@ -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(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ const errorMessage = (err: unknown): string =>
|
||||
|
||||
// ---- backup file ----
|
||||
const downloadBackupFile = () => {
|
||||
const backup = buildBackup();
|
||||
const backup = buildBackup(wallet.pubkey ?? undefined);
|
||||
const blob = new Blob([JSON.stringify(backup, null, 2)], {
|
||||
type: 'application/json',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user