Skip to content

E2E Testing with Playwright

Jennings Zhang edited this page Feb 6, 2024 · 7 revisions

Running Tests

Run all tests:

npm run test:e2e

Or, use a GUI to run tests one-by-one:

npm run test:ui

Patternfly Page Sidebar on Mobile

import { test, expect, Page } from "./fixtures";

/**
 * Workaround for Patternfly and its mobile layout.
 *
 * The sidebar is always expanded by default. Some time around when the page
 * is done loading, if Patternfly detects the screen width is too narrow, it
 * will collapse the sidebar. However, the button to collapse the sidebar
 * becomes interactive before that check happens.
 *
 * So to access the sidebar on mobile during first launch, we retry expanding
 * the sidebar twice as a workaround.
 */
async function retryExpandSidebar(page: Page) {
  await expect(async () => {
    await page.getByLabel('Global navigation').tap();
    await page.waitForTimeout(1000);  // sidebar animation
    await expect(page.getByRole('link', { name: 'New and Existing Analyses' }))
      .toBeInViewport({timeout: 10});
  }).toPass({
    intervals: [100],
    timeout: 2500
  });
}
Clone this wiki locally