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

Code before:

    await expect(async () => {
      // To avoid flakiness, we use a promise to wait for the elements to be visible
      await expect(eventsPage.eventsPageTitle).toBeVisible({ timeout: 10_000 });
      await eventsPage.waitForEventsTable();
      await expect(eventsPage.eventsTable).toBeVisible({ timeout: 10_000 });
      await eventsPage.verifyTableColumns();
    }).toPass({ timeout: 30_000 });
  });
});

test.describe("Events with Generated Data", () => {
  let eventsPage: EventsPage;
  let dagsPage: DagsPage;
  const testDagId = testConfig.testDag.id;

  test.beforeEach(({ page }) => {
    eventsPage = new EventsPage(page);
    dagsPage = new DagsPage(page);
  });

  test("should show audit log entries after triggering a DAG", async () => {
    test.setTimeout(3 * 60 * 1000); // 3 minutes timeout

    // First, trigger a DAG to generate audit log entries
    await dagsPage.triggerDag(testDagId);
    await expect(async () => {
      // Navigate to events page
      await eventsPage.navigate();
      // Wait for table to load
      await eventsPage.waitForEventsTable();
      // Verify the log entries contain actual data
      await eventsPage.verifyLogEntriesWithData();
    }).toPass({ timeout: 30_000 });
  });

  test("should verify pagination works with small page size", async () => {
    // Navigate to events page with small page size to force pagination
    await eventsPage.navigateToPaginatedEventsPage();

    await eventsPage.waitForEventsTable();

    await expect(eventsPage.paginationNextButton).toBeVisible({ timeout: 10_000 });
    await expect(eventsPage.paginationPrevButton).toBeVisible({ timeout: 10_000 });

    // Test pagination functionality - should have enough data to enable next button
    await expect(eventsPage.paginationNextButton).toBeEnabled({ timeout: 10_000 });

    // Click next page - content should change
    await eventsPage.clickNextPage();
    await expect(eventsPage.eventsTable).toBeVisible({ timeout: 10_000 });

Review comment (security):
Move trigger dag to beforeAll
```

test.describe("Events with Generated Data", () => {
  const testDagId = testConfig.testDag.id;

  test.beforeAll(async ({ browser }) => {
    test.setTimeout(3 * 60 * 1000);
    const context = await browser.newContext({ storageState: AUTH_FILE });
    const page = await context.newPage();
    const dagsPage = new DagsPage(page);
    
    await dagsPage.triggerDag(testDagId);
    await context.close();
  });

  test.beforeEach(({ page }) => {
    eventsPage = new EventsPage(page);
  });
```

Code after:
    await eventsPage.page.keyboard.press("Escape");
  });
});

test.describe("Events with Generated Data", () => {
  let eventsPage: EventsPage;
  const testDagId = testConfig.testDag.id;

  test.setTimeout(60_000);

  test.beforeAll(async ({ browser }) => {
    test.setTimeout(3 * 60 * 1000);
    const context = await browser.newContext({ storageState: AUTH_FILE });
    const page = await context.newPage();
    const dagsPage = new DagsPage(page);

    await dagsPage.triggerDag(testDagId);
    await context.close();
  });

  test.beforeEach(({ page }) => {
    eventsPage = new EventsPage(page);
  });

  test("verify audit log entries display valid data", async () => {
    await eventsPage.navigate();

    await expect(eventsPage.eventsTable).toBeVisible();

    const rowCount = await eventsPage.getTableRowCount();

    expect(rowCount).toBeGreaterThan(0);
    await eventsPage.verifyLogEntriesWithData();
  });

  test("verify search for specific event type and filtered results", async () => {
    await eventsPage.navigate();

    const initialRowCount = await eventsPage.getTableRowCount();

    expect(initialRowCount).toBeGreaterThan(0);

    await eventsPage.addFilter("Event Type");
    await eventsPage.setFilterValue("Event Type", "cli");
    await expect(eventsPage.eventsTable).toBeVisible();

    await expect(async () => {
      const filteredEvents = await eventsPage.getEventTypes(false);

      expect(filteredEvents.length).toBeGreaterThan(0);
      for (const event of filteredEvents) {