test: add Playwright e2e tests for new features and uncovered workflows
High priority (new PR #108 features): - Command palette: open/close, search flows, page navigation, FlowPilot handoff - Fallback branches: add in editor, execute in session runner - Session-to-flow: verify button appears on completed session detail Medium priority (existing features without coverage): - Procedural session: intake form, step-through, completion - Tree editor: troubleshooting and procedural editor load/edit/save - FlowPilot chat: page load, new chat creation - Admin panel: dashboard, user management, settings access Also adds API helpers: createProceduralTree(), createProceduralTreeWithFallbacks() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,138 @@ export async function createTroubleshootingTree(
|
||||
return (await response.json()) as TreeResponse
|
||||
}
|
||||
|
||||
export async function createProceduralTree(
|
||||
api: APIRequestContext,
|
||||
overrides?: Partial<{
|
||||
name: string
|
||||
description: string
|
||||
steps: Array<Record<string, unknown>>
|
||||
intake_form: Array<Record<string, unknown>>
|
||||
}>,
|
||||
) {
|
||||
const treeName = overrides?.name || uniqueName('Playwright Procedural Flow')
|
||||
const steps = overrides?.steps || [
|
||||
{
|
||||
id: 'step-1',
|
||||
type: 'procedure_step',
|
||||
title: 'Verify the server is reachable',
|
||||
description: 'Ping the target server to confirm network connectivity.',
|
||||
content_type: 'action',
|
||||
commands: 'ping -c 4 $server_ip',
|
||||
expected_outcome: 'All 4 packets received with no packet loss.',
|
||||
},
|
||||
{
|
||||
id: 'step-2',
|
||||
type: 'procedure_step',
|
||||
title: 'Check the service status',
|
||||
description: 'Verify the target service is running.',
|
||||
content_type: 'verification',
|
||||
commands: 'systemctl status $service_name',
|
||||
expected_outcome: 'Service shows active (running).',
|
||||
},
|
||||
{
|
||||
id: 'step-3',
|
||||
type: 'procedure_step',
|
||||
title: 'Restart the service if needed',
|
||||
description: 'Restart the service and confirm it comes back up.',
|
||||
content_type: 'action',
|
||||
commands: 'sudo systemctl restart $service_name',
|
||||
expected_outcome: 'Service restarts successfully.',
|
||||
},
|
||||
{ id: 'step-end', type: 'procedure_end', title: 'End' },
|
||||
]
|
||||
const intakeForm = overrides?.intake_form || [
|
||||
{
|
||||
variable_name: 'server_ip',
|
||||
label: 'Server IP Address',
|
||||
field_type: 'text',
|
||||
required: true,
|
||||
placeholder: 'e.g., 10.1.50.22',
|
||||
display_order: 1,
|
||||
},
|
||||
{
|
||||
variable_name: 'service_name',
|
||||
label: 'Service Name',
|
||||
field_type: 'text',
|
||||
required: true,
|
||||
placeholder: 'e.g., nginx',
|
||||
display_order: 2,
|
||||
},
|
||||
]
|
||||
|
||||
const response = await api.post('trees', {
|
||||
data: {
|
||||
name: treeName,
|
||||
description: overrides?.description || 'Playwright-created procedural flow',
|
||||
category: 'Playwright',
|
||||
tree_type: 'procedural',
|
||||
tree_structure: { steps },
|
||||
intake_form: intakeForm,
|
||||
status: 'published',
|
||||
},
|
||||
})
|
||||
|
||||
expect(response.ok()).toBeTruthy()
|
||||
return (await response.json()) as TreeResponse
|
||||
}
|
||||
|
||||
export async function createProceduralTreeWithFallbacks(
|
||||
api: APIRequestContext,
|
||||
overrides?: Partial<{ name: string }>,
|
||||
) {
|
||||
const treeName = overrides?.name || uniqueName('Playwright Fallback Flow')
|
||||
|
||||
const response = await api.post('trees', {
|
||||
data: {
|
||||
name: treeName,
|
||||
description: 'Procedural flow with fallback branches for Playwright testing',
|
||||
category: 'Playwright',
|
||||
tree_type: 'procedural',
|
||||
tree_structure: {
|
||||
steps: [
|
||||
{
|
||||
id: 'step-1',
|
||||
type: 'procedure_step',
|
||||
title: 'Clear the DNS cache',
|
||||
description: 'Flush the local DNS resolver cache.',
|
||||
content_type: 'action',
|
||||
commands: 'ipconfig /flushdns',
|
||||
expected_outcome: 'DNS cache flushed successfully.',
|
||||
fallback_steps: [
|
||||
{
|
||||
id: 'fb-1a',
|
||||
type: 'procedure_step',
|
||||
title: 'Restart DNS Client service',
|
||||
description: 'If flushing DNS did not help, restart the DNS Client service.',
|
||||
},
|
||||
{
|
||||
id: 'fb-1b',
|
||||
type: 'procedure_step',
|
||||
title: 'Check DNS server configuration',
|
||||
description: 'Verify the DNS server addresses are correct in network settings.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'step-2',
|
||||
type: 'procedure_step',
|
||||
title: 'Verify DNS resolution',
|
||||
description: 'Test that names resolve correctly.',
|
||||
content_type: 'verification',
|
||||
commands: 'nslookup google.com',
|
||||
expected_outcome: 'Name resolves to an IP address.',
|
||||
},
|
||||
{ id: 'step-end', type: 'procedure_end', title: 'End' },
|
||||
],
|
||||
},
|
||||
status: 'published',
|
||||
},
|
||||
})
|
||||
|
||||
expect(response.ok()).toBeTruthy()
|
||||
return (await response.json()) as TreeResponse
|
||||
}
|
||||
|
||||
export async function createSession(
|
||||
api: APIRequestContext,
|
||||
treeId: string,
|
||||
|
||||
Reference in New Issue
Block a user