vatsrahul1001 commented on code in PR #60856: URL: https://github.com/apache/airflow/pull/60856#discussion_r2727272314
########## airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts: ########## @@ -0,0 +1,125 @@ +/*! + * 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 "tests/e2e/pages/BasePage"; + +export class GridPage extends BasePage { + public readonly gridCells: Locator; + public readonly gridViewButton: Locator; + public readonly taskNameLinks: Locator; + + public constructor(page: Page) { + super(page); + this.gridViewButton = page.locator('button[title*="Grid"], button[title*="grid"]').first(); + this.gridCells = page.locator('a[id^="grid-"]'); + this.taskNameLinks = page.locator('a[href*="/tasks/"]'); + } + + public async clickGridCellAndVerifyDetails(): Promise<void> { + await this.waitForGridToLoad(); + + const firstCell = this.gridCells.first(); + + await expect(firstCell).toBeVisible(); + await firstCell.click(); + await this.page.waitForURL(/.*\/tasks\/.*/, { timeout: 15_000 }); + await this.page.waitForLoadState("networkidle"); + } + + public getGridCellByTaskId(taskId: string): Locator { + return this.page.locator(`a[id$="-${taskId}"]`); + } + + public async getGridCellCount(): Promise<number> { + await this.waitForGridToLoad(); + + return this.gridCells.count(); + } + + public async getTaskNames(): Promise<Array<string>> { + await this.waitForGridToLoad(); + + const names = await this.taskNameLinks.allTextContents(); + const uniqueNames = [...new Set(names.map((name) => name.trim()).filter((name) => name !== ""))]; + + return uniqueNames; + } + + public async navigateToDag(dagId: string): Promise<void> { + await this.navigateTo(`/dags/${dagId}`); + await this.page.waitForURL(`**/dags/${dagId}**`, { timeout: 15_000 }); + await this.page.waitForLoadState("networkidle"); + } + + public async switchToGridView(): Promise<void> { + await expect(this.gridViewButton).toBeVisible({ timeout: 10_000 }); + await this.gridViewButton.click(); + await this.waitForGridToLoad(); + } + + public async verifyGridViewIsActive(): Promise<void> { + await expect(this.gridViewButton).toBeVisible({ timeout: 10_000 }); + await expect(this.gridCells.first()).toBeVisible({ timeout: 15_000 }); + await expect(this.taskNameLinks.first()).toBeVisible({ timeout: 10_000 }); + } + + public async verifyTaskExists(taskName: string): Promise<void> { Review Comment: verifyTaskExists is not being used in test ########## airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts: ########## @@ -0,0 +1,125 @@ +/*! + * 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 "tests/e2e/pages/BasePage"; + +export class GridPage extends BasePage { + public readonly gridCells: Locator; + public readonly gridViewButton: Locator; + public readonly taskNameLinks: Locator; + + public constructor(page: Page) { + super(page); + this.gridViewButton = page.locator('button[title*="Grid"], button[title*="grid"]').first(); Review Comment: Can we make this more robust?. Maybe add a new test-data element in UI if possible? ########## airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts: ########## @@ -0,0 +1,125 @@ +/*! + * 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 "tests/e2e/pages/BasePage"; + +export class GridPage extends BasePage { + public readonly gridCells: Locator; + public readonly gridViewButton: Locator; + public readonly taskNameLinks: Locator; + + public constructor(page: Page) { + super(page); + this.gridViewButton = page.locator('button[title*="Grid"], button[title*="grid"]').first(); + this.gridCells = page.locator('a[id^="grid-"]'); + this.taskNameLinks = page.locator('a[href*="/tasks/"]'); + } + + public async clickGridCellAndVerifyDetails(): Promise<void> { + await this.waitForGridToLoad(); + + const firstCell = this.gridCells.first(); + + await expect(firstCell).toBeVisible(); + await firstCell.click(); + await this.page.waitForURL(/.*\/tasks\/.*/, { timeout: 15_000 }); + await this.page.waitForLoadState("networkidle"); Review Comment: This can be unreliable. Consider replacing with explicit element waits (which you already do with waitForGridToLoad()). ########## airflow-core/src/airflow/ui/tests/e2e/pages/GridPage.ts: ########## @@ -0,0 +1,125 @@ +/*! + * 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 "tests/e2e/pages/BasePage"; + +export class GridPage extends BasePage { + public readonly gridCells: Locator; + public readonly gridViewButton: Locator; + public readonly taskNameLinks: Locator; + + public constructor(page: Page) { + super(page); + this.gridViewButton = page.locator('button[title*="Grid"], button[title*="grid"]').first(); + this.gridCells = page.locator('a[id^="grid-"]'); + this.taskNameLinks = page.locator('a[href*="/tasks/"]'); + } + + public async clickGridCellAndVerifyDetails(): Promise<void> { + await this.waitForGridToLoad(); + + const firstCell = this.gridCells.first(); + + await expect(firstCell).toBeVisible(); + await firstCell.click(); + await this.page.waitForURL(/.*\/tasks\/.*/, { timeout: 15_000 }); + await this.page.waitForLoadState("networkidle"); + } + + public getGridCellByTaskId(taskId: string): Locator { Review Comment: This is not being used in 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]
