import { test, expect } from '@playwright/test'; import { readFileSync } from 'node:fs'; import path from 'node:path'; const demo = JSON.parse(readFileSync(path.resolve(__dirname, '../../examples/project-definitions/valid-release-demo.json'), 'utf8')); test('deterministic launcher, dependent data, dashboard, and save/reload workflow', async ({ page, request }) => { test.setTimeout(60_000); const name = `Slice 6 E2E ${Date.now()}`; const document = structuredClone(demo); document.project.name = name; await page.goto('/'); const setup = page.getByRole('heading', { name: 'Set up Conductor' }); if (await setup.isVisible().catch(() => false)) { await page.getByLabel('Username').fill('e2e-admin'); await page.getByLabel('Display name').fill('E2E Administrator'); await page.getByLabel('Password', { exact: true }).fill('e2e-test-password-1234'); await page.getByLabel('Confirm password').fill('e2e-test-password-1234'); await page.getByRole('button', { name: 'Create administrator' }).click(); } else if (await page.getByRole('heading', { name: 'Sign in to Conductor' }).isVisible().catch(() => false)) { await page.getByLabel('Username').fill('e2e-admin'); await page.getByLabel('Password').fill('e2e-test-password-1234'); await page.getByRole('button', { name: 'Sign in', exact: true }).click(); } await expect(page.getByText('E2E Administrator')).toBeVisible(); const cookies = await page.context().cookies(); const cookieHeader = cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join('; '); const csrf = cookies.find((cookie) => cookie.name === 'conductor_csrf')?.value; expect(csrf).toBeTruthy(); const authHeaders = { Cookie: cookieHeader, 'X-CSRF-Token': csrf! }; const created = await request.post('http://127.0.0.1:4000/api/projects', { headers: authHeaders, data: { name, description: document.project.description, project_json: JSON.stringify(document) }, }); expect(created.status()).toBe(201); const row = await created.json(); try { await page.getByRole('button', { name: 'Visual Editor', exact: true }).click(); await page.getByRole('button', { name: 'Load', exact: true }).click(); await page.getByRole('button', { name: new RegExp(name) }).click(); await expect(page.getByTitle('Click to rename project')).toContainText(name); await page.getByRole('button', { name: 'Preview', exact: true }).click(); await expect(page.getByTestId('page-load-status')).toContainText('completed', { ignoreCase: true }); const environment = page.locator('select').first(); await expect(environment.locator('option')).toHaveCount(3); await environment.selectOption('prod'); await page.locator('input[type="text"]').first().fill('bravo.example'); await page.getByRole('button', { name: 'Launch workflow', exact: true }).click(); await expect(page.getByText('req-demo-001', { exact: true })).toBeVisible(); await expect(page.locator('pre').filter({ hasText: 'bravo.example' })).toBeVisible(); await page.getByRole('button', { name: 'Refresh inventory', exact: true }).click(); await expect(page.getByRole('cell', { name: 'srv-202' })).toBeVisible(); await page.getByRole('cell', { name: 'srv-202' }).click(); await expect(page.locator('pre').filter({ hasText: 'srv-202' })).toBeVisible(); await page.getByRole('button', { name: 'Visual Editor', exact: true }).click(); await page.getByRole('button', { name: 'Update', exact: true }).click(); await expect(page.getByText(`Project "${name}" saved.`)).toBeVisible(); await page.reload(); await page.getByRole('button', { name: 'Visual Editor', exact: true }).click(); await page.getByRole('button', { name: 'Load', exact: true }).click(); await page.getByRole('button', { name: new RegExp(name) }).click(); await page.getByRole('button', { name: 'Preview', exact: true }).click(); await expect(page.getByRole('button', { name: 'Launch workflow', exact: true })).toBeVisible(); } finally { await request.delete(`http://127.0.0.1:4000/api/projects/${row.id}`, { headers: authHeaders }); await request.delete('http://127.0.0.1:4000/api/executions', { headers: authHeaders }); } });