Fix failing performance and unit tests
CI Pipeline / test (18) (pull_request) Failing after 3m29s
CI Pipeline / test (20) (pull_request) Failing after 4m23s
CI Pipeline / e2e (chromium) (pull_request) Successful in 3m0s
CI Pipeline / e2e (firefox) (pull_request) Successful in 5m45s
CI Pipeline / e2e (webkit) (pull_request) Successful in 4m22s
CI Pipeline / performance (pull_request) Successful in 4m0s
CI Pipeline / storybook (pull_request) Successful in 1m20s
CI Pipeline / visual-regression (pull_request) Successful in 6m7s
CI Pipeline / build (pull_request) Successful in 1m33s

This commit is contained in:
adilallo
2026-01-26 14:07:08 -07:00
parent bef13261b3
commit 1bb4627ab2
5 changed files with 84 additions and 15 deletions
+34 -2
View File
@@ -322,8 +322,40 @@ class PlaywrightPerformanceMonitor extends PerformanceMonitor {
async measurePageLoad(url) {
const startTime = Date.now();
// Navigate to the page
await this.page.goto(url, { waitUntil: "networkidle" });
try {
// Navigate to the page
// Use "load" instead of "networkidle" to handle dynamically imported components
// "networkidle" can timeout with code splitting as chunks load asynchronously
await this.page.goto(url, {
waitUntil: "load",
timeout: 60000, // 60 second timeout for slower networks
});
} catch (error) {
// Handle interstitial/blocking errors
if (error.message.includes("interstitial") || error.message.includes("prevented")) {
console.warn("Page load was blocked, attempting to continue:", error.message);
// Try to wait for the page to be in a usable state
try {
await this.page.waitForLoadState("domcontentloaded", { timeout: 10000 });
} catch (e) {
throw new Error(`Page failed to load: ${error.message}`);
}
} else {
throw error;
}
}
// Wait for dynamically imported components to be visible
// This ensures code-split components have loaded
try {
// Wait for main content sections that use dynamic imports
await this.page.waitForSelector("section", { timeout: 10000 }).catch(() => {
// Ignore if sections don't appear - page might still be valid
});
} catch (error) {
// Continue even if some components haven't loaded - we still want to measure performance
console.warn("Some components may not have loaded:", error.message);
}
const loadTime = Date.now() - startTime;
this.recordMetric("page_load_time", loadTime, { url });