1
0

feat: router, tab shell, setup and login pages

This commit is contained in:
2026-08-29 19:50:10 +02:00
parent fdf200a960
commit bda43ce237
10 changed files with 413 additions and 7 deletions

View File

@@ -1,10 +1,31 @@
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, waitFor } from '@testing-library/react'
import App from '../src/App'
const fetchMock = vi.fn()
beforeEach(() => {
fetchMock.mockReset()
vi.stubGlobal('fetch', fetchMock)
window.history.replaceState(null, '', '/')
})
function json(status: number, body: unknown) {
return new Response(JSON.stringify(body), {
status,
headers: { 'content-type': 'application/json' },
})
}
describe('App', () => {
it('renders the app title', () => {
it('renders the app title', async () => {
fetchMock.mockImplementation((url: string) => {
if (url === '/api/setup') return Promise.resolve(json(200, { needed: false }))
if (url === '/api/me')
return Promise.resolve(json(200, { user: { id: 1, username: 'sam', isAdmin: true } }))
return Promise.resolve(json(404, {}))
})
render(<App />)
expect(screen.getByRole('heading', { name: 'record-shop' })).toBeTruthy()
await waitFor(() => expect(screen.getByRole('heading', { name: 'record-shop' })).toBeTruthy())
})
})