Add Outline stage, parallel reading, offline saves, backup, sync-conflict handling and more
Study - New Outline stage (hierarchical I./A./1. points, linked to chunks, in all exports); the chunk stage is now "Chunks" - Home cards: passages shown as ranges, tags capped with "+N more" Reader - Side-by-side translations and a Compare tab per verse - Typeface, line spacing, verse-number settings; text and column scale with the screen - Highlights/bookmarks sheet with named colours (synced); BSB footnote spacing fix - Cmd-K palette (passages, studies, notes, marks), keyboard shortcuts and "?" help Flow and safety - Toasts with Undo replace most confirm()/alert() - Back/Forward move between pages - Server refuses saves over a newer copy (409); keep-mine / use-other banner; opening a study no longer re-stamps it - Latest chapter request wins when flipping quickly Offline and data - Save books, plan days or a whole BSB/NET for offline - Service worker fixes: helloao /api/ URLs were skipped and responses cloned too late - Settings: download/restore a full backup Accessibility - Sheets trap focus and close on Escape, skip link, focus ring, reduced motion, theme contrast raised to 4.5:1 (with a test) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1edbd364ea
commit
d13f55faf7
65 files changed
+2947
-208
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { afterEach, beforeEach, expect, test, vi } from 'vitest';
|
||||
import { bibleRefs, bookRefs, canSaveOffline, downloadChapters, loadSavedBooks, markBookSaved } from './offline.js';
|
||||
|
||||
beforeEach(() => localStorage.clear());
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
const chapterResponse = { ok: true, json: () => Promise.resolve({ chapter: { content: [{ type: 'verse', number: 1, content: ['In the beginning.'] }] } }) };
|
||||
|
||||
test('lists every chapter of a book and of the whole Bible', () => {
|
||||
expect(bookRefs('JHN')).toHaveLength(21);
|
||||
expect(bookRefs('JHN')[0]).toEqual({ book: 'JHN', chapter: 1 });
|
||||
expect(bibleRefs()).toHaveLength(1189);
|
||||
});
|
||||
|
||||
test('only the free translations can be saved', () => {
|
||||
expect(canSaveOffline('BSB')).toBe(true);
|
||||
expect(canSaveOffline('NET')).toBe(true);
|
||||
expect(canSaveOffline('ESV')).toBe(false);
|
||||
});
|
||||
|
||||
test('remembers which books are saved', () => {
|
||||
markBookSaved('BSB', 'JHN');
|
||||
markBookSaved('BSB', 'JHN');
|
||||
markBookSaved('BSB', 'PSA');
|
||||
expect(loadSavedBooks()).toEqual({ BSB: ['JHN', 'PSA'] });
|
||||
});
|
||||
|
||||
test('downloads every chapter, reports progress, and keeps going past a failure', async () => {
|
||||
const fetchMock = vi.fn((url) => Promise.resolve(url.includes('/JHN/2.json') ? { ok: false } : chapterResponse));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const progress = [];
|
||||
const result = await downloadChapters('BSB', bookRefs('JHN').slice(0, 4), { onProgress: (d, t) => progress.push([d, t]) });
|
||||
expect(result).toEqual({ done: 3, failed: 1 });
|
||||
expect(fetchMock).toHaveBeenCalledTimes(4);
|
||||
expect(progress.at(-1)).toEqual([4, 4]);
|
||||
});
|
||||
|
||||
test('stops when told to', async () => {
|
||||
const controller = new AbortController();
|
||||
const fetchMock = vi.fn(() => { controller.abort(); return Promise.resolve(chapterResponse); });
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
await downloadChapters('BSB', bookRefs('PSA'), { signal: controller.signal, concurrency: 1 });
|
||||
expect(fetchMock.mock.calls.length).toBeLessThan(5);
|
||||
});
|
||||
Reference in new issue
Block a user