diff --git a/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts b/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts index 9381cc69d259c..fc08d6b3a912e 100644 --- a/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts +++ b/airflow-core/src/airflow/ui/tests/e2e/pages/RequiredActionsPage.ts @@ -38,14 +38,10 @@ export class RequiredActionsPage extends BasePage { } public async getActionsTableRowCount(): Promise { - const rows = this.page.locator("table tbody tr"); + const rows = this.actionsTable.locator("tbody").getByRole("row"); const isTableVisible = await this.actionsTable.isVisible(); - if (!isTableVisible) { - return 0; - } - - return rows.count(); + return isTableVisible ? rows.count() : 0; } public async isEmptyStateDisplayed(): Promise { @@ -77,13 +73,12 @@ export class RequiredActionsPage extends BasePage { await button.click(); await responsePromise; - await this.page.waitForTimeout(10_000); } private async clickOnTaskInGrid(dagRunId: string, taskId: string): Promise { - const taskLocator = this.page.locator(`[id="grid-${dagRunId}-${taskId}"]`); + const taskLocator = this.page.getByTestId(`grid-${dagRunId}-${taskId}`); - await expect(taskLocator).toBeVisible({ timeout: 30_000 }); + await expect(taskLocator).toBeVisible({ timeout: 5000 }); await taskLocator.click(); } @@ -96,11 +91,11 @@ export class RequiredActionsPage extends BasePage { await requiredActionLink.click(); const buttonName = approve ? "Approve" : "Reject"; - const actionButton = this.page.locator(`[data-testid="hitl-option-${buttonName}"]`); + const actionButton = this.page.getByTestId(`hitl-option-${buttonName}`); await expect(actionButton).toBeVisible({ timeout: 10_000 }); - const informationInput = this.page.locator("#element_information"); + const informationInput = this.page.getByRole("textbox"); if (await informationInput.isVisible()) { await informationInput.fill("Approved by test"); @@ -121,7 +116,7 @@ export class RequiredActionsPage extends BasePage { await expect(requiredActionLink).toBeVisible({ timeout: 30_000 }); await requiredActionLink.click(); - const branchButton = this.page.locator('[data-testid="hitl-option-task_1"]'); + const branchButton = this.page.getByTestId("hitl-option-task_1"); await expect(branchButton).toBeVisible({ timeout: 10_000 }); await this.clickButtonAndWaitForHITLResponse(branchButton); @@ -138,7 +133,7 @@ export class RequiredActionsPage extends BasePage { await expect(requiredActionLink).toBeVisible({ timeout: 30_000 }); await requiredActionLink.click(); - const informationInput = this.page.locator("#element_information"); + const informationInput = this.page.getByRole("textbox"); await expect(informationInput).toBeVisible({ timeout: 10_000 }); await informationInput.fill("test"); @@ -160,7 +155,7 @@ export class RequiredActionsPage extends BasePage { await expect(requiredActionLink).toBeVisible({ timeout: 30_000 }); await requiredActionLink.click(); - const multiSelectContainer = this.page.locator("#element_chosen_options").locator(".."); + const multiSelectContainer = this.page.getByRole("combobox", { name: /select one or multiple values/i }); await expect(multiSelectContainer).toBeVisible({ timeout: 30_000 }); await multiSelectContainer.click(); @@ -186,7 +181,7 @@ export class RequiredActionsPage extends BasePage { await expect(requiredActionLink).toBeVisible({ timeout: 30_000 }); await requiredActionLink.click(); - const optionButton = this.page.locator('[data-testid="hitl-option-option 1"]'); + const optionButton = this.page.getByTestId("hitl-option-option 1"); await expect(optionButton).toBeVisible({ timeout: 10_000 }); await this.clickButtonAndWaitForHITLResponse(optionButton); @@ -256,7 +251,7 @@ export class RequiredActionsPage extends BasePage { const detailsPanel = this.page.locator("#details-panel"); const stateBadge = detailsPanel.getByTestId("state-badge").first(); - await expect(stateBadge).toContainText(expectedState, { timeout: 60_000 }); + await expect(stateBadge).toContainText(expectedState, { timeout: 5000 }); }).toPass({ timeout: 180_000 }); } @@ -272,7 +267,7 @@ export class RequiredActionsPage extends BasePage { const detailsPanel = this.page.locator("#details-panel"); const stateBadge = detailsPanel.getByTestId("state-badge").first(); - await expect(stateBadge).toContainText(options.expectedState, { timeout: 60_000 }); + await expect(stateBadge).toContainText(options.expectedState, { timeout: 5000 }); }).toPass({ timeout: options.timeout ?? 120_000 }); } } diff --git a/airflow-core/src/airflow/ui/tests/e2e/specs/requiredAction.spec.ts b/airflow-core/src/airflow/ui/tests/e2e/specs/requiredAction.spec.ts index 976413e92cd16..3588720ea4eab 100644 --- a/airflow-core/src/airflow/ui/tests/e2e/specs/requiredAction.spec.ts +++ b/airflow-core/src/airflow/ui/tests/e2e/specs/requiredAction.spec.ts @@ -45,25 +45,14 @@ test.describe("Verify Required Action page", () => { await browsePage.navigateToRequiredActionsPage(); - const isTableVisible = await browsePage.isTableDisplayed(); - const isEmptyStateVisible = await browsePage.isEmptyStateDisplayed(); - - expect(isTableVisible || isEmptyStateVisible).toBe(true); - - if (isTableVisible) { - await expect(browsePage.actionsTable).toBeVisible(); - - const dagIdHeader = page.locator('th:has-text("Dag ID")'); - const taskIdHeader = page.locator('th:has-text("Task ID")'); - const dagRunIdHeader = page.locator('th:has-text("Dag Run ID")'); - const responseCreatedHeader = page.locator('th:has-text("Response created at")'); - const responseReceivedHeader = page.locator('th:has-text("Response received at")'); - - await expect(dagIdHeader).toBeVisible(); - await expect(taskIdHeader).toBeVisible(); - await expect(dagRunIdHeader).toBeVisible(); - await expect(responseCreatedHeader).toBeVisible(); - await expect(responseReceivedHeader).toBeVisible(); + await expect(browsePage.actionsTable.or(browsePage.emptyStateMessage)).toBeVisible(); + + if (await browsePage.actionsTable.isVisible()) { + await expect(page.locator("th").filter({ hasText: "Dag ID" })).toBeVisible(); + await expect(page.locator("th").filter({ hasText: "Task ID" })).toBeVisible(); + await expect(page.locator("th").filter({ hasText: "Dag Run ID" })).toBeVisible(); + await expect(page.locator("th").filter({ hasText: "Response created at" })).toBeVisible(); + await expect(page.locator("th").filter({ hasText: "Response received at" })).toBeVisible(); } else { await expect(browsePage.emptyStateMessage).toBeVisible(); }