Keine Beschreibung

scrolling-fixed.test.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @jest-environment puppeteer
  3. * @flow
  4. */
  5. import { scroll, screenshot } from '../utils/puppeteer.js';
  6. it('should update the position when window is resized', async () => {
  7. const page = await browser.newPage();
  8. await page.goto(`${TEST_URL}/scrolling-fixed/scroll.html`);
  9. await scroll(page, '#scroll', 300);
  10. expect(await screenshot(page)).toMatchImageSnapshot();
  11. });
  12. it('should handle basic nested scrollable parents', async () => {
  13. const page = await browser.newPage();
  14. await page.goto(`${TEST_URL}/scrolling-fixed/nested.html`);
  15. await scroll(page, '.scroll2', 300);
  16. await scroll(page, '.scroll1', 300);
  17. expect(await screenshot(page)).toMatchImageSnapshot();
  18. });
  19. it('should handle basic nested scrollable parents when pop/ref are on same div', async () => {
  20. const page = await browser.newPage();
  21. await page.goto(`${TEST_URL}/scrolling-fixed/nested-same.html`);
  22. await scroll(page, '.scroll2', 300);
  23. await scroll(page, '.scroll1', 300);
  24. expect(await screenshot(page)).toMatchImageSnapshot();
  25. });
  26. it('should handle case where popper is one level deeper than reference', async () => {
  27. const page = await browser.newPage();
  28. await page.goto(`${TEST_URL}/scrolling-fixed/nested-alt.html`);
  29. await scroll(page, '.scroll2', 300);
  30. await scroll(page, '.scroll1', 300);
  31. expect(await screenshot(page)).toMatchImageSnapshot();
  32. });
  33. it('should handle basic offset parent', async () => {
  34. const page = await browser.newPage();
  35. await page.goto(`${TEST_URL}/scrolling-fixed/offset-basic.html`);
  36. await scroll(page, 'html', 200);
  37. expect(await screenshot(page)).toMatchImageSnapshot();
  38. });
  39. it('should handle case where root scrolling parent is also offset parent', async () => {
  40. const page = await browser.newPage();
  41. await page.goto(`${TEST_URL}/scrolling-fixed/offset-parent.html`);
  42. await scroll(page, '.scroll3', 200);
  43. await scroll(page, '.scroll2', 200);
  44. await scroll(page, '.scroll1', 200);
  45. expect(await screenshot(page)).toMatchImageSnapshot();
  46. });
  47. it('should handle multiple nested offsetParents', async () => {
  48. const page = await browser.newPage();
  49. await page.goto(`${TEST_URL}/scrolling-fixed/offset-parent-multiple.html`);
  50. await scroll(page, '.scroll3', 200);
  51. await scroll(page, '.scroll2', 200);
  52. await scroll(page, '.scroll1', 200);
  53. expect(await screenshot(page)).toMatchImageSnapshot();
  54. });
  55. it('should handle same offset parent', async () => {
  56. const page = await browser.newPage();
  57. await page.goto(`${TEST_URL}/scrolling-fixed/scroll-same-offset-parent.html`);
  58. await scroll(page, '#scroll', 200);
  59. expect(await screenshot(page)).toMatchImageSnapshot();
  60. });
  61. it('should handle alt offset parent', async () => {
  62. const page = await browser.newPage();
  63. await page.goto(`${TEST_URL}/scrolling-fixed/scroll-alt-offset-parent.html`);
  64. await scroll(page, '#scroll', 200);
  65. expect(await screenshot(page)).toMatchImageSnapshot();
  66. });