Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions airflow-core/src/airflow/ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ openapi.merged.json
/playwright-report/
/tests/e2e/test-results/
/tests/e2e/playwright-report/

# Playwright auth state (generated by global-setup.ts)
/playwright/.auth/
14 changes: 11 additions & 3 deletions airflow-core/src/airflow/ui/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* under the License.
*/
import { defineConfig, devices } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";

/**
* Playwright configuration for Airflow UI End-to-End Tests
*/
export const testConfig = {
credentials: {
password: process.env.TEST_PASSWORD ?? "admin",
Expand All @@ -31,12 +30,18 @@ export const testConfig = {
},
};

const currentFilename = fileURLToPath(import.meta.url);
const currentDirname = path.dirname(currentFilename);

export const AUTH_FILE = path.join(currentDirname, "playwright/.auth/user.json");

export default defineConfig({
expect: {
timeout: 5000,
},
forbidOnly: process.env.CI !== undefined && process.env.CI !== "",
fullyParallel: true,
globalSetup: "./tests/e2e/global-setup.ts",
projects: [
{
name: "chromium",
Expand All @@ -52,6 +57,7 @@ export default defineConfig({
],
ignoreDefaultArgs: ["--enable-automation"],
},
storageState: AUTH_FILE,
},
},
{
Expand All @@ -67,6 +73,7 @@ export default defineConfig({
"--disable-web-security",
],
},
storageState: AUTH_FILE,
},
},
{
Expand All @@ -76,6 +83,7 @@ export default defineConfig({
launchOptions: {
args: [],
},
storageState: AUTH_FILE,
},
},
],
Expand Down
58 changes: 58 additions & 0 deletions airflow-core/src/airflow/ui/tests/e2e/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*!
* 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 { chromium, firefox, webkit, type FullConfig } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";

import { AUTH_FILE, testConfig } from "../../playwright.config";
import { LoginPage } from "./pages/LoginPage";

const browsers = { chromium, firefox, webkit };

/**
* Authenticate once before all tests and save state for reuse
*/
async function globalSetup(config: FullConfig) {
const [firstProject] = config.projects as [FullConfig["projects"][number]];
const baseURL = firstProject.use.baseURL ?? "http://localhost:28080";
const { password, username } = testConfig.credentials;
const browserName = firstProject.name as keyof typeof browsers;
const browserType = browsers[browserName];

const authDir = path.dirname(AUTH_FILE);

if (!fs.existsSync(authDir)) {
fs.mkdirSync(authDir, { recursive: true });
}

const browser = await browserType.launch();
const context = await browser.newContext({ baseURL });
const page = await context.newPage();

try {
const loginPage = new LoginPage(page);

await loginPage.navigateAndLogin(username, password);
await context.storageState({ path: AUTH_FILE });
} finally {
await browser.close();
}
}

export default globalSetup;
38 changes: 0 additions & 38 deletions airflow-core/src/airflow/ui/tests/e2e/specs/dags-list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -19,28 +19,15 @@
import { expect, test } from "@playwright/test";
import { testConfig } from "playwright.config";
import { DagsPage } from "tests/e2e/pages/DagsPage";
import { LoginPage } from "tests/e2e/pages/LoginPage";

/**
* Dags Pagination E2E Tests
*/

test.describe("Dags Pagination", () => {
let loginPage: LoginPage;
let dagsPage: DagsPage;

const testCredentials = testConfig.credentials;

test.beforeEach(({ page }) => {
loginPage = new LoginPage(page);
dagsPage = new DagsPage(page);
});

test("should verify pagination works on the Dags list page", async () => {
await loginPage.navigateAndLogin(testCredentials.username, testCredentials.password);

await loginPage.expectLoginSuccess();

await dagsPage.navigate();

await expect(dagsPage.paginationNextButton).toBeVisible();
Expand All @@ -65,32 +52,17 @@
});
});

/**
* Dag Trigger E2E Tests
*/

test.describe("Dag Trigger Workflow", () => {
let loginPage: LoginPage;
let dagsPage: DagsPage;

// Test configuration from centralized config

const testCredentials = testConfig.credentials;

const testDagId = testConfig.testDag.id;

test.beforeEach(({ page }) => {
loginPage = new LoginPage(page);
dagsPage = new DagsPage(page);
});

test("should successfully trigger a Dag run", async () => {
test.setTimeout(7 * 60 * 1000);

await loginPage.navigateAndLogin(testCredentials.username, testCredentials.password);

await loginPage.expectLoginSuccess();

const dagRunId = await dagsPage.triggerDag(testDagId);

if (Boolean(dagRunId)) {
Expand All @@ -99,26 +71,16 @@
});
});

/*
Dag verify details tab E2E test
*/
test.describe("Dag Details 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 successfully verify details tab", async () => {
await loginPage.navigateAndLogin(testCredentials.username, testCredentials.password);
await loginPage.expectLoginSuccess();

await dagsPage.verifyDagDetails(testDagId);
});
});
Loading