- Implemented Form301 component for displaying OSHA Form 301 equivalent, including employee and case information. - Created Osha component to manage OSHA recordkeeping, including tabs for 300 Log, 300A Summary, Hours & rates, and Submit to OSHA. - Added functionality for printing and downloading CSV files for OSHA submissions. - Integrated loading and error handling states for data fetching.
26 lines
1.4 KiB
TypeScript
26 lines
1.4 KiB
TypeScript
import { request } from '@playwright/test'
|
|
import { baseURL } from '../playwright.config'
|
|
import { PASSWORD, users } from './fixtures'
|
|
|
|
/** Creates the workspace, a site and one user per role in the fresh server. */
|
|
export default async function globalSetup() {
|
|
const api = await request.newContext({ baseURL })
|
|
// oxlint-disable-next-line typescript/no-explicit-any -- loosely typed setup calls
|
|
const ok = async (res: Awaited<ReturnType<typeof api.post>>): Promise<any> => {
|
|
if (!res.ok()) throw new Error(`${res.url()} → ${res.status()} ${await res.text()}`)
|
|
return res.json()
|
|
}
|
|
await ok(await api.post('/api/setup', { data: { organizationName: 'E2E Plant', ...users.admin, password: PASSWORD } }))
|
|
const { site } = await ok(await api.post('/api/sites', { data: { name: 'Main Plant' } }))
|
|
const { area } = await ok(await api.post(`/api/sites/${site.id}/areas`, { data: { name: 'Press Shop', kind: 'building' } }))
|
|
const { kiosk } = await ok(await api.post('/api/kiosks', { data: { name: 'Canteen tablet' }, headers: { origin: baseURL } }))
|
|
// Shared with the test workers
|
|
process.env.E2E_KIOSK_TOKEN = kiosk.token
|
|
process.env.E2E_SITE_ID = site.id
|
|
process.env.E2E_AREA_ID = area.id
|
|
for (const role of ['supervisor', 'reporter', 'safety_manager'] as const) {
|
|
await ok(await api.post('/api/users', { data: { ...users[role], role, password: PASSWORD } }))
|
|
}
|
|
await api.dispose()
|
|
}
|