vatsrahul1001 commented on code in PR #59744: URL: https://github.com/apache/airflow/pull/59744#discussion_r2649665668
########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test, expect } from "@playwright/test"; +import { DagsPage } from "tests/e2e/pages/DagsPage"; +import { LoginPage } from "tests/e2e/pages/LoginPage"; Review Comment: We do not need login now as we do auth sharing ########## airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts: ########## @@ -100,6 +100,29 @@ export class DagsPage extends BasePage { await this.navigateTo(DagsPage.getDagDetailUrl(dagName)); } + /** + * Open the Code tab on a DAG detail page + */ +public async openCodeTab(): Promise<void> { + const codeTab = this.page.locator('[data-testid="dag-code-tab"]'); Review Comment: I do not think we have any attribute `[data-testid="dag-code-tab"]`. Also we should add all elements in page object(DagsPage.ts ) ########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test, expect } from "@playwright/test"; +import { DagsPage } from "tests/e2e/pages/DagsPage"; +import { LoginPage } from "tests/e2e/pages/LoginPage"; +import { testConfig } from "playwright.config"; + +test.describe("DAG Code Tab", () => { Review Comment: Lets use Dag Instead of DAG ########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test, expect } from "@playwright/test"; +import { DagsPage } from "tests/e2e/pages/DagsPage"; +import { LoginPage } from "tests/e2e/pages/LoginPage"; +import { testConfig } from "playwright.config"; + +test.describe("DAG Code Tab", () => { + let loginPage: LoginPage; + let dagsPage: DagsPage; + const testCredentials = testConfig.credentials; + const testDagId = testConfig.testDag.id; + + test.beforeEach(({ page }) => { + loginPage = new LoginPage(page); + dagsPage = new DagsPage(page); + }); + + test("should display DAG code", async () => { + await loginPage.navigateAndLogin(testCredentials.username, testCredentials.password); + await loginPage.expectLoginSuccess(); + + await dagsPage.navigateToDagDetail(testDagId); + await dagsPage.openCodeTab(); + + const codeContainer = dagsPage.getCodeContainer(); + await expect(codeContainer).toBeVisible(); + + const codeText = await dagsPage.getDagCodeText(); Review Comment: We should have a assertion here that DAG code is visible ########## airflow-core/src/airflow/ui/tests/e2e/pages/DagsPage.ts: ########## @@ -100,6 +100,29 @@ export class DagsPage extends BasePage { await this.navigateTo(DagsPage.getDagDetailUrl(dagName)); } + /** + * Open the Code tab on a DAG detail page + */ +public async openCodeTab(): Promise<void> { + const codeTab = this.page.locator('[data-testid="dag-code-tab"]'); + await codeTab.waitFor({ state: "visible", timeout: 10_000 }); + await codeTab.click(); +} + +/** + * Get the DAG code container (<pre>) + */ +public getCodeContainer(): Locator { + return this.page.locator('[data-testid="dag-code-container"]'); Review Comment: I do not think we have any attribute [data-testid="dag-code-container"]. Also we should add all elements in page object(DagsPage.ts ) ########## airflow-core/src/airflow/ui/tests/e2e/specs/dag-code-tab.spec.ts: ########## @@ -0,0 +1,48 @@ +/*! + * 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 { test, expect } from "@playwright/test"; +import { DagsPage } from "tests/e2e/pages/DagsPage"; +import { LoginPage } from "tests/e2e/pages/LoginPage"; +import { testConfig } from "playwright.config"; + +test.describe("DAG Code Tab", () => { + let loginPage: LoginPage; + let dagsPage: DagsPage; + const testCredentials = testConfig.credentials; + const testDagId = testConfig.testDag.id; + + test.beforeEach(({ page }) => { + loginPage = new LoginPage(page); + dagsPage = new DagsPage(page); + }); + + test("should display DAG code", async () => { + await loginPage.navigateAndLogin(testCredentials.username, testCredentials.password); + await loginPage.expectLoginSuccess(); + + await dagsPage.navigateToDagDetail(testDagId); + await dagsPage.openCodeTab(); + + const codeContainer = dagsPage.getCodeContainer(); + await expect(codeContainer).toBeVisible(); + + const codeText = await dagsPage.getDagCodeText(); + console.log("DAG code snippet:", codeText?.slice(0, 100)); // optional debug Review Comment: Do we need this? -- 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]
