vatsrahul1001 commented on code in PR #60449:
URL: https://github.com/apache/airflow/pull/60449#discussion_r2692985934


##########
airflow-core/src/airflow/ui/tests/e2e/pages/BrowsePage.ts:
##########
@@ -0,0 +1,138 @@
+/*!

Review Comment:
   Let's use RequiredActionsPage.ts instead of BrowsePage.ts



##########
airflow-core/src/airflow/ui/tests/e2e/specs/browse.spec.ts:
##########
@@ -0,0 +1,108 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { expect, test } from "@playwright/test";
+import { AUTH_FILE } from "playwright.config";
+
+import { BrowsePage } from "../pages/BrowsePage";
+
+const hitlDagId = "example_hitl_operator";

Review Comment:
   This should come from config 



##########
airflow-core/src/airflow/ui/tests/e2e/pages/BrowsePage.ts:
##########
@@ -0,0 +1,138 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { expect, type Locator, type Page } from "@playwright/test";
+
+import { BasePage } from "./BasePage";
+import { DagsPage } from "./DagsPage";
+
+export type MarkRunAsState = "failed" | "success";
+
+export class BrowsePage extends BasePage {
+  public readonly actionsTable: Locator;
+  public readonly emptyStateMessage: Locator;
+  public readonly pageHeading: Locator;
+  public readonly paginationNextButton: Locator;
+  public readonly paginationPrevButton: Locator;
+
+  public constructor(page: Page) {
+    super(page);
+    this.pageHeading = page.getByRole("heading", { name: /required action/i });
+    this.actionsTable = page.getByTestId("table-list");
+    this.emptyStateMessage = page.getByText(/no required actions found/i);
+    this.paginationNextButton = page.locator('[data-testid="next"]');
+    this.paginationPrevButton = page.locator('[data-testid="prev"]');
+  }
+
+  public static getRequiredActionsUrl(): string {
+    return "/required_actions";
+  }
+
+  public async clickNextPage(): Promise<void> {
+    await this.paginationNextButton.click();
+    await this.page.waitForLoadState("networkidle");
+  }
+
+  public async clickPrevPage(): Promise<void> {
+    await this.paginationPrevButton.click();
+    await this.page.waitForLoadState("networkidle");
+  }
+
+  public async getActionsTableRowCount(): Promise<number> {
+    const rows = this.page.locator("table tbody tr");
+    const isTableVisible = await this.actionsTable.isVisible();
+
+    if (!isTableVisible) {
+      return 0;
+    }
+
+    return rows.count();
+  }
+
+  public async getActionSubjects(): Promise<Array<string>> {
+    const rows = this.page.locator("table tbody tr td:nth-child(2)");
+    const count = await rows.count();
+    const subjects: Array<string> = [];
+
+    for (let i = 0; i < count; i++) {
+      const text = await rows.nth(i).textContent();
+
+      if (text !== null) {
+        subjects.push(text.trim());
+      }
+    }
+
+    return subjects;
+  }
+
+  public async isEmptyStateDisplayed(): Promise<boolean> {
+    return this.emptyStateMessage.isVisible();
+  }
+
+  public async isPaginationVisible(): Promise<boolean> {
+    return this.paginationNextButton.isVisible();
+  }
+
+  public async isTableDisplayed(): Promise<boolean> {
+    return this.actionsTable.isVisible();
+  }
+
+  public async navigateToRequiredActionsPage(): Promise<void> {
+    await this.navigateTo(BrowsePage.getRequiredActionsUrl());
+    await expect(this.pageHeading).toBeVisible({ timeout: 10_000 });
+  }
+
+  public async triggerAndMarkDagRun(dagId: string, state: MarkRunAsState): 
Promise<void> {
+    const dagsPage = new DagsPage(this.page);
+    const dagRunId = await dagsPage.triggerDag(dagId);
+
+    if (dagRunId !== null) {
+      await this.page.goto(`/dags/${dagId}/runs/${dagRunId}`);
+
+      const markDagRunButton = this.page.getByTestId("mark-run-as-button");
+
+      await expect(markDagRunButton).toBeVisible({ timeout: 20_000 });
+      await markDagRunButton.click();
+
+      const stateOption = this.page.getByTestId(`mark-run-as-${state}`);

Review Comment:
   Marking DAG run bypasses HITL flow, when you mark a DAG run as 
success/failed immediately after triggering, it forcefully completes the run. 
This bypasses the normal HITL flow where the HITL task creates a "Required 
Action" while waiting for human input.
   



##########
airflow-core/src/airflow/ui/tests/e2e/specs/browse.spec.ts:
##########
@@ -0,0 +1,108 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { expect, test } from "@playwright/test";
+import { AUTH_FILE } from "playwright.config";
+
+import { BrowsePage } from "../pages/BrowsePage";
+
+const hitlDagId = "example_hitl_operator";
+
+test.describe("Verify Required Action page", () => {
+  test.describe.configure({ mode: "serial" });
+
+  test.beforeAll(async ({ browser }) => {
+    test.setTimeout(120_000);
+
+    const context = await browser.newContext({ storageState: AUTH_FILE });
+
+    const page = await context.newPage();
+    const browsePage = new BrowsePage(page);
+
+    await browsePage.triggerAndMarkDagRun(hitlDagId, "success");
+    await browsePage.triggerAndMarkDagRun(hitlDagId, "failed");
+    await context.close();
+  });
+
+  test("Verify the actions list/table is displayed (or empty state if none)", 
async ({ page }) => {
+    const browsePage = new BrowsePage(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();
+    } else {
+      await expect(browsePage.emptyStateMessage).toBeVisible();
+    }
+  });
+
+  test("Verify Pagination", async ({ page }) => {
+    const browsePage = new BrowsePage(page);
+
+    await browsePage.navigateToRequiredActionsPage();
+
+    const isTableVisible = await browsePage.isTableDisplayed();
+
+    if (!isTableVisible) {
+      return;
+    }
+
+    const isPaginationVisible = await browsePage.isPaginationVisible();
+
+    if (!isPaginationVisible) {

Review Comment:
   Why are we skipping the pagination test? We can use offset and limit in an 
API call to test pagination. Check how it's being done in existing tests



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to