You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussain-s (via GitHub)" <gi...@apache.org> on 2026/03/22 21:24:31 UTC

[PR] Improve Playwright test patterns in providers.spec.ts [airflow]

hussain-s opened a new pull request, #64078:
URL: https://github.com/apache/airflow/pull/64078

   ## Summary
   
   Improve Playwright test patterns in `providers.spec.ts` and `ProvidersPage.ts` without changing test coverage or behavior.
   
   ## What changed
   
   - replaced DOM-query based waiting with locator-based readiness checks
   - moved Admin menu navigation into the page object
   - replaced manual row-count and string assertions with web-first Playwright assertions
   - kept the existing providers test coverage intact
   
   ## Validation
   
   - `pnpm exec eslint tests/e2e/specs/providers.spec.ts tests/e2e/pages/ProvidersPage.ts`
   - `pnpm exec tsc --noEmit -p tsconfig.app.json`
   - `TEST_USERNAME=admin TEST_PASSWORD=admin AIRFLOW_UI_BASE_URL=http://localhost:28080 pnpm exec playwright test tests/e2e/specs/providers.spec.ts --project=chromium`
   
   Relates to #63431
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "Shrividya (via GitHub)" <gi...@apache.org>.
Shrividya commented on code in PR #64078:
URL: https://github.com/apache/airflow/pull/64078#discussion_r2976517737


##########
airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts:
##########
@@ -16,70 +16,55 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { expect } from "@playwright/test";
 import type { Locator, Page } from "@playwright/test";
 
 import { BasePage } from "./BasePage";
 
 export class ProvidersPage extends BasePage {
+  public readonly adminMenuButton: Locator;
   public readonly heading: Locator;
+  public readonly providersMenuItem: Locator;
   public readonly rows: Locator;
   public readonly table: Locator;
 
   public constructor(page: Page) {
     super(page);
 
+    this.adminMenuButton = page.getByRole("button", { name: /^admin$/i });
     this.heading = page.getByRole("heading", { name: /^providers$/i });
+    this.providersMenuItem = page.getByRole("menuitem", { name: /^providers$/i });
     this.table = page.getByTestId("table-list");
     this.rows = this.table.locator("tbody tr").filter({
       has: page.locator("td"),
     });
   }
 
-  public async getRowCount(): Promise<number> {
-    return this.rows.count();
-  }
-
-  public async getRowDetails(index: number) {
-    const row = this.rows.nth(index);
-    const cells = row.locator("td");
-
-    const pkg = await cells.nth(0).locator("a").textContent();
-    const ver = await cells.nth(1).textContent();
-    const desc = await cells.nth(2).textContent();
-
-    return {
-      description: (desc ?? "").trim(),
-      packageName: (pkg ?? "").trim(),
-      version: (ver ?? "").trim(),
-    };
+  public descriptionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(2);
   }
 
   public async navigate(): Promise<void> {
     await this.navigateTo("/providers");
   }
 
-  public async waitForLoad(): Promise<void> {
-    await this.table.waitFor({ state: "visible", timeout: 30_000 });
-    await this.waitForTableData();
+  public async navigateFromAdminMenu(): Promise<void> {
+    await this.navigateTo("/");
+    await this.adminMenuButton.click();
+    await expect(this.providersMenuItem).toBeVisible();
+    await this.providersMenuItem.click();
   }
 
-  private async waitForTableData(): Promise<void> {
-    // Wait for actual data links to appear (not skeleton loaders)
-    await this.page.waitForFunction(
-      () => {
-        const table = document.querySelector('[data-testid="table-list"]');
-
-        if (!table) {
-          return false;
-        }
+  public packageLinkAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(0).getByRole("link");
+  }
 
-        // Check for actual links in tbody (real data, not skeleton)
-        const links = table.querySelectorAll("tbody tr td a");
+  public versionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(1);
+  }
 
-        return links.length > 0;
-      },
-      undefined,
-      { timeout: 30_000 },
-    );
+  public async waitForLoad(): Promise<void> {
+    await expect(this.table).toBeVisible({ timeout: 30_000 });
+    await expect(this.rows.first()).toBeVisible({ timeout: 30_000 });

Review Comment:
   LGTM! 👍 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "hussain-s (via GitHub)" <gi...@apache.org>.
hussain-s commented on code in PR #64078:
URL: https://github.com/apache/airflow/pull/64078#discussion_r2972934124


##########
airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts:
##########
@@ -16,70 +16,55 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { expect } from "@playwright/test";
 import type { Locator, Page } from "@playwright/test";
 
 import { BasePage } from "./BasePage";
 
 export class ProvidersPage extends BasePage {
+  public readonly adminMenuButton: Locator;
   public readonly heading: Locator;
+  public readonly providersMenuItem: Locator;
   public readonly rows: Locator;
   public readonly table: Locator;
 
   public constructor(page: Page) {
     super(page);
 
+    this.adminMenuButton = page.getByRole("button", { name: /^admin$/i });
     this.heading = page.getByRole("heading", { name: /^providers$/i });
+    this.providersMenuItem = page.getByRole("menuitem", { name: /^providers$/i });
     this.table = page.getByTestId("table-list");
     this.rows = this.table.locator("tbody tr").filter({
       has: page.locator("td"),
     });
   }
 
-  public async getRowCount(): Promise<number> {
-    return this.rows.count();
-  }
-
-  public async getRowDetails(index: number) {
-    const row = this.rows.nth(index);
-    const cells = row.locator("td");
-
-    const pkg = await cells.nth(0).locator("a").textContent();
-    const ver = await cells.nth(1).textContent();
-    const desc = await cells.nth(2).textContent();
-
-    return {
-      description: (desc ?? "").trim(),
-      packageName: (pkg ?? "").trim(),
-      version: (ver ?? "").trim(),
-    };
+  public descriptionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(2);
   }
 
   public async navigate(): Promise<void> {
     await this.navigateTo("/providers");
   }
 
-  public async waitForLoad(): Promise<void> {
-    await this.table.waitFor({ state: "visible", timeout: 30_000 });
-    await this.waitForTableData();
+  public async navigateFromAdminMenu(): Promise<void> {
+    await this.navigateTo("/");
+    await this.adminMenuButton.click();
+    await expect(this.providersMenuItem).toBeVisible();
+    await this.providersMenuItem.click();
   }
 
-  private async waitForTableData(): Promise<void> {
-    // Wait for actual data links to appear (not skeleton loaders)
-    await this.page.waitForFunction(
-      () => {
-        const table = document.querySelector('[data-testid="table-list"]');
-
-        if (!table) {
-          return false;
-        }
+  public packageLinkAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(0).getByRole("link");
+  }
 
-        // Check for actual links in tbody (real data, not skeleton)
-        const links = table.querySelectorAll("tbody tr td a");
+  public versionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(1);
+  }
 
-        return links.length > 0;
-      },
-      undefined,
-      { timeout: 30_000 },
-    );
+  public async waitForLoad(): Promise<void> {
+    await expect(this.table).toBeVisible({ timeout: 30_000 });
+    await expect(this.rows.first()).toBeVisible({ timeout: 30_000 });

Review Comment:
   Good catch. I tightened `waitForLoad()` so it now waits for the first provider link to be visible, not just the first row shell. That keeps the readiness check tied to real table content while staying locator-based. I also reran the targeted ESLint, TypeScript, and Chromium Playwright checks locally after the change.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "hussain-s (via GitHub)" <gi...@apache.org>.
hussain-s commented on code in PR #64078:
URL: https://github.com/apache/airflow/pull/64078#discussion_r2972934124


##########
airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts:
##########
@@ -16,70 +16,55 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { expect } from "@playwright/test";
 import type { Locator, Page } from "@playwright/test";
 
 import { BasePage } from "./BasePage";
 
 export class ProvidersPage extends BasePage {
+  public readonly adminMenuButton: Locator;
   public readonly heading: Locator;
+  public readonly providersMenuItem: Locator;
   public readonly rows: Locator;
   public readonly table: Locator;
 
   public constructor(page: Page) {
     super(page);
 
+    this.adminMenuButton = page.getByRole("button", { name: /^admin$/i });
     this.heading = page.getByRole("heading", { name: /^providers$/i });
+    this.providersMenuItem = page.getByRole("menuitem", { name: /^providers$/i });
     this.table = page.getByTestId("table-list");
     this.rows = this.table.locator("tbody tr").filter({
       has: page.locator("td"),
     });
   }
 
-  public async getRowCount(): Promise<number> {
-    return this.rows.count();
-  }
-
-  public async getRowDetails(index: number) {
-    const row = this.rows.nth(index);
-    const cells = row.locator("td");
-
-    const pkg = await cells.nth(0).locator("a").textContent();
-    const ver = await cells.nth(1).textContent();
-    const desc = await cells.nth(2).textContent();
-
-    return {
-      description: (desc ?? "").trim(),
-      packageName: (pkg ?? "").trim(),
-      version: (ver ?? "").trim(),
-    };
+  public descriptionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(2);
   }
 
   public async navigate(): Promise<void> {
     await this.navigateTo("/providers");
   }
 
-  public async waitForLoad(): Promise<void> {
-    await this.table.waitFor({ state: "visible", timeout: 30_000 });
-    await this.waitForTableData();
+  public async navigateFromAdminMenu(): Promise<void> {
+    await this.navigateTo("/");
+    await this.adminMenuButton.click();
+    await expect(this.providersMenuItem).toBeVisible();
+    await this.providersMenuItem.click();
   }
 
-  private async waitForTableData(): Promise<void> {
-    // Wait for actual data links to appear (not skeleton loaders)
-    await this.page.waitForFunction(
-      () => {
-        const table = document.querySelector('[data-testid="table-list"]');
-
-        if (!table) {
-          return false;
-        }
+  public packageLinkAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(0).getByRole("link");
+  }
 
-        // Check for actual links in tbody (real data, not skeleton)
-        const links = table.querySelectorAll("tbody tr td a");
+  public versionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(1);
+  }
 
-        return links.length > 0;
-      },
-      undefined,
-      { timeout: 30_000 },
-    );
+  public async waitForLoad(): Promise<void> {
+    await expect(this.table).toBeVisible({ timeout: 30_000 });
+    await expect(this.rows.first()).toBeVisible({ timeout: 30_000 });

Review Comment:
   Good catch. I tightened `waitForLoad()` so it now waits for the first provider link to be visible, not just the first row shell. That keeps the readiness check tied to real table content while staying locator-based.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "choo121600 (via GitHub)" <gi...@apache.org>.
choo121600 merged PR #64078:
URL: https://github.com/apache/airflow/pull/64078


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #64078:
URL: https://github.com/apache/airflow/pull/64078#issuecomment-4107015132

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "Shrividya (via GitHub)" <gi...@apache.org>.
Shrividya commented on code in PR #64078:
URL: https://github.com/apache/airflow/pull/64078#discussion_r2972388976


##########
airflow-core/src/airflow/ui/tests/e2e/pages/ProvidersPage.ts:
##########
@@ -16,70 +16,55 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { expect } from "@playwright/test";
 import type { Locator, Page } from "@playwright/test";
 
 import { BasePage } from "./BasePage";
 
 export class ProvidersPage extends BasePage {
+  public readonly adminMenuButton: Locator;
   public readonly heading: Locator;
+  public readonly providersMenuItem: Locator;
   public readonly rows: Locator;
   public readonly table: Locator;
 
   public constructor(page: Page) {
     super(page);
 
+    this.adminMenuButton = page.getByRole("button", { name: /^admin$/i });
     this.heading = page.getByRole("heading", { name: /^providers$/i });
+    this.providersMenuItem = page.getByRole("menuitem", { name: /^providers$/i });
     this.table = page.getByTestId("table-list");
     this.rows = this.table.locator("tbody tr").filter({
       has: page.locator("td"),
     });
   }
 
-  public async getRowCount(): Promise<number> {
-    return this.rows.count();
-  }
-
-  public async getRowDetails(index: number) {
-    const row = this.rows.nth(index);
-    const cells = row.locator("td");
-
-    const pkg = await cells.nth(0).locator("a").textContent();
-    const ver = await cells.nth(1).textContent();
-    const desc = await cells.nth(2).textContent();
-
-    return {
-      description: (desc ?? "").trim(),
-      packageName: (pkg ?? "").trim(),
-      version: (ver ?? "").trim(),
-    };
+  public descriptionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(2);
   }
 
   public async navigate(): Promise<void> {
     await this.navigateTo("/providers");
   }
 
-  public async waitForLoad(): Promise<void> {
-    await this.table.waitFor({ state: "visible", timeout: 30_000 });
-    await this.waitForTableData();
+  public async navigateFromAdminMenu(): Promise<void> {
+    await this.navigateTo("/");
+    await this.adminMenuButton.click();
+    await expect(this.providersMenuItem).toBeVisible();
+    await this.providersMenuItem.click();
   }
 
-  private async waitForTableData(): Promise<void> {
-    // Wait for actual data links to appear (not skeleton loaders)
-    await this.page.waitForFunction(
-      () => {
-        const table = document.querySelector('[data-testid="table-list"]');
-
-        if (!table) {
-          return false;
-        }
+  public packageLinkAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(0).getByRole("link");
+  }
 
-        // Check for actual links in tbody (real data, not skeleton)
-        const links = table.querySelectorAll("tbody tr td a");
+  public versionCellAt(index: number): Locator {
+    return this.rows.nth(index).locator("td").nth(1);
+  }
 
-        return links.length > 0;
-      },
-      undefined,
-      { timeout: 30_000 },
-    );
+  public async waitForLoad(): Promise<void> {
+    await expect(this.table).toBeVisible({ timeout: 30_000 });
+    await expect(this.rows.first()).toBeVisible({ timeout: 30_000 });

Review Comment:
   Nit: The original waitForTableData() specifically checked for "tbody tr td a" links to distinguish real data from skeleton rows. In this line, the check would pass as soon as it identifies <tr> ,even before the real data loads.
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improve Playwright test patterns in providers.spec.ts [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #64078:
URL: https://github.com/apache/airflow/pull/64078#issuecomment-4140601993

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org