Skip to content

Conversation

@lin121291
Copy link
Contributor

What change does this PR introduce?

Adds end-to-end (E2E) tests for the Task Instances page (/task_instances) to improve test coverage of the UI.

What does this PR do?

New Files:

  • airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancesPage.ts - Page Object Model for Task Instances page
  • airflow-core/src/airflow/ui/tests/e2e/specs/task-instances.spec.ts - Test specifications

Related Issues

Closes #59357

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Jan 14, 2026
await taskInstancesPage.verifyPagination(5);
});

test("verify different task states display visually distinct", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need this. Lets remove color checking

/**
* Apply a filter by selecting a filter type and value
*/
public async applyFilter(filterName: string, filterValue: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DAG Runs PR uses URL parameters for filtering which is simpler and more reliable.

/**
* Verify pagination works correctly with offset and limit parameters
*/
public async verifyPagination(limit: number): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current implementation parses pagination text with regex which is complex and fragile. DAG Runs PR uses a simpler approach

);
const countAfter = await rowsAfterFilter.count();

if (countAfter === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use

await expect(dataLinks.first().or(noDataMessage.first())).toBeVisible({ timeout: 30_000 });

- Use URL parameters (?task_state=) instead of UI interactions for filtering
- Simplify pagination verification using semantic button selectors
- Replace regex-based text parsing with Playwright's getByRole()
- Use or() pattern for cleaner conditional logic
@vatsrahul1001
Copy link
Contributor

Thanks, @lin121291 for implementing review comments. I suggest resolving comments after you are done. I will review this soon

.isVisible()
.catch(() => false);

if (hasPage2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently passes if there is not enough data. I think we should not have this condition. As we are already creating data in beforeAll


await expect(paginationNav.first()).toBeVisible({ timeout: 10_000 });

const page1Button = this.page.getByRole("button", { name: /page 1|^1$/ });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can better use

this.paginationNextButton = page.locator('[data-testid="next"]');
this.paginationPrevButton = page.locator('[data-testid="prev"]');

const dataLinksPage2 = this.taskInstancesTable.locator("a[href*='/dags/']");
const noDataMessage = this.page.locator("text=/no.*data|no.*task instances|no.*results/i");

await expect(dataLinksPage2.first().or(noDataMessage.first())).toBeVisible({ timeout: 30_000 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not verifying anything in second page. Atlest we should check data is changed

@vatsrahul1001
Copy link
Contributor

vatsrahul1001 commented Jan 26, 2026

Pagination needs to follow the established pattern from PR #59400:

The current implementation differs from our merged pagination tests. Please reference:

  1. Use [data-testid="next/prev"] buttons instead of page numbers:
    // Current (incorrect)
    const page2Button = this.page.getByRole("button", { name: /page 2|^2$/ });

// Reference pattern (from DagsPage.ts)
this.paginationNextButton = page.locator('[data-testid="next"]');
this.paginationPrevButton = page.locator('[data-testid="prev"]');2. Remove if (hasPage2) conditional - beforeAll ensures data exists, pagination should work.

  1. Verify data actually changed using expect.poll():
    // Reference from dags-list.spec.ts
    const initialData = await dagsPage.getDagNames();
    await dagsPage.clickNextPage();
    const dataAfterNext = await dagsPage.getDagNames();
    expect(dataAfterNext).not.toEqual(initialData); // Verifies data changed!See: Feat e2e test for Dags pagination #59400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI E2E Test || TASKS-001: Verify all task instances display

2 participants