refactor: improve feed loading and infinite scroll reliability

- Add debouncing and loading state to InfiniteScroll component to prevent duplicate entries
- Refactor updateAllFeed into smaller, focused functions for better maintainability
- Add proper error handling and type assertions
- Optimize test performance with networkidle waits and better selectors
- Fix strict mode violations in Playwright tests
- Clean up test configuration by commenting out unused browser targets
This commit is contained in:
Matthew Raymer
2025-03-31 09:17:15 +00:00
parent 8c8e4ec28e
commit 34dc4149f5
6 changed files with 3007 additions and 22370 deletions

View File

@@ -88,12 +88,8 @@ import { test, expect } from '@playwright/test';
import { importUser, createUniqueStringsArray, createRandomNumbersArray } from './testUtils';
test('Record 9 new gifts', async ({ page }) => {
const giftCount = 9; // because 10 has taken us above 30 seconds
// Standard text
const giftCount = 9;
const standardTitle = 'Gift ';
// Field value arrays
const finalTitles = [];
const finalNumbers = [];
@@ -101,21 +97,19 @@ test('Record 9 new gifts', async ({ page }) => {
const uniqueStrings = await createUniqueStringsArray(giftCount);
const randomNumbers = await createRandomNumbersArray(giftCount);
// Populate array with titles
// Populate arrays
for (let i = 0; i < giftCount; i++) {
let loopTitle = standardTitle + uniqueStrings[i];
finalTitles.push(loopTitle);
let loopNumber = randomNumbers[i];
finalNumbers.push(loopNumber);
finalTitles.push(standardTitle + uniqueStrings[i]);
finalNumbers.push(randomNumbers[i]);
}
// Import user 00
await importUser(page, '00');
// Record new gifts
// Record new gifts with optimized waiting
for (let i = 0; i < giftCount; i++) {
// Record something given
await page.goto('./');
// Record gift
await page.goto('./', { waitUntil: 'networkidle' });
if (i === 0) {
await page.getByTestId('closeOnboardingAndFinish').click();
}
@@ -123,11 +117,16 @@ test('Record 9 new gifts', async ({ page }) => {
await page.getByPlaceholder('What was given').fill(finalTitles[i]);
await page.getByRole('spinbutton').fill(finalNumbers[i].toString());
await page.getByRole('button', { name: 'Sign & Send' }).click();
// Wait for success and dismiss
await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
await page.locator('div[role="alert"] button > svg.fa-xmark').click();
// Refresh home view and check gift
await page.goto('./');
await expect(page.locator('li').filter({ hasText: finalTitles[i] })).toBeVisible();
// Verify gift in list with network idle wait
await page.goto('./', { waitUntil: 'networkidle' });
await expect(page.locator('ul#listLatestActivity li')
.filter({ hasText: finalTitles[i] })
.first())
.toBeVisible({ timeout: 10000 });
}
});