- Add permissions logic for status options in corrective actions. - Create tests for permissions functionality. - Implement queries for user authentication and actions management. - Develop Actions page to display and manage corrective actions. - Create authentication pages for login, setup, and password reset. - Add IncidentDetail page to view incident details and associated actions. - Implement Settings page for user management and password changes.
21 lines
1.1 KiB
TypeScript
21 lines
1.1 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' } }))
|
|
await ok(await api.post(`/api/sites/${site.id}/areas`, { data: { name: 'Press Shop', kind: 'building' } }))
|
|
for (const role of ['supervisor', 'reporter'] as const) {
|
|
await ok(await api.post('/api/users', { data: { ...users[role], role, password: PASSWORD } }))
|
|
}
|
|
await api.dispose()
|
|
}
|