-
Notifications
You must be signed in to change notification settings - Fork 16.6k
ADMIN-006: Verify Configuration Page functionality #61908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,12 @@ Environment variables (with defaults): | |
| - `TEST_USERNAME` - Username (default: `airflow`) | ||
| - `TEST_PASSWORD` - Password (default: `airflow`) | ||
| - `TEST_DAG_ID` - Test DAG ID (default: `example_bash_operator`) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need so many config? I think only |
||
| - `TEST_CONFIG_PAGE_PATH` - Config page path (default: `/configs`) | ||
| - `TEST_CONFIG_PAGE_HEADING` - Config page heading (default: `Airflow Configuration`) | ||
| - `TEST_CONFIG_PAGE_EXPECTS_TABLE_DATA` - `true` to assert table rows are exposed; `false` to assert 403 message (default: `false`) | ||
| - `TEST_CONFIG_PAGE_SECTION` - Section asserted when table data is exposed (default: `core`) | ||
| - `TEST_CONFIG_PAGE_KEY` - Key asserted when table data is exposed (default: `dags_folder`) | ||
| - `TEST_CONFIG_PAGE_FORBIDDEN_MESSAGE` - Message asserted when table data is hidden (default: `Your Airflow administrator chose not to expose the configuration`) | ||
|
|
||
| ## Debugging | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /*! | ||
| * 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 type { Locator, Page } from "@playwright/test"; | ||
|
|
||
| import { BasePage } from "./BasePage"; | ||
|
|
||
| export class ConfigsPage extends BasePage { | ||
| public readonly forbiddenStatus: Locator; | ||
| public readonly heading: Locator; | ||
| public readonly rows: Locator; | ||
| public readonly table: Locator; | ||
|
|
||
| public constructor(page: Page) { | ||
| super(page); | ||
| this.heading = page.getByRole("heading", { name: /configuration/i }); | ||
| this.table = page.getByTestId("table-list"); | ||
| this.forbiddenStatus = page.getByText(/403 forbidden/i); | ||
| this.rows = this.table.locator("tbody tr").filter({ | ||
| has: page.locator("td"), | ||
| }); | ||
| } | ||
|
|
||
| public async getColumnNames(): Promise<Array<string>> { | ||
| return this.table.locator("thead th").allTextContents(); | ||
| } | ||
|
|
||
| public async getRowCount(): Promise<number> { | ||
| return this.rows.count(); | ||
| } | ||
|
|
||
| public async getRowDetails(index: number): Promise<{ key: string; section: string; value: string }> { | ||
| const row = this.rows.nth(index); | ||
| const cells = row.locator("td"); | ||
|
|
||
| const section = await cells.nth(0).textContent(); | ||
| const key = await cells.nth(1).textContent(); | ||
| const value = await cells.nth(2).textContent(); | ||
|
|
||
| return { | ||
| key: (key ?? "").trim(), | ||
| section: (section ?? "").trim(), | ||
| value: (value ?? "").trim(), | ||
| }; | ||
| } | ||
|
|
||
| public async hasSectionAndKey(section: string, key: string): Promise<boolean> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use filter |
||
| const sectionLower = section.toLowerCase(); | ||
| const keyLower = key.toLowerCase(); | ||
| const rowCount = await this.getRowCount(); | ||
|
|
||
| for (let i = 0; i < rowCount; i++) { | ||
| const row = await this.getRowDetails(i); | ||
|
|
||
| if (row.section.toLowerCase() === sectionLower && row.key.toLowerCase() === keyLower) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| public async navigate(path = "/configs"): Promise<void> { | ||
| await this.navigateTo(path); | ||
| } | ||
|
|
||
| public async waitForLoad(): Promise<void> { | ||
| await this.heading.waitFor({ state: "visible", timeout: 30_000 }); | ||
| await this.page.waitForFunction( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can just use
|
||
| () => { | ||
| const table = document.querySelector('[data-testid="table-list"]'); | ||
| const bodyText = document.body.textContent; | ||
|
|
||
| return table !== null || bodyText.includes("403 Forbidden"); | ||
| }, | ||
| undefined, | ||
| { timeout: 30_000 }, | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /*! | ||
| * 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 { testConfig } from "playwright.config"; | ||
|
|
||
| import { ConfigsPage } from "../pages/ConfigsPage"; | ||
|
|
||
| const escapeForRegex = (value: string): string => value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&"); | ||
|
|
||
| test.describe("Configuration Page", () => { | ||
| let configsPage: ConfigsPage; | ||
| const { configPage } = testConfig; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| configsPage = new ConfigsPage(page); | ||
| await configsPage.navigate(configPage.path); | ||
| await configsPage.waitForLoad(); | ||
| }); | ||
|
|
||
| test("verify configuration displays", async () => { | ||
| await expect(configsPage.heading).toHaveText(new RegExp(configPage.expectedHeading, "i")); | ||
|
|
||
| if (!configPage.expectsTableData) { | ||
| await expect(configsPage.forbiddenStatus).toBeVisible(); | ||
| await expect( | ||
| configsPage.page.getByText(new RegExp(escapeForRegex(configPage.forbiddenMessage), "i")), | ||
| ).toBeVisible(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| await expect(configsPage.table).toBeVisible(); | ||
|
|
||
| const rowCount = await configsPage.getRowCount(); | ||
|
|
||
| expect(rowCount).toBeGreaterThan(0); | ||
|
|
||
| const columns = await configsPage.getColumnNames(); | ||
|
|
||
| expect(columns).toEqual(expect.arrayContaining(["Section", "Key", "Value"])); | ||
| }); | ||
|
|
||
| test("verify configuration page is accessible via Admin menu", async ({ page }) => { | ||
| await page.goto("/"); | ||
|
|
||
| await page.getByRole("button", { name: /^admin$/i }).click(); | ||
|
|
||
| const configMenuItem = page.getByRole("menuitem", { name: /^config$/i }); | ||
|
|
||
| await expect(configMenuItem).toBeVisible(); | ||
| await configMenuItem.click(); | ||
|
|
||
| await configsPage.waitForLoad(); | ||
| expect(page.url()).toContain(configPage.path); | ||
|
|
||
| if (!configPage.expectsTableData) { | ||
| await expect(configsPage.forbiddenStatus).toBeVisible(); | ||
| await expect( | ||
| configsPage.page.getByText(new RegExp(escapeForRegex(configPage.forbiddenMessage), "i")), | ||
| ).toBeVisible(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| await expect(configsPage.table).toBeVisible(); | ||
| }); | ||
|
|
||
| test("verify configuration section and key are rendered", async () => { | ||
| test.skip( | ||
| !configPage.expectsTableData, | ||
| "Set TEST_CONFIG_PAGE_EXPECTS_TABLE_DATA=true when configuration values are exposed.", | ||
| ); | ||
|
|
||
| const sectionAndKeyExists = await configsPage.hasSectionAndKey( | ||
| configPage.expectedSection, | ||
| configPage.expectedKey, | ||
| ); | ||
|
|
||
| expect(sectionAndKeyExists).toBe(true); | ||
| }); | ||
|
|
||
| test("verify section, key and value are populated in configuration rows", async () => { | ||
| test.skip( | ||
| !configPage.expectsTableData, | ||
| "Set TEST_CONFIG_PAGE_EXPECTS_TABLE_DATA=true when configuration values are exposed.", | ||
| ); | ||
|
|
||
| const rowCount = await configsPage.getRowCount(); | ||
| const rowsToCheck = Math.min(rowCount, 3); | ||
|
|
||
| for (let i = 0; i < rowsToCheck; i++) { | ||
| const { key, section, value } = await configsPage.getRowDetails(i); | ||
|
|
||
| expect(section).not.toEqual(""); | ||
| expect(key).not.toEqual(""); | ||
| expect(value).not.toEqual(""); | ||
| } | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have we removed this?