fix(lists): add items offline via the outbox; recognisable input field
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m34s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m34s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ab97638361
commit
28ebbe7263
9 files changed
+152
-21
No files matched your search
@@ -47,3 +47,28 @@ describe('outbox', () => {
|
||||
expect(isCacheablePath('/api/v1/export/markdown')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('list items added offline', () => {
|
||||
beforeEach(() => localStorage.clear());
|
||||
|
||||
it('show up as stand-ins and follow edits until they are sent', async () => {
|
||||
const { pendingListItems, updateQueued, dropQueued, OFFLINE_ITEM_PREFIX } = await import('../offline');
|
||||
const milk = enqueue('POST', '/api/v1/lists/lst_1/items', { content: 'Hafermilch', category: 'Kühlregal', quantity: '' });
|
||||
const bread = enqueue('POST', '/api/v1/lists/lst_2/items', { content: 'Brot', category: '', quantity: '1' });
|
||||
enqueue('POST', '/api/v1/inbox', { content: 'kein Listeneintrag' });
|
||||
|
||||
let items = pendingListItems();
|
||||
expect(items.map((i) => [i.listId, i.content])).toEqual([
|
||||
['lst_1', 'Hafermilch'],
|
||||
['lst_2', 'Brot'],
|
||||
]);
|
||||
expect(items[0].id).toBe(OFFLINE_ITEM_PREFIX + milk.id);
|
||||
|
||||
updateQueued(milk.id, { quantity: '2' });
|
||||
dropQueued(bread.id);
|
||||
items = pendingListItems();
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0].quantity).toBe('2');
|
||||
expect(getOutbox()).toHaveLength(2); // the inbox entry stays
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user