import { expect, test } from '@playwright/test' import { createAuthenticatedApiContext, createProceduralTree, disposeApiContext, uniqueName, } from './helpers/api' test.describe('procedural session smoke tests', () => { test('can start and step through a procedural session with intake form', async ({ page }) => { const api = await createAuthenticatedApiContext() const tree = await createProceduralTree(api, { name: uniqueName('PW Procedural Session Flow'), }) try { await page.goto(`/flows/${tree.id}/navigate`) await expect(page.getByRole('heading', { name: tree.name })).toBeVisible({ timeout: 10000 }) // Fill intake form await page.getByLabel('Server IP Address').fill('10.1.50.22') await page.getByLabel('Service Name').fill('nginx') // Start the session await page.getByRole('button', { name: /Start/ }).click() // Should see the first step await expect(page.getByText('Verify the server is reachable')).toBeVisible({ timeout: 5000 }) // Mark first step complete and advance const completeButton = page.getByRole('button', { name: /Complete|Next|Mark/ }).first() await completeButton.click() // Should advance to second step await expect(page.getByText('Check the service status')).toBeVisible({ timeout: 5000 }) } finally { await disposeApiContext(api) } }) test('can complete a full procedural session end to end', async ({ page }) => { const api = await createAuthenticatedApiContext() const tree = await createProceduralTree(api, { name: uniqueName('PW Full Procedural Flow'), steps: [ { id: 'step-1', type: 'procedure_step', title: 'Single step procedure', description: 'Just one step to complete.', content_type: 'action', }, { id: 'step-end', type: 'procedure_end', title: 'End' }, ], intake_form: [], }) try { await page.goto(`/flows/${tree.id}/navigate`) await expect(page.getByRole('heading', { name: tree.name })).toBeVisible({ timeout: 10000 }) // Start session (no intake form) await page.getByRole('button', { name: /Start/ }).click() // Should see the single step await expect(page.getByText('Single step procedure')).toBeVisible({ timeout: 5000 }) // Complete the step const completeButton = page.getByRole('button', { name: /Complete|Next|Mark/ }).first() await completeButton.click() // Should reach completion — look for completion indicators await expect(page.getByText(/Complete|Finished|Summary/i)).toBeVisible({ timeout: 5000 }) } finally { await disposeApiContext(api) } }) })