From ea22ab199f508ef05256985d4b8e0c4e33c3f9cc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 19:24:50 +0000 Subject: [PATCH] Connect to Lovable Cloud Add phase 2 migration for moderator INSERT policies and enhance test runner rate-limit mitigations: - Introduce migration 20251110_fix_missing_insert_policies_phase2.sql to grant moderator INSERT capabilities for park_submission_locations, parks, rides, companies, ride_models, and locations with MFA checks. - Update test runner to 8s base delays, preemptive cooldowns before heavy suites, and 18s post-suite delays for heavy suites, improving rate-limit handling. --- src/lib/integrationTests/testRunner.ts | 46 ++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/lib/integrationTests/testRunner.ts b/src/lib/integrationTests/testRunner.ts index 8af3fc8c..9ccfc34d 100644 --- a/src/lib/integrationTests/testRunner.ts +++ b/src/lib/integrationTests/testRunner.ts @@ -53,9 +53,9 @@ export class IntegrationTestRunner { private onProgress?: (result: TestResult) => void; private delayBetweenTests: number; - constructor(onProgress?: (result: TestResult) => void, delayBetweenTests: number = 6000) { + constructor(onProgress?: (result: TestResult) => void, delayBetweenTests: number = 8000) { this.onProgress = onProgress; - this.delayBetweenTests = delayBetweenTests; // Default 6 seconds to prevent rate limiting + this.delayBetweenTests = delayBetweenTests; // Default 8 seconds to prevent rate limiting } /** @@ -198,19 +198,53 @@ export class IntegrationTestRunner { ]; for (let i = 0; i < suites.length; i++) { + const isHeavySuite = submissionHeavySuites.includes(suites[i].name); + + // PREEMPTIVE delay BEFORE heavy suites start (prevents rate limit buildup) + if (isHeavySuite && i > 0) { + const preemptiveDelayMs = 8000; // 8s "cooldown" before heavy suite + const delaySeconds = preemptiveDelayMs / 1000; + const delayResult: TestResult = { + id: `preemptive-delay-${Date.now()}`, + name: `⏳ Pre-suite cooldown: ${delaySeconds}s (preparing for ${suites[i].name})`, + suite: 'System', + status: 'running', + duration: 0, + timestamp: new Date().toISOString(), + details: { + reason: 'Preemptive rate limit prevention before submission-heavy suite', + nextSuite: suites[i].name + } + }; + + if (this.onProgress) { + this.onProgress(delayResult); + } + + await this.delay(preemptiveDelayMs); + + if (this.onProgress) { + this.onProgress({ + ...delayResult, + status: 'skip', + duration: preemptiveDelayMs, + details: { reason: 'Cooldown completed' } + }); + } + } + await this.runSuite(suites[i]); if (this.shouldStop) { break; } - // Add delay between suites with adaptive timing + // REACTIVE delay AFTER suites complete if (i < suites.length - 1 && this.delayBetweenTests > 0) { // Longer delay after submission-heavy suites - const isHeavySuite = submissionHeavySuites.includes(suites[i].name); const delayMs = isHeavySuite - ? this.delayBetweenTests * 2 // 12s delay after heavy suites - : this.delayBetweenTests; // 6s delay after others + ? this.delayBetweenTests * 2.25 // 18s delay after heavy suites (increased from 12s) + : this.delayBetweenTests; // 8s delay after others (increased from 6s) const delaySeconds = delayMs / 1000; const delayResult: TestResult = {