test(e2e): repair investigation textarea selectors

This commit is contained in:
2026-08-15 13:55:59 +01:00
parent a599922d9f
commit 2561b5d720
5 changed files with 38 additions and 36 deletions
+13 -13
View File
@@ -59,7 +59,7 @@ async function waitForWorkspaceReady(page, options = {}) {
* Returns { success, hasError } for test assertions.
*/
async function submitAnswer(page, text) {
const textarea = page.locator('textarea[placeholder*=Answer]');
const textarea = page.locator('[data-testid="response-textarea"]');
if (!(await textarea.isVisible({ timeout: 3000 }).catch(() => false))) {
return { success: false, hasError: false };
}
@@ -90,7 +90,7 @@ test("long investigation — European market entry with 4 answer turns", async (
window.__MOCK_SCENARIO = "complete";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(LONG_INVESTIGATION.centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -133,7 +133,7 @@ test("contradiction fixture — opposing recommendations in investigation card",
window.__MOCK_SCENARIO = ""; // use default
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(CONTRADICTION.centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -173,7 +173,7 @@ test("diagnosis scenario — churn investigation renders correctly", async ({ pa
window.__MOCK_SCENARIO = "";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(DIAGNOSIS.centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -204,7 +204,7 @@ test("comparison scenario — product rating nodes render with edges", async ({
window.__MOCK_SCENARIO = "";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(COMPARISON.centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -218,7 +218,7 @@ test("comparison scenario — product rating nodes render with edges", async ({
if (result.success) {
// Second turn's answer textarea should appear
const answerTextarea = page.locator('textarea[placeholder*=Answer]');
const answerTextarea = page.locator('[data-testid="response-textarea"]');
expect(await answerTextarea.isVisible()).toBe(true);
// Submit second answer
@@ -240,7 +240,7 @@ test("prioritisation scenario — team relocation yields ranked options", async
window.__MOCK_SCENARIO = "";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(PRIORITISATION.centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -270,7 +270,7 @@ test("rapid successive updates maintain correct loading-state cycling", async ({
window.__MOCK_SCENARIO = "";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(LONG_INVESTIGATION.centralStatement); // use long scenario central statement
await page.getByRole("button", { name: "Analyse" }).click();
@@ -302,19 +302,19 @@ test("answer textarea placeholder updates between turns", async ({ page }) => {
window.__MOCK_SCENARIO = "";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(INVESTIGATION_SCENARIOS[0].centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
// Initial workspace should have an answer textarea with a question-related placeholder
const answerTextarea = page.locator('textarea[placeholder*=Answer]');
const answerTextarea = page.locator('[data-testid="response-textarea"]');
await expect(answerTextarea).toBeVisible({ timeout: 10_000 });
// Submit first answer
await submitAnswer(page, INVESTIGATION_SCENARIOS[0].answerSequence[0]?.text || "");
// After update, new question textarea should be present with potentially different placeholder
const updatedTextarea = page.locator('textarea[placeholder*=Answer]');
const updatedTextarea = page.locator('[data-testid="response-textarea"]');
await expect(updatedTextarea).toBeVisible();
// The workspace card should still display the current investigation context
@@ -334,7 +334,7 @@ test("terminal state renders without answer textarea", async ({ page }) => {
window.__MOCK_SCENARIO = "complete";
});
const textarea = page.locator("textarea[placeholder*=Describe]");
const textarea = page.locator('[data-testid="scenario-textarea"]');
await textarea.fill(SCENARIO_LOOKUP["Happy path — complete investigation"].centralStatement);
await page.getByRole("button", { name: "Analyse" }).click();
@@ -344,7 +344,7 @@ test("terminal state renders without answer textarea", async ({ page }) => {
await expect(page.locator('[data-testid="reasoning-workspace"]')).toBeVisible();
// If there's a question (turn 0 gives a question), submit it to reach terminal
const answerTextarea = page.locator('textarea[placeholder*=Answer]');
const answerTextarea = page.locator('[data-testid="response-textarea"]');
if (await answerTextarea.isVisible({ timeout: 3000 })) {
await answerTextarea.fill(SCENARIO_LOOKUP["Happy path — complete investigation"].answerSequence[0]?.text || "");
await page.getByRole("button", { name: "Update situation" }).click();