The app becomes a Rails 8 application; the Vue frontend moves to app/frontend and is served through vite_rails. - Without an account documents stay in the browser (IndexedDB). Sign-in is by magic link or the 6-digit code from the same mail; afterwards local documents can be uploaded into the account. - Server documents (/d/<id>) with versioned saves and a single-editor lock per browser tab; others see them read-only and follow by polling. - Sharing via link (works without an account) and via e-mail invitation, roles viewer/editor; the owner manages links and people. - Store gains a read-only mode that blocks all content changes. - Solid Queue, Cache and Cable share the one PostgreSQL database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { strFromU8, strToU8, unzipSync, zipSync } from 'fflate';
|
|
import { useDocument } from '../../store/document';
|
|
import { serializeDocument } from '../json';
|
|
import { importJsonReplace, readNumFile } from '../operations';
|
|
import { NUM_MIMETYPE, NumFileError, packNum, unpackNum } from '../num';
|
|
|
|
describe('.num files', () => {
|
|
it('round-trip the document JSON exactly', async () => {
|
|
const s = useDocument();
|
|
s.resetToSeed();
|
|
const json = serializeDocument(s.snapshot());
|
|
const bytes = packNum(json);
|
|
expect(unpackNum(bytes)).toBe(json);
|
|
// and import back into the store like a .json file
|
|
s.newDocument();
|
|
importJsonReplace(s, await readNumFile(bytes.slice().buffer));
|
|
expect(serializeDocument(s.snapshot())).toBe(json);
|
|
});
|
|
|
|
it('are smaller than the JSON they carry', () => {
|
|
const s = useDocument();
|
|
s.resetToSeed();
|
|
const json = serializeDocument(s.snapshot());
|
|
expect(packNum(json).length).toBeLessThan(json.length);
|
|
});
|
|
|
|
it('start with an uncompressed mimetype entry, plus meta.json with an ISO timestamp', () => {
|
|
const bytes = packNum('{}', new Date('2026-09-28T10:00:00Z'));
|
|
// local file header (30 bytes) + "mimetype" (8) -> the stored content
|
|
expect(strFromU8(bytes.subarray(30, 38))).toBe('mimetype');
|
|
expect(strFromU8(bytes.subarray(38, 38 + NUM_MIMETYPE.length))).toBe(NUM_MIMETYPE);
|
|
const meta = JSON.parse(strFromU8(unzipSync(bytes)['meta.json']));
|
|
expect(meta).toEqual({ format: 'numolus', formatVersion: 1, created: '2026-09-28T10:00:00.000Z' });
|
|
});
|
|
|
|
it('reject what is not a numolus file', () => {
|
|
expect(() => unpackNum(strToU8('{"version":2}'))).toThrow(NumFileError);
|
|
expect(() => unpackNum(zipSync({ mimetype: strToU8('application/zip') }))).toThrow(/Keine numolus-Datei/);
|
|
expect(() => unpackNum(zipSync({ mimetype: strToU8(NUM_MIMETYPE) }))).toThrow(/kein document.json/);
|
|
const newer = zipSync({
|
|
mimetype: strToU8(NUM_MIMETYPE),
|
|
'meta.json': strToU8('{"formatVersion": 99}'),
|
|
'document.json': strToU8('{}'),
|
|
});
|
|
expect(() => unpackNum(newer)).toThrow(/neueren numolus-Version/);
|
|
});
|
|
});
|