test(e2e): bateria abrangente + relatório auditoria (re-#85)#94
test(e2e): bateria abrangente + relatório auditoria (re-#85)#94adm01-debug wants to merge 1 commit into
Conversation
Cobertura nova focada nos fixes #34–#43: - e2e/spa-rewrite.spec.ts (Fix #42): 12 testes que validam que /admin/*, /orcamentos/*, /produtos, /colecoes etc. servem index.html e não retornam 404 (defesa contra regressão do rewrite Vercel). 11/12 verdes (1 skip esperado em dev por assets inline). - e2e/catalog.spec.ts (Fix #40 + #41): +2 testes registrando contratos de regressão para "categoria real" (≤5% cards com "Sem categoria") e OptimizedImage chaining (<=20% imgs em opacity-0). CORS gate corrigido nos dois últimos hold-outs: - supabase/functions/{sync-external-db,simulation-orchestrator}: migrar de literais inline para buildPublicCorsHeaders() + handleCorsPreflight(). check:edge-cors e check:no-inline-cors agora cobrem 81/81 funções. - scripts/{contract,massive-load}-testing.mjs: fallback URL alinhado ao projeto correto (doufsxqlfjyuvxuezpln, fix #36). docs/AUDITORIA_E2E_2026-05-22.md consolida: - veredito por melhoria #34–#43 - matriz de cobertura, projects do Playwright, métricas de perf - gaps priorizados (TS baseline drift +118, 73 toast leaks novos) - recomendações imediatas/curto/médio prazo https://claude.ai/code/session_011nXFRRG58esCThfczTQuXG
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Conflito vs main após merge de #93 (cleanup pass 1 mexeu em arquivos que esta PR também toca, ex.: scripts/contract-testing.mjs). Fechando como superseded. Branch |
|
Updates to Preview Branch (claude/e2e-test-battery-9lNtU) ↗︎
Tasks are run on every commit but only new migration files are pushed.
❌ Branch Error • Fri, 22 May 2026 09:58:32 UTC View logs for this Workflow Run ↗︎. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acd45509ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await expect(firstCard).toBeVisible({ timeout: 15_000 }); | ||
| const totalCards = await page.locator('[data-testid="product-card"]').count(); | ||
| if (totalCards === 0) { | ||
| test.skip(true, "Sem cards renderizados — provavelmente sem dados."); | ||
| return; |
There was a problem hiding this comment.
Check empty grid before waiting for first product card
This test tries to skip when there are no products, but the skip branch is unreachable because expect(firstCard).toBeVisible() runs first and will timeout when the catalog is empty. In environments/tenants without seeded products, this turns an intended skip into a hard failure and can make the regression suite flaky. Count cards (or otherwise detect empty state) before the visibility assertion so the test can skip as designed.
Useful? React with 👍 / 👎.
| await expect(firstImg).toBeVisible({ timeout: 15_000 }); | ||
| await firstImg.evaluate((el: HTMLImageElement) => { | ||
| if (el.complete && el.naturalWidth > 0) return; | ||
| return new Promise<void>((resolve) => { | ||
| el.addEventListener("load", () => resolve(), { once: true }); |
There was a problem hiding this comment.
Guard empty image list before awaiting first image visibility
The same control-flow issue exists here: the test only calls test.skip when totalImgs === 0, but it first asserts firstImg is visible. If the grid renders no images (valid for empty catalogs or filtered datasets), the test fails on timeout instead of skipping, which creates avoidable CI noise. Move the zero-images guard ahead of the visibility/load wait.
Useful? React with 👍 / 👎.
| * Observação: vercel.json em si só age no deploy. O Vite dev tem fallback | ||
| * historyApi nativo, então este spec funciona como contrato de comportamento | ||
| * (qualquer regressão em vercel.json também regressaria a UX no dev). |
There was a problem hiding this comment.
Run rewrite regression against Vercel-equivalent server
This suite claims to validate the vercel.json SPA rewrite, but it runs against the Playwright web server (npx vite in playwright.config.ts), where history fallback is handled by Vite itself. As a result, removing or breaking Vercel rewrite rules can still leave these tests green, producing a false sense of protection for the production-only 404 regression.
Useful? React with 👍 / 👎.
| 'link[rel="modulepreload"][href^="/assets/"], link[rel="stylesheet"][href^="/assets/"]', | ||
| ); | ||
| const script = document.querySelector<HTMLScriptElement>('script[src^="/assets/"]'); | ||
| return link?.href ?? script?.src ?? null; |
There was a problem hiding this comment.
Avoid always-skipped asset check under Vite dev
The asset assertion is effectively non-executing in the configured test environment: this code only looks for /assets/* links/scripts, but Vite dev serves entry modules via /@vite/client and /src/*, so assetHref becomes null and the test is skipped every run. That means this test does not currently verify the rewrite-interception behavior it is meant to guard.
Useful? React with 👍 / 👎.
| const ratio = countSem / totalCards; | ||
| expect( | ||
| ratio, | ||
| `${countSem}/${totalCards} cards ainda exibem 'Sem categoria' (regressão do fix #40)`, | ||
| ).toBeLessThanOrEqual(0.05); |
There was a problem hiding this comment.
Relax category fallback ratio for small product counts
The asserted threshold (<= 0.05) contradicts the stated intent to tolerate some uncategorized products when the page has fewer than 20 cards: for 1–19 cards, even a single legitimate "Sem categoria" result fails the test. This makes the regression check brittle across tenants with small catalogs and can produce false failures unrelated to fix #40.
Useful? React with 👍 / 👎.
| expect( | ||
| opacityZero / totalImgs, | ||
| `${opacityZero}/${totalImgs} imgs ficaram com opacity-0 após carga`, | ||
| ).toBeLessThanOrEqual(0.2); |
There was a problem hiding this comment.
Exclude offscreen lazy images from opacity ratio assertion
This assertion divides by all images in the grid, but many images are expected to remain opacity-0 until they enter viewport in lazy-load flows, so the ratio can exceed 20% even when onLoad chaining works correctly. In long grids or small viewports this produces false regressions; scope the denominator to loaded/visible images (or wait for a deterministic loaded subset) before asserting.
Useful? React with 👍 / 👎.
| const response = await page.goto(route, { waitUntil: "domcontentloaded" }); | ||
| expect(response, `Resposta nula para ${route}`).not.toBeNull(); | ||
| expect(response!.status(), `Status HTTP para ${route}`).toBeLessThan(400); |
There was a problem hiding this comment.
Assert deep-route URL is preserved for each route check
Each route test only checks status < 400 and #root visibility, so a server-side redirect (for example to /) can still pass even though the deep-link contract is broken for that route. The suite should also assert new URL(page.url()).pathname === route per case, otherwise several rewrite regressions remain undetected.
Useful? React with 👍 / 👎.
Re-#85 — E2E test battery + audit report. Adições puras (spec files + docs/AUDITORIA_E2E_2026-05-22.md). Originally draft; recreating non-draft to test merge eligibility.
Summary by cubic
Adds an E2E test battery and an audit report to validate recent fixes. Verifies SPA rewrite routing (#42), adds catalog regression specs (#40, #41), standardizes CORS in two edge functions, and aligns load/contract scripts with the correct Supabase project (#36).
New Features
e2e/spa-rewrite.spec.ts(12 tests) to ensure deep routes serve the SPA and refresh works (covers fix(vercel): SPA rewrite — destrava sidebar/header e refresh em rotas profundas #42).e2e/catalog.spec.tswith regression checks for real category names andOptimizedImageload behavior (covers fix(catalog): exibe o nome real da categoria em vez de "Sem categoria" #40, fix(image): cards de produto ficavam com imagem invisível (opacity-0 eterno) #41). Skips without auth creds.docs/AUDITORIA_E2E_2026-05-22.mdwith suite results, gaps, and recommendations.Refactors
supabase/functions/{simulation-orchestrator,sync-external-db}tobuildPublicCorsHeaders+handleCorsPreflight, removing inline CORS and passing all CORS gates.scripts/{contract-testing,massive-load-test}.mjsto use the correct Supabase URL fallback (doufsxqlfjyuvxuezpln) to match fix: aponta cliente Supabase para o banco do usuário (destrava UI) #36.Written for commit acd4550. Summary will update on new commits. Review in cubic