Repository: apache/airflow
File: airflow-core/src/airflow/ui/tests/e2e/specs/backfill.spec.ts (TypeScript)

Code before:
  test.describe.configure({ mode: "serial" });
  test.setTimeout(240_000);

  const testDagId = testConfig.testDag.id;

  const backfillConfigs = [
    { behavior: "All Runs" as const, fromDate: getPastDate(5), toDate: getPastDate(4) },
    { behavior: "Missing Runs" as const, fromDate: getPastDate(8), toDate: getPastDate(6) },
    { behavior: "Missing and Errored Runs" as const, fromDate: getPastDate(12), toDate: getPastDate(10) },
  ];

  test.beforeAll(async ({ browser }) => {
    test.setTimeout(600_000);

    const context = await browser.newContext({ storageState: AUTH_FILE });
    const page = await context.newPage();
    const setupBackfillPage = new BackfillPage(page);

    for (const config of backfillConfigs) {
      await setupBackfillPage.createBackfill(testDagId, {
        fromDate: config.fromDate,
        reprocessBehavior: config.behavior,
        toDate: config.toDate,
      });

      // Wait for backfill to complete on DAG detail page (where the banner is visible)
      await setupBackfillPage.navigateToDagDetail(testDagId);
      await setupBackfillPage.waitForNoActiveBackfill();
    }

    await context.close();
  });

  test("verify backfill with 'all runs' behavior", async ({ page }) => {
    const backfillPage = new BackfillPage(page);

    await backfillPage.navigateToBackfillsTab(testDagId);

    const config = backfillConfigs[0]!; // All Runs

    const backfillDetails = await backfillPage.getBackfillDetailsByDateRange({
      fromDate: config.fromDate,
      toDate: config.toDate,
    });

    expect(backfillDetails.fromDate.slice(0, 10)).toEqual(config.fromDate.slice(0, 10));
    expect(backfillDetails.toDate.slice(0, 10)).toEqual(config.toDate.slice(0, 10));

    expect(backfillDetails.createdAt).not.toEqual("");
    expect(backfillDetails.reprocessBehavior).toEqual("All Runs");
    const status = await backfillPage.getBackfillStatus();

Review comment (suggestion):
```suggestion
      // Wait for backfill to complete on Dag detail page (where the banner is visible)
```

Code after:
  test.describe.configure({ mode: "serial" });
  test.setTimeout(240_000);

  const testDagId = testConfig.testDag.id;

  const backfillConfigs = [
    { behavior: "All Runs" as const, fromDate: getPastDate(5), toDate: getPastDate(4) },
    { behavior: "Missing Runs" as const, fromDate: getPastDate(8), toDate: getPastDate(6) },
    { behavior: "Missing and Errored Runs" as const, fromDate: getPastDate(12), toDate: getPastDate(10) },
  ];

  test.beforeAll(async ({ browser }) => {
    test.setTimeout(600_000);

    const context = await browser.newContext({ storageState: AUTH_FILE });
    const page = await context.newPage();
    const setupBackfillPage = new BackfillPage(page);

    for (const config of backfillConfigs) {
      await setupBackfillPage.createBackfill(testDagId, {
        fromDate: config.fromDate,
        reprocessBehavior: config.behavior,
        toDate: config.toDate,
      });

      // Wait for backfill to complete on Dag detail page (where the banner is visible)
      await setupBackfillPage.navigateToDagDetail(testDagId);
      await setupBackfillPage.waitForNoActiveBackfill();
    }

    await context.close();
  });

  test("verify backfill with 'all runs' behavior", async ({ page }) => {
    const backfillPage = new BackfillPage(page);

    await backfillPage.navigateToBackfillsTab(testDagId);

    const config = backfillConfigs[0]!; // All Runs

    const backfillDetails = await backfillPage.getBackfillDetailsByDateRange({
      fromDate: config.fromDate,
      toDate: config.toDate,
    });

    expect(backfillDetails.fromDate.slice(0, 10)).toEqual(config.fromDate.slice(0, 10));
    expect(backfillDetails.toDate.slice(0, 10)).toEqual(config.toDate.slice(0, 10));

    expect(backfillDetails.createdAt).not.toEqual("");
    expect(backfillDetails.reprocessBehavior).toEqual("All Runs");
    const status = await backfillPage.getBackfillStatus();