@lemonriver/core 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-DYN-H65n.js → build-CSkdswfd.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-DW1wSoxa.js → config-C5-myPY6.js} +2087 -1439
- package/dist/{dev-_VDoRfAK.js → dev-DHtYH8sw.js} +2 -2
- package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
- package/dist/{preview-CYIGh3Z8.js → preview-C1B6-umF.js} +1 -1
- package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +5 -2
- package/release-notes.json +19 -0
- package/src/app/components/command/slide-command-menu.tsx +0 -9
- package/src/app/lemonriver/backup/client.ts +25 -1
- package/src/app/lemonriver/backup/model.ts +63 -18
- package/src/app/lemonriver/board/board-page.tsx +2 -2
- package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
- package/src/app/lemonriver/feedback/dialog.tsx +222 -0
- package/src/app/lemonriver/feedback/export.ts +21 -2
- package/src/app/lemonriver/feedback/first-success.ts +30 -0
- package/src/app/lemonriver/feedback/install.ts +18 -0
- package/src/app/lemonriver/feedback/model.ts +88 -0
- package/src/app/lemonriver/help/help-page.tsx +16 -1
- package/src/app/lemonriver/help/model.ts +1 -1
- package/src/app/lemonriver/home/drafts.ts +57 -0
- package/src/app/lemonriver/home/home-page.tsx +94 -10
- package/src/app/lemonriver/home/organize-drafts.tsx +192 -0
- package/src/app/lemonriver/links.ts +16 -0
- package/src/app/lemonriver/outline/outline-page.tsx +8 -1
- package/src/app/lemonriver/settings/backup-restore-dialog.tsx +15 -1
- package/src/app/lemonriver/settings/backup-section.tsx +159 -28
- package/src/app/lemonriver/settings/settings-page.tsx +23 -0
- package/src/app/lemonriver/settings/workspace-card.tsx +53 -0
- package/src/app/lemonriver/settings/workspace.ts +37 -0
- package/src/app/lemonriver/share/editor-share.tsx +58 -0
- package/src/app/lemonriver/share/import-dialog.tsx +14 -0
- package/src/app/lemonriver/share/naming.ts +6 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -0
- package/src/app/lemonriver/slide-extensions.tsx +37 -53
- package/src/app/lemonriver/text/en.ts +91 -11
- package/src/app/lemonriver/text/es.ts +81 -6
- package/src/app/lemonriver/text/ja.ts +80 -6
- package/src/app/lemonriver/text/types.ts +89 -6
- package/src/app/lemonriver/text/zh-cn.ts +92 -11
- package/src/app/lemonriver/text/zh-tw.ts +92 -11
- package/src/app/lemonriver/theme/pages.ts +4 -0
- package/src/app/lemonriver/update/beta-badge.tsx +69 -0
- package/src/app/lemonriver/update/release-notes.ts +22 -0
- package/src/app/lemonriver/update/update-prompt.tsx +28 -4
- package/src/app/lib/export-html.ts +5 -3
- package/src/app/lib/export-pptx.ts +5 -4
- package/src/app/routes/slide.tsx +6 -57
- package/src/app/components/note-markdown.test.tsx +0 -42
- package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
- package/src/app/lemonriver/backup/guide.test.ts +0 -45
- package/src/app/lemonriver/backup/model.test.ts +0 -96
- package/src/app/lemonriver/backup/places.test.ts +0 -154
- package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
- package/src/app/lemonriver/board/layout.test.ts +0 -245
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
- package/src/app/lemonriver/board/model/cards.test.ts +0 -332
- package/src/app/lemonriver/board/model/changes.test.ts +0 -244
- package/src/app/lemonriver/board/model/filter.test.ts +0 -50
- package/src/app/lemonriver/board/model/history.test.ts +0 -71
- package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
- package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
- package/src/app/lemonriver/board/model/structure.test.ts +0 -350
- package/src/app/lemonriver/board/model/timing.test.ts +0 -113
- package/src/app/lemonriver/features.test.ts +0 -49
- package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
- package/src/app/lemonriver/feedback/upload.test.ts +0 -26
- package/src/app/lemonriver/help/model.test.ts +0 -179
- package/src/app/lemonriver/home/brief.test.ts +0 -38
- package/src/app/lemonriver/home/sorting.test.ts +0 -24
- package/src/app/lemonriver/home/time.test.ts +0 -33
- package/src/app/lemonriver/outline/files.test.ts +0 -90
- package/src/app/lemonriver/outline/model.test.ts +0 -751
- package/src/app/lemonriver/public-links.test.ts +0 -32
- package/src/app/lemonriver/routes.test.tsx +0 -54
- package/src/app/lemonriver/share/codes.test.ts +0 -49
- package/src/app/lemonriver/share/compare.test.ts +0 -199
- package/src/app/lemonriver/share/folder.test.ts +0 -42
- package/src/app/lemonriver/share/guide.test.ts +0 -78
- package/src/app/lemonriver/share/naming.test.ts +0 -59
- package/src/app/lemonriver/share/paths.test.ts +0 -116
- package/src/app/lemonriver/share/pdf.test.ts +0 -79
- package/src/app/lemonriver/templates/knobs.test.ts +0 -62
- package/src/app/lemonriver/templates/model.test.ts +0 -175
- package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
- package/src/app/lemonriver/templates/recommend.test.ts +0 -71
- package/src/app/lemonriver/text/text.test.ts +0 -90
- package/src/app/lemonriver/theme/pages.test.ts +0 -74
- package/src/app/lemonriver/theme/themes.test.ts +0 -18
- package/src/app/lemonriver/trash/api.test.ts +0 -19
- package/src/app/lemonriver/update/prompt.test.ts +0 -84
- package/src/app/lemonriver/update/version.test.ts +0 -14
- package/src/app/lib/asset-filter.test.ts +0 -176
- package/src/app/lib/inspector/fiber.test.ts +0 -154
- package/src/app/lib/inspector/geometry.test.ts +0 -324
- package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
- package/src/app/lib/note-markdown.test.ts +0 -147
- package/src/app/lib/pptx/css.test.ts +0 -205
- package/src/app/lib/pptx/ooxml.test.ts +0 -199
- package/src/app/lib/pptx/text-lines.test.ts +0 -82
- package/src/app/lib/print-ready.test.ts +0 -32
- package/src/app/lib/sdk.test.ts +0 -13
- package/src/app/lib/transition.test.ts +0 -31
- package/src/app/lib/use-document-title.test.ts +0 -14
- package/src/app/lib/utils.test.ts +0 -49
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
adoptEntries,
|
|
4
|
-
type CardState,
|
|
5
|
-
carryCards,
|
|
6
|
-
entriesAfter,
|
|
7
|
-
isSettledKey,
|
|
8
|
-
linkCards,
|
|
9
|
-
linkedPairs,
|
|
10
|
-
originAfter,
|
|
11
|
-
type PageOp,
|
|
12
|
-
pageKeys,
|
|
13
|
-
patchCard,
|
|
14
|
-
sanitizeCards,
|
|
15
|
-
sanitizeLinks,
|
|
16
|
-
setLinkKind,
|
|
17
|
-
unlinkCards,
|
|
18
|
-
} from './cards.ts';
|
|
19
|
-
|
|
20
|
-
/** Runs one board operation the way the board does, entries and all. */
|
|
21
|
-
function run(state: CardState, entries: string[], op: PageOp) {
|
|
22
|
-
const count = entries.length;
|
|
23
|
-
const next = entriesAfter(op, entries, count);
|
|
24
|
-
const nextCount =
|
|
25
|
-
op.kind === 'delete'
|
|
26
|
-
? count - 1
|
|
27
|
-
: op.kind === 'deleteMany'
|
|
28
|
-
? count - op.indices.length
|
|
29
|
-
: op.kind === 'move' || op.kind === 'moveMany' || op.kind === 'reorder'
|
|
30
|
-
? count
|
|
31
|
-
: count + 1;
|
|
32
|
-
const carried = carryCards(
|
|
33
|
-
state,
|
|
34
|
-
pageKeys(entries, count),
|
|
35
|
-
pageKeys(next, nextCount),
|
|
36
|
-
originAfter(op, count),
|
|
37
|
-
);
|
|
38
|
-
return { state: carried, entries: next };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The memo each position shows, which is what a user actually sees. */
|
|
42
|
-
const memos = (state: CardState, entries: string[] | null | undefined, count: number) =>
|
|
43
|
-
pageKeys(entries, count).map((key) => state.cards[key]?.memo ?? null);
|
|
44
|
-
|
|
45
|
-
const deck = ['Cover', 'Agenda', 'Q3', 'Close'];
|
|
46
|
-
|
|
47
|
-
describe('pageKeys', () => {
|
|
48
|
-
it('keys pages by their entry in the deck', () => {
|
|
49
|
-
expect(pageKeys(deck, 4)).toEqual(deck);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('tells repeated entries apart, so a duplicated page gets its own card', () => {
|
|
53
|
-
expect(pageKeys(['A', 'B', 'A', 'A'], 4)).toEqual(['A', 'B', 'A#2', 'A#3']);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('falls back to positions when the entries cannot be read one per page', () => {
|
|
57
|
-
expect(pageKeys(null, 3)).toEqual(['@0', '@1', '@2']);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('gives a deck caught mid-reload keys that match no card', () => {
|
|
61
|
-
const keys = pageKeys(['A', 'B'], 3);
|
|
62
|
-
expect(keys.every(isSettledKey)).toBe(false);
|
|
63
|
-
expect(pageKeys(undefined, 2).some(isSettledKey)).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('carryCards', () => {
|
|
68
|
-
const withMemo: CardState = { cards: { Q3: { memo: 'Q3 numbers missing' } }, links: [] };
|
|
69
|
-
|
|
70
|
-
it('keeps a memo on its page when the page moves', () => {
|
|
71
|
-
const after = run(withMemo, deck, { kind: 'move', from: 2, to: 0 });
|
|
72
|
-
expect(memos(after.state, after.entries, 4)).toEqual(['Q3 numbers missing', null, null, null]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('keeps a memo on its page when the deck is reordered outside the board', () => {
|
|
76
|
-
// No operation runs: the thumbnail rail rewrote the file and the entries reload.
|
|
77
|
-
expect(memos(withMemo, ['Q3', 'Cover', 'Agenda', 'Close'], 4)[0]).toBe('Q3 numbers missing');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('never shifts a memo onto the neighbour when a page is added before it', () => {
|
|
81
|
-
const after = run(withMemo, deck, { kind: 'insert', index: 1 });
|
|
82
|
-
expect(memos(after.state, after.entries, 5)).toEqual([
|
|
83
|
-
null,
|
|
84
|
-
null,
|
|
85
|
-
null,
|
|
86
|
-
'Q3 numbers missing',
|
|
87
|
-
null,
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('starts a duplicated page with a card of its own', () => {
|
|
92
|
-
const after = run(withMemo, deck, { kind: 'duplicate', index: 2 });
|
|
93
|
-
expect(memos(after.state, after.entries, 5)).toEqual([
|
|
94
|
-
null,
|
|
95
|
-
null,
|
|
96
|
-
'Q3 numbers missing',
|
|
97
|
-
null,
|
|
98
|
-
null,
|
|
99
|
-
]);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('lets the copy keep its own memo while the original moves around it', () => {
|
|
103
|
-
let state: CardState = {
|
|
104
|
-
cards: { A: { memo: 'first' }, 'A#2': { memo: 'second' } },
|
|
105
|
-
links: [],
|
|
106
|
-
};
|
|
107
|
-
let entries = ['A', 'B', 'A'];
|
|
108
|
-
({ state, entries } = run(state, entries, { kind: 'move', from: 0, to: 2 }));
|
|
109
|
-
expect(memos(state, entries, 3)).toEqual([null, 'second', 'first']);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('takes a deleted page’s card and links with it', () => {
|
|
113
|
-
const state: CardState = {
|
|
114
|
-
cards: { Q3: { memo: 'gone' }, Close: { memo: 'kept' } },
|
|
115
|
-
links: [{ a: 'Q3', b: 'Cover' }],
|
|
116
|
-
};
|
|
117
|
-
const after = run(state, deck, { kind: 'delete', index: 2 });
|
|
118
|
-
expect(after.state.cards).toEqual({ Close: { memo: 'kept' } });
|
|
119
|
-
expect(after.state.links).toEqual([]);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('does not hand a deleted copy’s memo to the original', () => {
|
|
123
|
-
const state: CardState = { cards: { 'A#2': { memo: 'copy only' } }, links: [] };
|
|
124
|
-
const after = run(state, ['A', 'A'], { kind: 'delete', index: 1 });
|
|
125
|
-
expect(memos(after.state, after.entries, 1)).toEqual([null]);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('re-keys every page when the deck is keyed by position', () => {
|
|
129
|
-
const state: CardState = { cards: { '@2': { memo: 'third page' } }, links: [] };
|
|
130
|
-
const op: PageOp = { kind: 'move', from: 2, to: 0 };
|
|
131
|
-
const carried = carryCards(state, pageKeys(null, 4), pageKeys(null, 4), originAfter(op, 4));
|
|
132
|
-
expect(memos(carried, null, 4)).toEqual(['third page', null, null, null]);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('leaves data for a page the deck does not have right now where it is', () => {
|
|
136
|
-
const state: CardState = { cards: { Gone: { memo: 'parked' } }, links: [] };
|
|
137
|
-
const after = run(state, deck, { kind: 'move', from: 0, to: 3 });
|
|
138
|
-
expect(after.state.cards.Gone).toEqual({ memo: 'parked' });
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('starts a new copy clean even when an earlier copy left data under the same key', () => {
|
|
142
|
-
// The first copy was deleted from the thumbnail rail, so its card was never cleared.
|
|
143
|
-
const state: CardState = {
|
|
144
|
-
cards: { 'A#2': { memo: 'old copy' } },
|
|
145
|
-
links: [{ a: 'A#2', b: 'B' }],
|
|
146
|
-
};
|
|
147
|
-
const after = run(state, ['A', 'B'], { kind: 'duplicate', index: 0 });
|
|
148
|
-
expect(memos(after.state, after.entries, 3)).toEqual([null, null, null]);
|
|
149
|
-
expect(after.state.links).toEqual([]);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('keeps a page’s own card when it is pushed onto a position that holds leftover data', () => {
|
|
153
|
-
// A deck keyed by position that once had five pages: "@4" is left over.
|
|
154
|
-
const state: CardState = {
|
|
155
|
-
cards: { '@3': { memo: 'last page' }, '@4': { memo: 'leftover' } },
|
|
156
|
-
links: [],
|
|
157
|
-
};
|
|
158
|
-
const op: PageOp = { kind: 'insert', index: 1 };
|
|
159
|
-
const carried = carryCards(state, pageKeys(null, 4), pageKeys(null, 5), originAfter(op, 4));
|
|
160
|
-
expect(memos(carried, null, 5)).toEqual([null, null, null, null, 'last page']);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe('adoptEntries', () => {
|
|
165
|
-
it('moves a blank page’s memo onto the name the deck gave it', () => {
|
|
166
|
-
let state: CardState = { cards: {}, links: [] };
|
|
167
|
-
let entries: string[] = ['Cover', 'Close'];
|
|
168
|
-
({ state, entries } = run(state, entries, { kind: 'insert', index: 1 }));
|
|
169
|
-
const blankKey = pageKeys(entries, 3)[1];
|
|
170
|
-
state = { ...state, cards: { [blankKey]: { memo: 'draft me' } } };
|
|
171
|
-
|
|
172
|
-
const named = ['Cover', 'NewPage1', 'Close'];
|
|
173
|
-
const adopted = adoptEntries(state, entries, named);
|
|
174
|
-
expect(memos(adopted, named, 3)).toEqual([null, 'draft me', null]);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('clears leftovers from an older page that used the same name', () => {
|
|
178
|
-
const state: CardState = {
|
|
179
|
-
cards: { NewPage1: { memo: 'stale' } },
|
|
180
|
-
links: [{ a: 'NewPage1', b: 'Cover' }],
|
|
181
|
-
};
|
|
182
|
-
const { entries } = run(state, ['Cover', 'Close'], { kind: 'insert', index: 1 });
|
|
183
|
-
const adopted = adoptEntries(state, entries, ['Cover', 'NewPage1', 'Close']);
|
|
184
|
-
expect(adopted.cards).toEqual({});
|
|
185
|
-
expect(adopted.links).toEqual([]);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('changes nothing when no blank page is waiting for a name', () => {
|
|
189
|
-
const state: CardState = { cards: { Cover: { memo: 'x' } }, links: [] };
|
|
190
|
-
expect(adoptEntries(state, deck, deck)).toBe(state);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
describe('links', () => {
|
|
195
|
-
it('records a link once, whichever way it is drawn', () => {
|
|
196
|
-
const links = linkCards(linkCards([], 'A', 'B'), 'B', 'A');
|
|
197
|
-
expect(links).toEqual([{ a: 'A', b: 'B' }]);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('never links a card to itself', () => {
|
|
201
|
-
expect(linkCards([], 'A', 'A')).toEqual([]);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('removes a link drawn the other way round', () => {
|
|
205
|
-
expect(unlinkCards([{ a: 'A', b: 'B' }], 'B', 'A')).toEqual([]);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('follows both pages when the deck is reordered', () => {
|
|
209
|
-
const keys = ['Close', 'Cover', 'Q3', 'Agenda'];
|
|
210
|
-
expect(linkedPairs(keys, [{ a: 'Cover', b: 'Close' }])).toEqual([{ a: 1, b: 0 }]);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('hides a link whose page is not in the deck', () => {
|
|
214
|
-
expect(linkedPairs(deck, [{ a: 'Cover', b: 'Gone' }])).toEqual([]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('carries what two pages have to do with each other', () => {
|
|
218
|
-
const keys = ['Close', 'Cover'];
|
|
219
|
-
expect(linkedPairs(keys, [{ a: 'Cover', b: 'Close', kind: 'cause' }])).toEqual([
|
|
220
|
-
{ a: 1, b: 0, kind: 'cause' },
|
|
221
|
-
]);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('names a link without making a second one', () => {
|
|
225
|
-
const links = setLinkKind([{ a: 'A', b: 'B' }], 'B', 'A', 'cause');
|
|
226
|
-
expect(links).toEqual([{ a: 'A', b: 'B', kind: 'cause' }]);
|
|
227
|
-
expect(setLinkKind(links, 'A', 'B', null)).toEqual([{ a: 'A', b: 'B' }]);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('keeps the kind when a page it points at moves', () => {
|
|
231
|
-
const after = run(
|
|
232
|
-
{ cards: {}, links: [{ a: 'Cover', b: 'Q3', kind: 'contrast' }] },
|
|
233
|
-
['Cover', 'Q3', 'Close'],
|
|
234
|
-
{ kind: 'move', from: 1, to: 0 },
|
|
235
|
-
);
|
|
236
|
-
expect(after.state.links).toEqual([{ a: 'Cover', b: 'Q3', kind: 'contrast' }]);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
describe('patchCard', () => {
|
|
241
|
-
it('sets and clears fields one at a time', () => {
|
|
242
|
-
let cards = patchCard({}, 'A', { title: 'Market', status: 'doing' });
|
|
243
|
-
expect(cards).toEqual({ A: { title: 'Market', status: 'doing' } });
|
|
244
|
-
cards = patchCard(cards, 'A', { status: null });
|
|
245
|
-
expect(cards).toEqual({ A: { title: 'Market' } });
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('drops a card once nothing is left on it', () => {
|
|
249
|
-
expect(patchCard({ A: { memo: 'x' } }, 'A', { memo: '' })).toEqual({});
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe('sanitize', () => {
|
|
254
|
-
it('keeps only the fields and statuses the board knows', () => {
|
|
255
|
-
expect(
|
|
256
|
-
sanitizeCards({
|
|
257
|
-
A: { title: ' Intro ', status: 'doing', extra: 1 },
|
|
258
|
-
B: { status: 'bogus' },
|
|
259
|
-
C: 'nope',
|
|
260
|
-
}),
|
|
261
|
-
).toEqual({ A: { title: 'Intro', status: 'doing' } });
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('drops malformed and duplicate links', () => {
|
|
265
|
-
expect(sanitizeLinks([{ a: 'A', b: 'B' }, { a: 'B', b: 'A' }, { a: 'A' }, null])).toEqual([
|
|
266
|
-
{ a: 'A', b: 'B' },
|
|
267
|
-
]);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('keeps a kind it knows and drops one it does not', () => {
|
|
271
|
-
expect(
|
|
272
|
-
sanitizeLinks([
|
|
273
|
-
{ a: 'A', b: 'B', kind: 'echo' },
|
|
274
|
-
{ a: 'B', b: 'C', kind: 'because' },
|
|
275
|
-
{ a: 'C', b: 'D' },
|
|
276
|
-
]),
|
|
277
|
-
).toEqual([
|
|
278
|
-
{ a: 'A', b: 'B', kind: 'echo' },
|
|
279
|
-
{ a: 'B', b: 'C' },
|
|
280
|
-
{ a: 'C', b: 'D' },
|
|
281
|
-
]);
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
describe('batch and structural operations', () => {
|
|
286
|
-
const state: CardState = {
|
|
287
|
-
cards: { Cover: { memo: 'one' }, Q3: { memo: 'two' }, Close: { memo: 'three' } },
|
|
288
|
-
links: [{ a: 'Q3', b: 'Close' }],
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
it('carries every card through a whole-deck reorder', () => {
|
|
292
|
-
const order = [3, 1, 0, 2];
|
|
293
|
-
const { state: next, entries } = run(state, deck, { kind: 'reorder', order });
|
|
294
|
-
expect(entries).toEqual(['Close', 'Agenda', 'Cover', 'Q3']);
|
|
295
|
-
expect(memos(next, entries, 4)).toEqual(['three', null, 'one', 'two']);
|
|
296
|
-
expect(next.links).toEqual([{ a: 'Q3', b: 'Close' }]);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('keeps the relative order of several pages moved at once', () => {
|
|
300
|
-
const { state: next, entries } = run(state, deck, { kind: 'moveMany', moving: [0, 2], to: 3 });
|
|
301
|
-
expect(entries).toEqual(['Agenda', 'Close', 'Cover', 'Q3']);
|
|
302
|
-
expect(memos(next, entries, 4)).toEqual([null, 'three', 'one', 'two']);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('drops the cards of every page removed at once', () => {
|
|
306
|
-
const { state: next, entries } = run(state, deck, { kind: 'deleteMany', indices: [0, 2] });
|
|
307
|
-
expect(entries).toEqual(['Agenda', 'Close']);
|
|
308
|
-
expect(memos(next, entries, 2)).toEqual([null, 'three']);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
describe('restore', () => {
|
|
313
|
-
it('puts the page back under its own name, not a blank the deck must explain', () => {
|
|
314
|
-
const { entries } = run({ cards: {}, links: [] }, ['Cover', 'Q3', 'Close'], {
|
|
315
|
-
kind: 'restore',
|
|
316
|
-
index: 1,
|
|
317
|
-
entry: 'Agenda',
|
|
318
|
-
});
|
|
319
|
-
expect(entries).toEqual(deck);
|
|
320
|
-
expect(pageKeys(entries, 4).every(isSettledKey)).toBe(true);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it('lets a card written back under that name show up again', () => {
|
|
324
|
-
const { entries } = run({ cards: {}, links: [] }, ['Cover', 'Q3', 'Close'], {
|
|
325
|
-
kind: 'restore',
|
|
326
|
-
index: 1,
|
|
327
|
-
entry: 'Agenda',
|
|
328
|
-
});
|
|
329
|
-
const state = { cards: { Agenda: { memo: 'back' } }, links: [] };
|
|
330
|
-
expect(memos(state, entries, 4)).toEqual([null, 'back', null, null]);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { Block } from '../blocks/classify.ts';
|
|
3
|
-
import {
|
|
4
|
-
type BlockInfo,
|
|
5
|
-
carryChanges,
|
|
6
|
-
changedPages,
|
|
7
|
-
effectiveBlocks,
|
|
8
|
-
parkedBlocks,
|
|
9
|
-
placeBlock,
|
|
10
|
-
removeChange,
|
|
11
|
-
sanitizeChanges,
|
|
12
|
-
staleChanges,
|
|
13
|
-
unparkBlock,
|
|
14
|
-
} from './changes.ts';
|
|
15
|
-
|
|
16
|
-
const block = (id: string, text = id): Block => ({
|
|
17
|
-
id,
|
|
18
|
-
kind: 'text',
|
|
19
|
-
text,
|
|
20
|
-
loc: null,
|
|
21
|
-
box: { x: 0, y: 0, w: 10, h: 10 },
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const info = (text: string): BlockInfo => ({ kind: 'text', text, loc: null });
|
|
25
|
-
const at = (page: string, before: string | null, id: string) => ({ page, before, block: id });
|
|
26
|
-
|
|
27
|
-
const A = [block('a1', 'Alpha page one'), block('a2', 'Opening content')];
|
|
28
|
-
const B = [block('b1', 'Second page')];
|
|
29
|
-
|
|
30
|
-
describe('placeBlock', () => {
|
|
31
|
-
it('keeps one entry per block', () => {
|
|
32
|
-
let changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
33
|
-
page: 'p2',
|
|
34
|
-
before: null,
|
|
35
|
-
});
|
|
36
|
-
changes = placeBlock(changes, at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
37
|
-
page: 'p3',
|
|
38
|
-
before: null,
|
|
39
|
-
});
|
|
40
|
-
expect(changes).toHaveLength(1);
|
|
41
|
-
expect(changes[0].to).toEqual({ page: 'p3', before: null });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('drops the entry when the block goes back where it was', () => {
|
|
45
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
46
|
-
page: 'p1',
|
|
47
|
-
before: 'a2',
|
|
48
|
-
});
|
|
49
|
-
expect(changes).toEqual([]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('keeps the code when parking', () => {
|
|
53
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), 'parked', '<h1/>');
|
|
54
|
-
expect(changes[0].to).toBe('parked');
|
|
55
|
-
expect(changes[0].code).toBe('<h1/>');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('effectiveBlocks', () => {
|
|
60
|
-
it('reorders inside a page', () => {
|
|
61
|
-
const changes = placeBlock([], at('p1', 'a2', 'a2'), info('Opening content'), {
|
|
62
|
-
page: 'p1',
|
|
63
|
-
before: 'a1',
|
|
64
|
-
});
|
|
65
|
-
expect(effectiveBlocks('p1', A, changes).map((b) => b.id)).toEqual(['a2', 'a1']);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('moves a block to the end of another page', () => {
|
|
69
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
70
|
-
page: 'p2',
|
|
71
|
-
before: null,
|
|
72
|
-
});
|
|
73
|
-
const one = effectiveBlocks('p1', A, changes);
|
|
74
|
-
const two = effectiveBlocks('p2', B, changes);
|
|
75
|
-
expect(one.map((b) => b.id)).toEqual(['a2']);
|
|
76
|
-
expect(two.map((b) => b.id)).toEqual(['b1', 'a1']);
|
|
77
|
-
expect(two[1]).toMatchObject({ pending: true, from: 'p1' });
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('puts the block last when its anchor is gone', () => {
|
|
81
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
82
|
-
page: 'p2',
|
|
83
|
-
before: 'gone',
|
|
84
|
-
});
|
|
85
|
-
expect(effectiveBlocks('p2', B, changes).map((b) => b.id)).toEqual(['b1', 'a1']);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('inserts two blocks moved to the same page in order', () => {
|
|
89
|
-
let changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), { page: 'p2', before: 'b1' });
|
|
90
|
-
changes = placeBlock(changes, at('p3', null, 'c1'), info('c'), { page: 'p2', before: 'b1' });
|
|
91
|
-
expect(effectiveBlocks('p2', B, changes).map((b) => b.id)).toEqual(['a1', 'c1', 'b1']);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('takes a parked block off its page', () => {
|
|
95
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), 'parked');
|
|
96
|
-
expect(effectiveBlocks('p1', A, changes).map((b) => b.id)).toEqual(['a2']);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('parkedBlocks and removeChange', () => {
|
|
101
|
-
it('lists parked blocks in change order', () => {
|
|
102
|
-
let changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), 'parked', 'x');
|
|
103
|
-
changes = placeBlock(changes, at('p2', null, 'b1'), info('b'), 'parked', 'y');
|
|
104
|
-
expect(parkedBlocks(changes).map((p) => p.origin.block)).toEqual(['a1', 'b1']);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('removes one entry by its origin', () => {
|
|
108
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), 'parked');
|
|
109
|
-
expect(removeChange(changes, at('p1', 'a2', 'a1'))).toEqual([]);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('carryChanges', () => {
|
|
114
|
-
it('leaves a reorder alone, because a page key travels with its page', () => {
|
|
115
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), { page: 'p2', before: null });
|
|
116
|
-
const carried = carryChanges(changes, ['p1', 'p2'], ['p2', 'p1'], [1, 0]);
|
|
117
|
-
expect(carried[0].origin.page).toBe('p1');
|
|
118
|
-
expect(carried[0].to).toEqual({ page: 'p2', before: null });
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('follows a duplicated page, whose copy gets a key of its own', () => {
|
|
122
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), 'parked', 'x');
|
|
123
|
-
const carried = carryChanges(changes, ['p1'], ['p1', 'p1#2'], [0, -1]);
|
|
124
|
-
expect(carried).toHaveLength(1);
|
|
125
|
-
expect(carried[0].origin.page).toBe('p1');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('drops a change whose source page was deleted', () => {
|
|
129
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), { page: 'p2', before: null });
|
|
130
|
-
expect(carryChanges(changes, ['p1', 'p2'], ['p2'], [1])).toEqual([]);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('drops a change whose target page was deleted', () => {
|
|
134
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), { page: 'p2', before: null });
|
|
135
|
-
expect(carryChanges(changes, ['p1', 'p2'], ['p1'], [0])).toEqual([]);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('keeps a parked change when its page survives elsewhere', () => {
|
|
139
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), 'parked', 'x');
|
|
140
|
-
const carried = carryChanges(changes, ['p0', 'p1'], ['p1', 'p9'], [1, 0]);
|
|
141
|
-
expect(carried).toHaveLength(1);
|
|
142
|
-
expect(carried[0].origin.page).toBe('p1');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('staleChanges', () => {
|
|
147
|
-
it('flags a block whose text changed on the page', () => {
|
|
148
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), {
|
|
149
|
-
page: 'p2',
|
|
150
|
-
before: null,
|
|
151
|
-
});
|
|
152
|
-
const readOf = (page: string) =>
|
|
153
|
-
page === 'p1' ? [block('a1', 'Edited heading'), block('a2')] : null;
|
|
154
|
-
expect([...staleChanges(changes, readOf)]).toEqual([0]);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('flags a block that is no longer on the page', () => {
|
|
158
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), 'parked', 'x');
|
|
159
|
-
expect([...staleChanges(changes, () => [block('a2')])]).toEqual([0]);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('leaves a change alone when the page cannot be read', () => {
|
|
163
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), 'parked', 'x');
|
|
164
|
-
expect([...staleChanges(changes, () => null)]).toEqual([]);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
describe('changedPages', () => {
|
|
169
|
-
it('counts both ends of a move', () => {
|
|
170
|
-
const changes = placeBlock([], at('p1', 'a2', 'a1'), info('a'), { page: 'p2', before: null });
|
|
171
|
-
expect([...changedPages(changes)].sort()).toEqual(['p1', 'p2']);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('sanitizeChanges', () => {
|
|
176
|
-
it('drops malformed entries and keeps good ones', () => {
|
|
177
|
-
const raw = [
|
|
178
|
-
{
|
|
179
|
-
origin: { page: 'p1', before: null, block: 'a1' },
|
|
180
|
-
block: { kind: 'text', text: 'A', loc: null },
|
|
181
|
-
to: 'parked',
|
|
182
|
-
},
|
|
183
|
-
{ origin: { page: 'p1' }, block: { kind: 'nope', text: 'x' }, to: 'parked' },
|
|
184
|
-
'nonsense',
|
|
185
|
-
null,
|
|
186
|
-
];
|
|
187
|
-
const clean = sanitizeChanges(raw);
|
|
188
|
-
expect(clean).toHaveLength(1);
|
|
189
|
-
expect(clean[0].origin.block).toBe('a1');
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('clips long text and long code', () => {
|
|
193
|
-
const clean = sanitizeChanges([
|
|
194
|
-
{
|
|
195
|
-
origin: { page: 'p1', before: null, block: 'a1' },
|
|
196
|
-
block: { kind: 'text', text: 'x'.repeat(500), loc: null },
|
|
197
|
-
to: 'parked',
|
|
198
|
-
code: 'y'.repeat(9000),
|
|
199
|
-
},
|
|
200
|
-
]);
|
|
201
|
-
expect(clean[0].block.text).toHaveLength(80);
|
|
202
|
-
expect(clean[0].code).toHaveLength(4000);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('keeps at most 200 entries', () => {
|
|
206
|
-
const raw = Array.from({ length: 250 }, (_, i) => ({
|
|
207
|
-
origin: { page: 'p1', before: null, block: `b${i}` },
|
|
208
|
-
block: { kind: 'text', text: `t${i}`, loc: null },
|
|
209
|
-
to: 'parked',
|
|
210
|
-
}));
|
|
211
|
-
expect(sanitizeChanges(raw)).toHaveLength(200);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('unparkBlock', () => {
|
|
216
|
-
it('puts a parked block on a page, keeping its code and saying where it came from', () => {
|
|
217
|
-
const parked = placeBlock(
|
|
218
|
-
[],
|
|
219
|
-
at('p1', 'a2', 'a1'),
|
|
220
|
-
info('Alpha page one'),
|
|
221
|
-
'parked',
|
|
222
|
-
'<h1>x</h1>',
|
|
223
|
-
);
|
|
224
|
-
expect(parked).toHaveLength(1);
|
|
225
|
-
|
|
226
|
-
const moved = unparkBlock(parked, parked[0], { page: 'p2', before: null });
|
|
227
|
-
expect(moved).toHaveLength(1);
|
|
228
|
-
expect(moved[0].to).toEqual({ page: 'p2', before: null });
|
|
229
|
-
expect(moved[0].fromParking).toBe(true);
|
|
230
|
-
expect(moved[0].code).toBe('<h1>x</h1>');
|
|
231
|
-
expect(parkedBlocks(moved)).toHaveLength(0);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('drops the entry when the block goes back where it came from', () => {
|
|
235
|
-
const parked = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), 'parked', 'x');
|
|
236
|
-
expect(unparkBlock(parked, parked[0], { page: 'p1', before: 'a2' })).toEqual([]);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('survives a round trip through the stored form', () => {
|
|
240
|
-
const parked = placeBlock([], at('p1', 'a2', 'a1'), info('Alpha page one'), 'parked', 'x');
|
|
241
|
-
const moved = unparkBlock(parked, parked[0], { page: 'p2', before: null });
|
|
242
|
-
expect(sanitizeChanges(JSON.parse(JSON.stringify(moved)))).toEqual(moved);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { BoardCard } from './cards';
|
|
3
|
-
import { EMPTY_FILTER, isFilterActive, matchesFilter, toggleStatus } from './filter.ts';
|
|
4
|
-
|
|
5
|
-
const card = (over: BoardCard = {}): BoardCard => over;
|
|
6
|
-
|
|
7
|
-
describe('board filter', () => {
|
|
8
|
-
it('keeps everything while no filter is set', () => {
|
|
9
|
-
expect(isFilterActive(EMPTY_FILTER)).toBe(false);
|
|
10
|
-
expect(matchesFilter(undefined, false, EMPTY_FILTER)).toBe(true);
|
|
11
|
-
expect(matchesFilter(card({ status: 'todo' }), false, EMPTY_FILTER)).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('keeps only the chosen statuses', () => {
|
|
15
|
-
const filter = { ...EMPTY_FILTER, statuses: ['done' as const] };
|
|
16
|
-
expect(matchesFilter(card({ status: 'done' }), false, filter)).toBe(true);
|
|
17
|
-
expect(matchesFilter(card({ status: 'doing' }), false, filter)).toBe(false);
|
|
18
|
-
expect(matchesFilter(card(), false, filter)).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('accepts any of several chosen statuses', () => {
|
|
22
|
-
const filter = { ...EMPTY_FILTER, statuses: ['done' as const, 'review' as const] };
|
|
23
|
-
expect(matchesFilter(card({ status: 'review' }), false, filter)).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('narrows to cards carrying a work memo', () => {
|
|
27
|
-
const filter = { ...EMPTY_FILTER, memo: true };
|
|
28
|
-
expect(matchesFilter(card({ memo: 'Q3 numbers' }), false, filter)).toBe(true);
|
|
29
|
-
expect(matchesFilter(card({ title: 'Cover' }), false, filter)).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('narrows to cards with an unhandled comment', () => {
|
|
33
|
-
const filter = { ...EMPTY_FILTER, comments: true };
|
|
34
|
-
expect(matchesFilter(card(), true, filter)).toBe(true);
|
|
35
|
-
expect(matchesFilter(card(), false, filter)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('asks for every set condition at once', () => {
|
|
39
|
-
const filter = { statuses: ['done' as const], memo: true, comments: true };
|
|
40
|
-
expect(matchesFilter(card({ status: 'done', memo: 'x' }), true, filter)).toBe(true);
|
|
41
|
-
expect(matchesFilter(card({ status: 'done', memo: 'x' }), false, filter)).toBe(false);
|
|
42
|
-
expect(matchesFilter(card({ status: 'todo', memo: 'x' }), true, filter)).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('toggles a status on and off again', () => {
|
|
46
|
-
const on = toggleStatus(EMPTY_FILTER, 'done');
|
|
47
|
-
expect(on.statuses).toEqual(['done']);
|
|
48
|
-
expect(toggleStatus(on, 'done').statuses).toEqual([]);
|
|
49
|
-
});
|
|
50
|
-
});
|