diff --git a/src/pages/SettingsPage.test.tsx b/src/pages/SettingsPage.test.tsx new file mode 100644 index 00000000..4d1d025f --- /dev/null +++ b/src/pages/SettingsPage.test.tsx @@ -0,0 +1,50 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import type { BreezSdk } from '@breeztech/breez-sdk-spark'; +import { WalletProvider } from '@/contexts/WalletContext'; +import { ToastProvider } from '@/contexts/ToastContext'; +import { createMockClient } from '@/test/mocks/mockWalletApi'; +import { setDevMode } from '@/services/settings'; +import SettingsPage from './SettingsPage'; + +const renderSettings = () => render( + + + + + +); + +// `vite.config.ts` defines this at build time, so the version line has nothing +// to read under vitest. +vi.stubGlobal('__APP_VERSION__', '0.0.0-test'); + +afterEach(() => { + setDevMode(false); + localStorage.clear(); +}); + +describe('unilateral exit on the settings page', () => { + it('is not offered without dev mode', () => { + setDevMode(false); + renderSettings(); + + expect(screen.queryByTestId('settings-unilateral-exit')).toBeNull(); + }); + + it('is offered with dev mode on', () => { + setDevMode(true); + renderSettings(); + + expect(screen.getByTestId('settings-unilateral-exit')).toBeInTheDocument(); + }); +}); diff --git a/src/pages/SettingsPage.tsx b/src/pages/SettingsPage.tsx index bca64ed3..dd54b312 100644 --- a/src/pages/SettingsPage.tsx +++ b/src/pages/SettingsPage.tsx @@ -450,6 +450,12 @@ const SettingsPage: React.FC = ({ )} + {/* Dev mode only: this is what you reach for if Spark stops operating, + not a feature, and starting one moves the whole balance on-chain + at the cost of mining fees. An exit already running stays on the + transaction list either way, so nothing in flight is stranded by + turning dev mode back off. */} + {isDevMode && (

Unilateral Exit

@@ -475,6 +481,7 @@ const SettingsPage: React.FC = ({ Use this only if Spark stops operating. This is a last-resort action.

+ )} {/* Account deletion (App Store 5.1.1(v)): opens the guide explaining how to delete the account (logout wipes the