feat: scaffold React frontend with login/register UI

This commit is contained in:
Indiana
2026-07-20 17:42:44 +00:00
parent 852a630fe0
commit 6bcdf83c4d
13 changed files with 3569 additions and 0 deletions

31
frontend/src/App.test.tsx Normal file
View File

@@ -0,0 +1,31 @@
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { describe, expect, it, vi } from 'vitest'
import App from './App'
import * as api from './api'
vi.mock('./api')
describe('App', () => {
it('renders the Quantumancy title', async () => {
vi.mocked(api.me).mockRejectedValue(new Error('not authenticated'))
render(<App />)
await waitFor(() => expect(screen.getByText('Quantumancy')).toBeInTheDocument())
})
it('logs in and shows the contact-established state', async () => {
vi.mocked(api.me).mockRejectedValue(new Error('not authenticated'))
vi.mocked(api.login).mockResolvedValue({ id: '1', username: 'medium1' })
render(<App />)
await waitFor(() => expect(screen.getByText('Quantumancy')).toBeInTheDocument())
await userEvent.type(screen.getByLabelText('Username'), 'medium1')
await userEvent.type(screen.getByLabelText('Password'), 'spookyspooky')
await userEvent.click(screen.getByRole('button', { name: 'Enter' }))
await waitFor(() =>
expect(screen.getByText('Contact established as medium1.')).toBeInTheDocument(),
)
})
})