aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/Navigation.test.tsx
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-15 14:22:31 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-15 14:22:31 -0800
commitcc74caf9d9b66711f4aab793966c1f8a5663e1b9 (patch)
tree8602af15cd7e36f1ce1f8a5c9f6753b7f108adbe /frontend/src/Navigation.test.tsx
parent9f64d3a18eb92c4845dac38265acecef2931490b (diff)
downloadneko-cc74caf9d9b66711f4aab793966c1f8a5663e1b9.tar.gz
neko-cc74caf9d9b66711f4aab793966c1f8a5663e1b9.tar.bz2
neko-cc74caf9d9b66711f4aab793966c1f8a5663e1b9.zip
Switch to HashRouter to fix page reload issues (NK-hy162w)
Diffstat (limited to 'frontend/src/Navigation.test.tsx')
-rw-r--r--frontend/src/Navigation.test.tsx45
1 files changed, 28 insertions, 17 deletions
diff --git a/frontend/src/Navigation.test.tsx b/frontend/src/Navigation.test.tsx
index 7d73249..b0bae86 100644
--- a/frontend/src/Navigation.test.tsx
+++ b/frontend/src/Navigation.test.tsx
@@ -27,7 +27,7 @@ describe('Navigation and Filtering', () => {
it('preserves "all" filter when clicking a feed', async () => {
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 1024 });
- window.history.pushState({}, '', '/');
+ window.history.pushState({}, '', '/#/');
render(<App />);
// Wait for sidebar to load and feeds section to be visible
@@ -47,7 +47,9 @@ describe('Navigation and Filtering', () => {
fireEvent.click(allFilter);
// Verify URL has filter=all
- expect(window.location.search).toContain('filter=all');
+ await waitFor(() => {
+ expect(window.location.hash).toContain('filter=all');
+ });
// Click Feed 1
const feed1Link = screen.getByText('Feed 1');
@@ -55,8 +57,8 @@ describe('Navigation and Filtering', () => {
// Verify URL is /feed/1?filter=all (or similar)
await waitFor(() => {
- expect(window.location.pathname).toContain('/feed/1');
- expect(window.location.search).toContain('filter=all');
+ expect(window.location.hash).toContain('/feed/1');
+ expect(window.location.hash).toContain('filter=all');
});
// Click Feed 2
@@ -65,48 +67,57 @@ describe('Navigation and Filtering', () => {
// Verify URL is /feed/2?filter=all
await waitFor(() => {
- expect(window.location.pathname).toContain('/feed/2');
- expect(window.location.search).toContain('filter=all');
+ expect(window.location.hash).toContain('/feed/2');
+ expect(window.location.hash).toContain('filter=all');
});
});
it('highlights the correct filter link', async () => {
- window.history.pushState({}, '', '/');
+ window.history.pushState({}, '', '/#/');
render(<App />);
await waitFor(() => {
- expect(screen.getByText('unread')).toHaveClass('active');
+ const unreadLink = screen.getByText('unread');
+ expect(unreadLink.className).toContain('active');
});
fireEvent.click(screen.getByText('all'));
await waitFor(() => {
- expect(screen.getByText('all')).toHaveClass('active');
- expect(screen.getByText('unread')).not.toHaveClass('active');
+ const allLink = screen.getByText('all');
+ const unreadLink = screen.getByText('unread');
+ expect(allLink.className).toContain('active');
+ expect(unreadLink.className).not.toContain('active');
});
});
it('highlights "unread" as active even when on a feed page without filter param', async () => {
- window.history.pushState({}, '', '/feed/1');
+ window.history.pushState({}, '', '/#/feed/1');
render(<App />);
await waitFor(() => {
- expect(screen.getByText('unread')).toHaveClass('active');
+ const unreadLink = screen.getByText('unread');
+ expect(unreadLink.className).toContain('active');
});
});
it('preserves search query when clicking a feed', async () => {
- window.history.pushState({}, '', '/?q=linux');
+ window.history.pushState({}, '', '/#/?q=linux');
render(<App />);
- await screen.findByRole('heading', { name: /Feeds/i, level: 4 });
- fireEvent.click(screen.getByRole('heading', { name: /Feeds/i, level: 4 }));
+ // Wait for load
+ await waitFor(() => {
+ expect(screen.queryByText(/Loading feeds/i)).not.toBeInTheDocument();
+ });
+
+ const feedsHeader = await screen.findByRole('heading', { name: /Feeds/i, level: 4 });
+ fireEvent.click(feedsHeader);
await screen.findByText('Feed 1');
fireEvent.click(screen.getByText('Feed 1'));
await waitFor(() => {
- expect(window.location.pathname).toContain('/feed/1');
- expect(window.location.search).toContain('q=linux');
+ expect(window.location.hash).toContain('/feed/1');
+ expect(window.location.hash).toContain('q=linux');
});
});
});