Skip to content

test(e2e): bateria abrangente + relatório auditoria (re-#85)#94

Closed
adm01-debug wants to merge 1 commit into
mainfrom
claude/e2e-test-battery-9lNtU
Closed

test(e2e): bateria abrangente + relatório auditoria (re-#85)#94
adm01-debug wants to merge 1 commit into
mainfrom
claude/e2e-test-battery-9lNtU

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 22, 2026

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).

Written for commit acd4550. Summary will update on new commits. Review in cubic

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
Copilot AI review requested due to automatic review settings May 22, 2026 09:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Warning

Rate limit exceeded

@adm01-debug has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 57 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81df5a16-77aa-4da0-9222-984669e75695

📥 Commits

Reviewing files that changed from the base of the PR and between 54b917c and acd4550.

📒 Files selected for processing (7)
  • docs/AUDITORIA_E2E_2026-05-22.md
  • e2e/catalog.spec.ts
  • e2e/spa-rewrite.spec.ts
  • scripts/contract-testing.mjs
  • scripts/massive-load-test.mjs
  • supabase/functions/simulation-orchestrator/index.ts
  • supabase/functions/sync-external-db/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/e2e-test-battery-9lNtU

Comment @coderabbitai help to get the list of available commands and usage tips.

@adm01-debug
Copy link
Copy Markdown
Owner Author

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 claude/e2e-test-battery-9lNtU preservado no remote para rebase manual + reabertura quando o Abner rotacionar o PAT.

@supabase
Copy link
Copy Markdown

supabase Bot commented May 22, 2026

Updates to Preview Branch (claude/e2e-test-battery-9lNtU) ↗︎

Deployments Status Updated
Database ⚠️ Fri, 22 May 2026 09:58:06 UTC
Services ⚠️ Fri, 22 May 2026 09:58:06 UTC
APIs ⚠️ Fri, 22 May 2026 09:58:06 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Fri, 22 May 2026 09:58:32 UTC
Migrations ⏸️ Fri, 22 May 2026 09:55:25 UTC
Seeding ⏸️ Fri, 22 May 2026 09:55:25 UTC
Edge Functions ⏸️ Fri, 22 May 2026 09:55:25 UTC

❌ Branch Error • Fri, 22 May 2026 09:58:32 UTC

unexpected status 400: {"message":"Resource has been removed"}
unexpected status 400: {"message":"Resource has been removed"}
unexpected status 400: {"message":"Resource has been removed"}
unexpected status 400: {"message":"Resource has been removed"}

⚠️ Warning — Service health check failed


View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread e2e/catalog.spec.ts
Comment on lines +85 to +89
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/catalog.spec.ts
Comment on lines +116 to +120
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 });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/spa-rewrite.spec.ts
Comment on lines +14 to +16
* 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).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/spa-rewrite.spec.ts
Comment on lines +70 to +73
'link[rel="modulepreload"][href^="/assets/"], link[rel="stylesheet"][href^="/assets/"]',
);
const script = document.querySelector<HTMLScriptElement>('script[src^="/assets/"]');
return link?.href ?? script?.src ?? null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/catalog.spec.ts
Comment on lines +96 to +100
const ratio = countSem / totalCards;
expect(
ratio,
`${countSem}/${totalCards} cards ainda exibem 'Sem categoria' (regressão do fix #40)`,
).toBeLessThanOrEqual(0.05);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/catalog.spec.ts
Comment on lines +133 to +136
expect(
opacityZero / totalImgs,
`${opacityZero}/${totalImgs} imgs ficaram com opacity-0 após carga`,
).toBeLessThanOrEqual(0.2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread e2e/spa-rewrite.spec.ts
Comment on lines +41 to +43
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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@adm01-debug adm01-debug review requested due to automatic review settings May 22, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants