aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-16 14:07:12 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-16 14:07:12 -0800
commitddbdf506164613cd68194a1406f6855ae9d7f22c (patch)
treed818a9780a9ff33e5232b4fd44165026442ac457
parent114259aa929c13122156196f270756b03f9f3e95 (diff)
downloadneko-ddbdf506164613cd68194a1406f6855ae9d7f22c.tar.gz
neko-ddbdf506164613cd68194a1406f6855ae9d7f22c.tar.bz2
neko-ddbdf506164613cd68194a1406f6855ae9d7f22c.zip
v3: fix feed toggle from settings page, add navigation tests
When on the settings page and clicking a feed that was previously active, navigate to that feed instead of toggling back to home. The toggle behavior now only applies when already viewing that feed. Added tests for navigating from settings to feeds and tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-rw-r--r--frontend-vanilla/src/main.test.ts34
-rw-r--r--frontend-vanilla/src/main.ts3
2 files changed, 36 insertions, 1 deletions
diff --git a/frontend-vanilla/src/main.test.ts b/frontend-vanilla/src/main.test.ts
index 5bf9fe0..26e8019 100644
--- a/frontend-vanilla/src/main.test.ts
+++ b/frontend-vanilla/src/main.test.ts
@@ -321,6 +321,40 @@ describe('main application logic', () => {
getCurrentRouteSpy.mockRestore();
});
+ it('should navigate to feed when clicking feed from settings page', () => {
+ renderLayout();
+ store.setFeeds([{ _id: 5, title: 'My Feed', url: 'http://test', web_url: 'http://test', category: '' }]);
+ store.setActiveFeed(5); // was viewing this feed before settings
+ renderFeeds();
+
+ const getCurrentRouteSpy = vi.spyOn(router, 'getCurrentRoute').mockReturnValue({ path: '/settings', params: {}, query: new URLSearchParams() });
+ const navigateSpy = vi.spyOn(router, 'navigate');
+
+ const feedLink = document.querySelector('a[data-nav="feed"][data-value="5"]') as HTMLElement;
+ expect(feedLink).not.toBeNull();
+ feedLink.click();
+
+ // Should navigate to feed, not toggle to home (even though feed 5 was active)
+ expect(navigateSpy).toHaveBeenCalledWith('/feed/5', expect.any(Object));
+ getCurrentRouteSpy.mockRestore();
+ });
+
+ it('should navigate to tag when clicking tag from settings page', () => {
+ renderLayout();
+ store.setTags([{ title: 'Tech' } as any]);
+ renderTags();
+
+ const getCurrentRouteSpy = vi.spyOn(router, 'getCurrentRoute').mockReturnValue({ path: '/settings', params: {}, query: new URLSearchParams() });
+ const navigateSpy = vi.spyOn(router, 'navigate');
+
+ const tagLink = document.querySelector('a[data-nav="tag"][data-value="Tech"]') as HTMLElement;
+ expect(tagLink).not.toBeNull();
+ tagLink.click();
+
+ expect(navigateSpy).toHaveBeenCalledWith('/tag/Tech', expect.any(Object));
+ getCurrentRouteSpy.mockRestore();
+ });
+
it('deleteFeed should call API', async () => {
vi.mocked(apiFetch).mockResolvedValueOnce({ ok: true } as Response);
const { deleteFeed } = await import('./main');
diff --git a/frontend-vanilla/src/main.ts b/frontend-vanilla/src/main.ts
index 3dc0574..94f5727 100644
--- a/frontend-vanilla/src/main.ts
+++ b/frontend-vanilla/src/main.ts
@@ -128,7 +128,8 @@ export function attachLayoutListeners() {
} else if (navType === 'feed') {
e.preventDefault();
const feedId = link.getAttribute('data-value')!;
- if (store.activeFeedId === parseInt(feedId)) {
+ const currentRoute = router.getCurrentRoute();
+ if (store.activeFeedId === parseInt(feedId) && currentRoute.path !== '/settings') {
router.navigate('/', currentQuery);
} else {
router.navigate(`/feed/${feedId}`, currentQuery);