Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv-moataznabil committed Jul 25, 2024
1 parent a28f1de commit 85ba718
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/infinite_scroll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@ import { test, expect } from '@playwright/test';

test('Infinite Scroll', async ({ page }) => {
await page.goto('/infinite_scroll');
const content = page.locator('.jscroll-added');
await page.evaluate(() => window.scrollBy(0, window.innerHeight));
await expect(content).toHaveCount(2);

// Ensure the initial content is loaded
await page.waitForSelector('.jscroll-added');

const initialCount = await page.locator('.jscroll-added').count();
console.log(`Initial content count: ${initialCount}`);

// Scroll down the page and wait for new content to load
for (let i = 0; i < 2; i++) {
await page.evaluate(() => window.scrollBy(0, window.innerHeight));
await page.waitForTimeout(2000); // Increase the timeout to ensure content has time to load
}

// Explicitly wait for at least two new elements to be added
await expect(page.locator('.jscroll-added')).toHaveCount(initialCount + 2, { timeout: 10000 });

// Check if new content has been added
const newContentCount = await page.locator('.jscroll-added').count();
console.log(`New content count after scrolling: ${newContentCount}`);

expect(newContentCount).toBeGreaterThan(initialCount);
});

0 comments on commit 85ba718

Please sign in to comment.