- Added shared styles for UI components in `src/components/styles.ts`. - Created configuration constants in `src/lib/config.ts`. - Implemented date formatting and greeting functions in `src/lib/dates.ts` and corresponding tests in `src/lib/dates.test.ts`. - Developed incident management functions in `src/lib/incidents.ts` with tests in `src/lib/incidents.test.ts`. - Established navigation structure in `src/lib/navigation.ts`. - Seeded demo data for incidents and users in `src/lib/seed.ts`. - Defined tone classes for UI elements in `src/lib/tones.ts`. - Created type definitions for incidents and related entities in `src/lib/types.ts`. - Set up main application entry point in `src/main.tsx`. - Developed various pages including About, Analytics, Incidents, Locations, Overview, and Report Incident. - Configured testing setup in `src/test/setup.ts` and TypeScript configurations. - Integrated Vite for development and testing with appropriate plugins.
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
|
|
test('navigates between the main pages', async ({ page, isMobile }) => {
|
|
await page.goto('/')
|
|
await expect(page.getByRole('heading', { level: 1 })).toContainText('Jordan')
|
|
|
|
for (const name of ['Incidents', 'Locations', 'Analytics']) {
|
|
if (isMobile) await page.getByRole('button', { name: 'Open menu' }).click()
|
|
await page.getByRole('navigation').getByRole('link', { name }).click()
|
|
await expect(page.getByRole('heading', { level: 1, name })).toBeVisible()
|
|
}
|
|
})
|
|
|
|
test('reports an incident', async ({ page }) => {
|
|
await page.goto('/report')
|
|
await page.getByLabel('Incident title').fill('Blocked fire exit in warehouse')
|
|
await page.getByLabel('Specific location').fill('North exit')
|
|
await page.getByRole('button', { name: /submit report/i }).click()
|
|
|
|
await expect(page).toHaveURL(/\/incidents$/)
|
|
await expect(page.getByText('Blocked fire exit in warehouse')).toBeVisible()
|
|
})
|
|
|
|
test('loads bundled fonts without third-party requests', async ({ page }) => {
|
|
const external: string[] = []
|
|
page.on('request', (request) => {
|
|
if (!request.url().startsWith('http://localhost')) external.push(request.url())
|
|
})
|
|
await page.goto('/')
|
|
await page.evaluate(() => document.fonts.ready)
|
|
expect(await page.evaluate(() => document.fonts.check('16px "DM Sans Variable"'))).toBe(true)
|
|
expect(external).toEqual([])
|
|
})
|