Use better behavior on disconnected radio and allow deeplinking into settings. Closes #66.

This commit is contained in:
Jack Kingsman
2026-03-16 17:46:12 -07:00
parent ffb5fa51c1
commit b68bfc41d6
14 changed files with 359 additions and 56 deletions

View File

@@ -1,9 +1,19 @@
import { act, renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { act, renderHook, waitFor } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { useAppShell } from '../hooks/useAppShell';
describe('useAppShell', () => {
let originalHash: string;
beforeEach(() => {
originalHash = window.location.hash;
});
afterEach(() => {
window.location.hash = originalHash;
});
it('opens new-message modal and closes the sidebar', () => {
const { result } = renderHook(() => useAppShell());
@@ -34,6 +44,55 @@ describe('useAppShell', () => {
expect(result.current.showSettings).toBe(false);
});
it('initializes settings mode from the URL hash', () => {
window.location.hash = '#settings/database';
const { result } = renderHook(() => useAppShell());
expect(result.current.showSettings).toBe(true);
expect(result.current.settingsSection).toBe('database');
});
it('syncs the selected settings section into the URL hash', async () => {
const { result } = renderHook(() => useAppShell());
act(() => {
result.current.handleToggleSettingsView();
});
await waitFor(() => {
expect(window.location.hash).toBe('#settings/radio');
});
act(() => {
result.current.setSettingsSection('fanout');
});
await waitFor(() => {
expect(window.location.hash).toBe('#settings/fanout');
});
});
it('restores the previous hash when settings close', async () => {
window.location.hash = '#channel/test/Public';
const { result } = renderHook(() => useAppShell());
act(() => {
result.current.handleToggleSettingsView();
});
await waitFor(() => {
expect(window.location.hash).toBe('#settings/radio');
});
act(() => {
result.current.handleCloseSettingsView();
});
expect(window.location.hash).toBe('#channel/test/Public');
});
it('toggles the cracker shell without affecting sidebar state', () => {
const { result } = renderHook(() => useAppShell());