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

Code before:
    await assets.waitForLoad();
  });

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

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

  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):
Current test is not testing filtering correctly. You can try below
```
test("verify search filters assets", async () => {
  const initialCount = await assets.assetCount();
  expect(initialCount).toBeGreaterThan(1); 

  await assets.search("dag1"); // dag1 is just example, use proper asset name which filters 

  await expect.poll(() => assets.assetCount(), { timeout: 20_000 }).toBeLessThan(initialCount);
  const names = await assets.assetNames();
  expect(names.length).toBeGreaterThan(0);
  for (const name of names) {
    expect(name.toLowerCase()).toContain("dag1");
  }
});
```

Code after:
    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("asset_produces_1");
    await expect
      .poll(
        async () => {
          const response = await page.request.get(
            `/api/v2/dags/asset_produces_1/dagRuns?order_by=-start_date&limit=1`,
          );
          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 }) => {