Build and Push Docker Image / build-and-push (push) Successful in 5m13s
- Earlier versions of a study: the server keeps compressed copies (about one per ten minutes of editing, the latest 30); Export shows what differs and puts one back (the replaced copy is kept) - Notes on highlights and bookmarks: synced, merged without loss, in exports and backups - Reader verse panel lists your studies and chunks that cover the verse, and opens them - Prayer journal: requests, who for, linked verses, days prayed, answers; synced, in backups and the account export; daily prayer reminder through ntfy - TODO.md lists the ideas not built yet Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
26 lines
1.5 KiB
JavaScript
26 lines
1.5 KiB
JavaScript
// @vitest-environment node
|
|
import { test, expect } from 'vitest';
|
|
import { MIN_GAP_MS, pack, shouldSnapshot, summarizeProject, unpack } from './versions.js';
|
|
|
|
test('a version is kept once per window of editing, and always the first', () => {
|
|
const t = 1_800_000_000_000;
|
|
expect(shouldSnapshot({ prevEditedAt: t, lastKeptAt: undefined })).toBe(true);
|
|
expect(shouldSnapshot({ prevEditedAt: t, lastKeptAt: t - 60_000 })).toBe(false); // a minute after the last one
|
|
expect(shouldSnapshot({ prevEditedAt: t, lastKeptAt: t - MIN_GAP_MS })).toBe(true);
|
|
expect(shouldSnapshot({ prevEditedAt: t, lastKeptAt: t - 1000, force: true })).toBe(true); // before a restore
|
|
expect(shouldSnapshot({ prevEditedAt: undefined, lastKeptAt: undefined })).toBe(false); // nothing to keep
|
|
});
|
|
|
|
test('a stored copy round-trips and is smaller than the original', () => {
|
|
const study = { id: 'a', title: 'T', chapters: [{ verses: Array.from({ length: 200 }, (_, i) => ({ number: i, text: 'In the beginning God created the heavens and the earth.' })) }] };
|
|
const packed = pack(study);
|
|
expect(packed.length).toBeLessThan(JSON.stringify(study).length / 5);
|
|
expect(unpack(packed)).toEqual(study);
|
|
});
|
|
|
|
test('a study is summarised by its chunks and the words in its notes', () => {
|
|
const s = summarizeProject({ chapters: [{ chunks: [{ observation: 'one two three', application: ' four ' }, { finalScript: 'a b' }] }, { chunks: [{}] }] });
|
|
expect(s).toEqual({ chunks: 3, words: 6 });
|
|
expect(summarizeProject(null)).toEqual({ chunks: 0, words: 0 });
|
|
});
|