Açıklama Yok

scrolling-absolute.test.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-absolute/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-absolute/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-absolute/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-absolute/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-absolute/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-absolute/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-absolute/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(
  58. `${TEST_URL}/scrolling-absolute/scroll-same-offset-parent.html`
  59. );
  60. await scroll(page, '#scroll', 200);
  61. expect(await screenshot(page)).toMatchImageSnapshot();
  62. });
  63. it('should handle alt offset parent', async () => {
  64. const page = await browser.newPage();
  65. await page.goto(
  66. `${TEST_URL}/scrolling-absolute/scroll-alt-offset-parent.html`
  67. );
  68. await scroll(page, '#scroll', 200);
  69. expect(await screenshot(page)).toMatchImageSnapshot();
  70. });
  71. it('finds scrolling parent through assigned slots', async () => {
  72. const page = await browser.newPage();
  73. await page.goto(
  74. `${TEST_URL}/scrolling-absolute/parent-through-assigned-slot.html`
  75. );
  76. await scroll(page, '#scroll', 200);
  77. expect(await screenshot(page)).toMatchImageSnapshot();
  78. });