diff --git a/test-playwright/33-record-gift-x10.spec.ts b/test-playwright/33-record-gift-x10.spec.ts index 65e09d6b..f118b1d6 100644 --- a/test-playwright/33-record-gift-x10.spec.ts +++ b/test-playwright/33-record-gift-x10.spec.ts @@ -164,34 +164,13 @@ test('Record 9 new gifts', async ({ page }, testInfo) => { await page.locator('div[role="alert"] button > svg.fa-xmark').click(); }); - // Optimized verification: use real-time DOM monitoring instead of page reload + // Optimized verification: use page.reload() instead of page.goto() for faster refresh await perfCollector.measureUserAction(`verify-gift-in-list-iteration-${i + 1}`, async () => { - // Wait for any network activity to settle after gift submission - await page.waitForLoadState('networkidle', { timeout: 3000 }); - - // Real-time DOM monitoring: wait for the gift to appear in the activity list - await page.waitForFunction( - (giftTitle) => { - const activityList = document.querySelector('ul#listLatestActivity'); - if (!activityList) return false; - - const listItems = activityList.querySelectorAll('li'); - for (const item of listItems) { - if (item.textContent?.includes(giftTitle)) { - return true; - } - } - return false; - }, - finalTitles[i], - { timeout: 8000 } - ); - - // Additional verification: ensure the gift is actually visible + await page.reload({ waitUntil: 'domcontentloaded' }); await expect(page.locator('ul#listLatestActivity li') .filter({ hasText: finalTitles[i] }) .first()) - .toBeVisible({ timeout: 2000 }); + .toBeVisible({ timeout: 5000 }); }); }