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

Code before:
  test("shows asset rows when data exists", async () => {
    const count = await assets.assetCount();

    expect(count).toBeGreaterThanOrEqual(0);
  });

  test("each asset has a visible name link", async () => {
    const names = await assets.assetNames();

    for (const name of names) {
      expect(name.trim().length).toBeGreaterThan(0);
    }
  });

  test("filters assets using search", async () => {
    const initialCount = await assets.assetCount();

    await assets.search("dag");
    await expect.poll(() => assets.assetCount(), { timeout: 20_000 }).toBeLessThanOrEqual(initialCount);

    if ((await assets.assetCount()) === 0) {
      await expect(assets.emptyState).toBeVisible();
    }
  });

  test("supports pagination when multiple pages exist", async () => {
    const firstRowText = await assets.rows.first().textContent();

    const didNavigate = await assets.goNext();

    if (!didNavigate) {
      test.skip(true, "Pagination not rendered");
    }

    await expect
      .poll(async () => assets.rows.first().textContent(), { timeout: 20_000 })
      .not.toEqual(firstRowText);
  });
});


Review comment (suggestion):
You can try something like below
test("verify pagination controls navigate between pages", async () => {
  // Force pagination with small limit
  await assets.navigateTo("/assets?limit=5&offset=0");
  await assets.waitForLoad();


  const page1Assets = await assets.getAssetNames();
  expect(page1Assets.length).toBeGreaterThan(0);

  await assets.page.getByRole("button", { name: "2" }).click();
  await assets.page.waitForURL(/offset=5/);
  await assets.waitForLoad();

  const page2Assets = await assets.getAssetNames();
  expect(page2Assets.length).toBeGreaterThan(0);


  expect(page2Assets).not.toEqual(page1Assets);


  await assets.page.getByRole("button", { name: "1" }).click();
  await assets.page.waitForURL(/offset=0|(?!.*offset)/);
  await assets.waitForLoad();

  const backToPage1Assets = await assets.getAssetNames();
  expect(backToPage1Assets).toEqual(page1Assets);
});

Code after:
          );
          const data = (await response.json()) as { dag_runs: Array<{ state: string }> };

          return data.dag_runs[0]?.state ?? "pending";
        },
        { intervals: [2000], timeout: 120_000 },
      )
      .toBe("success");
    await context.close();
  });

  test.beforeEach(async ({ page }) => {
    assets = new AssetListPage(page);
    await assets.navigate();
    await assets.waitForLoad();
  });

  test("verify assets page heading", async () => {
    await expect(assets.heading).toBeVisible();
  });

  test("verify assets table", async () => {
    await expect(assets.table).toBeVisible();
  });

  test("verify asset rows when data exists", async () => {
    const count = await assets.assetCount();

    expect(count).toBeGreaterThanOrEqual(0);
  });

  test("verify asset has a visible name link", async () => {
    const names = await assets.assetNames();

    for (const name of names) {
      expect(name.trim().length).toBeGreaterThan(0);
    }
  });

  test("verify clicking an asset navigates to detail page", async ({ page }) => {
    const name = await assets.openFirstAsset();

    await expect(page).toHaveURL(/\/assets\/.+/);
    await expect(page.getByRole("heading", { name: new RegExp(name, "i") })).toBeVisible();
  });

  test("verify assets using search", async () => {
    const initialCount = await assets.assetCount();

    expect(initialCount).toBeGreaterThan(0);