aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src/main.test.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-28 16:17:43 -0800
committerGitHub <noreply@github.com>2026-02-28 16:17:43 -0800
commit5785d164eb54ae87d2f831a649fb1d4d10cca970 (patch)
tree020cbd30711b1ee7eea3d077389ec381eded4a4e /frontend-vanilla/src/main.test.ts
parent81c35390da64a061a9a8867c497eb992f05340bc (diff)
parentdf5e7d93963f0256285b13ddf750761930797e78 (diff)
downloadneko-5785d164eb54ae87d2f831a649fb1d4d10cca970.tar.gz
neko-5785d164eb54ae87d2f831a649fb1d4d10cca970.tar.bz2
neko-5785d164eb54ae87d2f831a649fb1d4d10cca970.zip
Merge pull request #24 from adammathes/claude/agents-file-mobile-stars-2nj6yHEADmaster
Fix item ID type coercion in star/read toggles
Diffstat (limited to 'frontend-vanilla/src/main.test.ts')
-rw-r--r--frontend-vanilla/src/main.test.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/frontend-vanilla/src/main.test.ts b/frontend-vanilla/src/main.test.ts
index 2715b5c..2d74ea5 100644
--- a/frontend-vanilla/src/main.test.ts
+++ b/frontend-vanilla/src/main.test.ts
@@ -188,6 +188,27 @@ describe('main application logic', () => {
}));
});
+ it('should handle star toggle when _id is a string (API returns string)', async () => {
+ renderLayout();
+ // The Go API returns _id as a string due to json:",string" tag.
+ // fetchItems normalizes this, but verify the flow works end-to-end.
+ const mockItem = { _id: "5" as any, title: 'String ID Item', starred: true, publish_date: '2023-01-01' } as any;
+ store.setItems([mockItem]);
+ renderItems();
+
+ vi.mocked(apiFetch).mockResolvedValue({ ok: true } as Response);
+
+ const starBtn = document.querySelector('[data-action="toggle-star"]') as HTMLElement;
+ starBtn.click();
+
+ // parseInt in the click handler produces number 5, but store has string "5".
+ // This should still work because toggleStar finds the item.
+ expect(apiFetch).toHaveBeenCalledWith(expect.stringContaining('/api/item/5'), expect.objectContaining({
+ method: 'PUT',
+ body: expect.stringContaining('"starred":false')
+ }));
+ });
+
it('should handle theme change in settings', () => {
renderLayout();
renderSettings();