Notes: multiple notes per section with last-edited dates, delete, sort by recently edited; Word export now readable; shared note-format module + tests; v2.43.0
Publish Container / build (push) Successful in 16m3s
Publish Container / build (push) Successful in 16m3s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
401fd451de
commit
09177f47ed
8 files changed
+285
-76
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { parseNoteEntries, serializeNoteEntries, noteEntriesToText } from '../shared/note-format.js'
|
||||
|
||||
test('legacy anchor map upgrades to entries and round-trips as v2', () => {
|
||||
const entries = parseNoteEntries(JSON.stringify({ scripture: '<p>a</p>', general: '', commentary: '<p>b</p>' }))
|
||||
assert.deepEqual(entries.map(e => e.anchor), ['scripture', 'commentary'])
|
||||
const again = parseNoteEntries(serializeNoteEntries(entries))
|
||||
assert.equal(again.length, 2)
|
||||
assert.equal(JSON.parse(serializeNoteEntries(entries)).v, 2)
|
||||
})
|
||||
|
||||
test('plain-text legacy notes become a general entry', () => {
|
||||
const entries = parseNoteEntries('just some text')
|
||||
assert.equal(entries.length, 1)
|
||||
assert.equal(entries[0].anchor, 'general')
|
||||
})
|
||||
|
||||
test('multiple entries per anchor are kept and empty ones dropped', () => {
|
||||
const raw = serializeNoteEntries([
|
||||
{ id: '1', anchor: 'general', html: '<p>one</p>', updatedAt: '2026-01-01T00:00:00.000Z' },
|
||||
{ id: '2', anchor: 'general', html: '<p>two</p>', updatedAt: null },
|
||||
{ id: '3', anchor: 'general', html: ' ', updatedAt: null },
|
||||
])
|
||||
assert.equal(parseNoteEntries(raw).length, 2)
|
||||
assert.equal(serializeNoteEntries([]), '')
|
||||
})
|
||||
|
||||
test('plain-text export strips markup', () => {
|
||||
const text = noteEntriesToText(serializeNoteEntries([{ id: '1', anchor: 'scripture', html: '<p>Hi & bye</p>', updatedAt: null }]))
|
||||
assert.equal(text, 'Scripture Text\nHi & bye')
|
||||
})
|
||||
Reference in new issue
Block a user