sticky-for-guest.spec.ts 828 B

123456789101112131415161718192021222324252627282930
  1. import { expect, test } from '@playwright/test';
  2. test('Sub navigation sticky changes when scrolling down and up', async ({
  3. page,
  4. }) => {
  5. await page.goto('/Sandbox');
  6. // Wait until the page is scrollable
  7. await expect
  8. .poll(async () => {
  9. const { scrollHeight, innerHeight } = await page.evaluate(() => ({
  10. scrollHeight: document.body.scrollHeight,
  11. innerHeight: window.innerHeight,
  12. }));
  13. return scrollHeight > innerHeight + 250;
  14. })
  15. .toBe(true);
  16. // Sticky
  17. await page.evaluate(() => window.scrollTo(0, 250));
  18. await expect(page.locator('.sticky-outer-wrapper').first()).toHaveClass(
  19. /active/,
  20. );
  21. // Not sticky
  22. await page.evaluate(() => window.scrollTo(0, 0));
  23. await expect(page.locator('.sticky-outer-wrapper').first()).not.toHaveClass(
  24. /active/,
  25. );
  26. });