MAESTRO: add e2e flow check for analysis

This commit is contained in:
Mariusz Banach
2026-02-18 05:18:55 +01:00
parent 40d2103e3c
commit cdee156896
3 changed files with 65 additions and 19 deletions

View File

@@ -29,7 +29,7 @@ This phase performs final integration, accessibility audit, responsive testing,
## Completion ## Completion
- [ ] Complete flow works end-to-end: paste headers → configure tests → analyse → view report → export - [x] Complete flow works end-to-end: paste headers → configure tests → analyse → view report → export. Notes: replaced Playwright example spec with end-to-end flow test (paste + configure + analyse + report + export), adjusted Playwright webServer ports/CORS for local 3100 runs, ran `npx playwright test e2e/example.spec.ts --project=chromium`.
- [ ] File drop flow works: drop EML → auto-populate → analyse → report - [ ] File drop flow works: drop EML → auto-populate → analyse → report
- [ ] Cache flow works: analyse → reload → see cached results → clear cache - [ ] Cache flow works: analyse → reload → see cached results → clear cache
- [ ] Rate limiting flow works: exceed limit → CAPTCHA modal → solve → retry succeeds - [ ] Rate limiting flow works: exceed limit → CAPTCHA modal → solve → retry succeeds

View File

@@ -1,18 +1,61 @@
import { test, expect } from '@playwright/test'; import { test, expect } from "@playwright/test";
import fs from "fs/promises";
import path from "path";
test('has title', async ({ page }) => { const headersPath = path.resolve(__dirname, "../../backend/tests/fixtures/sample_headers.txt");
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring. test("complete analysis flow from paste to export", async ({ page }) => {
await expect(page).toHaveTitle(/Playwright/); const headers = await fs.readFile(headersPath, "utf8");
});
await page.goto("http://localhost:3100");
test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/'); const headerInput = page.getByRole("textbox", { name: "Header Input" });
await headerInput.fill(headers);
// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click(); const decodeToggle = page.getByTestId("toggle-decode-all");
await decodeToggle.click();
// Expects page to have a heading with the name of Installation. await expect(decodeToggle).toHaveAttribute("aria-checked", "true");
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
const firstCheckbox = page.locator('[data-testid^="test-checkbox-"]').first();
await firstCheckbox.scrollIntoViewIfNeeded();
await firstCheckbox.waitFor({ state: "visible" });
await firstCheckbox.check();
const checkboxTestId = await firstCheckbox.getAttribute("data-testid");
const testId = checkboxTestId?.replace("test-checkbox-", "");
expect(testId).toBeTruthy();
await page.getByRole("button", { name: "Analyse Headers" }).click();
const reportContainer = page.getByTestId("report-container");
await reportContainer.waitFor({ state: "visible", timeout: 30000 });
if (testId) {
await expect(page.getByTestId(`test-result-card-${testId}`)).toBeVisible();
}
const [jsonDownload] = await Promise.all([
page.waitForEvent("download"),
page.getByTestId("report-export-json").click(),
]);
expect(jsonDownload.suggestedFilename()).toBe("analysis-report.json");
const jsonPath = await jsonDownload.path();
if (!jsonPath) {
throw new Error("JSON export did not provide a download path.");
}
const jsonContents = await fs.readFile(jsonPath, "utf8");
const parsed = JSON.parse(jsonContents) as { metadata?: Record<string, unknown> };
expect(parsed.metadata).toBeTruthy();
const [htmlDownload] = await Promise.all([
page.waitForEvent("download"),
page.getByTestId("report-export-html").click(),
]);
expect(htmlDownload.suggestedFilename()).toBe("analysis-report.html");
const htmlPath = await htmlDownload.path();
if (!htmlPath) {
throw new Error("HTML export did not provide a download path.");
}
const htmlContents = await fs.readFile(htmlPath, "utf8");
expect(htmlContents).toContain("<title>Email Header Analysis Report</title>");
}); });

View File

@@ -73,14 +73,17 @@ export default defineConfig({
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
webServer: [ webServer: [
{ {
command: 'python -m uvicorn backend.app.main:app --port 8000', command: 'python -m uvicorn app.main:app --app-dir backend --port 8000',
url: 'http://localhost:8000', url: 'http://localhost:8000',
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
cwd: '..', cwd: '..',
env: {
WHA_CORS_ORIGINS: '["http://localhost:3100"]',
},
}, },
{ {
command: 'npm run dev -- --port 3000', command: 'npm run dev -- --port 3100',
url: 'http://localhost:3000', url: 'http://localhost:3100',
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
}, },
], ],