aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/App.test.tsx
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-12 21:50:56 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-12 21:50:56 -0800
commit42f1b4de384bcbbdab3b80d8e5cc53b36fcffd50 (patch)
tree3a5aab90607131231ec68367f8cc00425d7dc516 /frontend/src/App.test.tsx
parent9db2500fb340ef304c0f15f4379bc33589df9a63 (diff)
downloadneko-42f1b4de384bcbbdab3b80d8e5cc53b36fcffd50.tar.gz
neko-42f1b4de384bcbbdab3b80d8e5cc53b36fcffd50.tar.bz2
neko-42f1b4de384bcbbdab3b80d8e5cc53b36fcffd50.zip
Implement frontend login logic with >90% coverage
Diffstat (limited to 'frontend/src/App.test.tsx')
-rw-r--r--frontend/src/App.test.tsx30
1 files changed, 26 insertions, 4 deletions
diff --git a/frontend/src/App.test.tsx b/frontend/src/App.test.tsx
index f1572a7..8e3d805 100644
--- a/frontend/src/App.test.tsx
+++ b/frontend/src/App.test.tsx
@@ -1,10 +1,32 @@
-import { render, screen } from '@testing-library/react';
+import { render, screen, waitFor } from '@testing-library/react';
import App from './App';
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
describe('App', () => {
- it('renders heading', () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ global.fetch = vi.fn();
+ });
+
+ it('renders login on initial load (unauthenticated)', async () => {
+ (global.fetch as any).mockResolvedValueOnce({
+ ok: false,
+ });
+ window.history.pushState({}, 'Test page', '/v2/login');
render(<App />);
- expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument(); // Adjust based on actual App content
+ expect(screen.getByRole('button', { name: /login/i })).toBeInTheDocument();
+ });
+
+ it('renders dashboard when authenticated', async () => {
+ (global.fetch as any).mockResolvedValueOnce({
+ ok: true,
+ });
+
+ window.history.pushState({}, 'Test page', '/v2/');
+ render(<App />);
+
+ await waitFor(() => {
+ expect(screen.getByText(/dashboard/i)).toBeInTheDocument();
+ });
});
});