Skip to content

test(chat): bateria de 20 cenarios de simulacao de edge cases [simulacao exaustiva] - #649

Merged
adm01-debug merged 1 commit into
mainfrom
test/chat-simulation-v1
Jul 31, 2026
Merged

test(chat): bateria de 20 cenarios de simulacao de edge cases [simulacao exaustiva]#649
adm01-debug merged 1 commit into
mainfrom
test/chat-simulation-v1

Conversation

@adm01-debug

@adm01-debug adm01-debug commented Jul 31, 2026

Copy link
Copy Markdown
Owner

O que foi adicionado

  • Bateria de simulação de edge cases chatpanel.simulation.test.ts — 20 cenários numerados cobrindo gaps que os testes unitários não cobriam:
    1-3. whisper: regressão anti-fix (envio normal com anexos intacto), contactId JID → toast indisponível sem insert, sem profile → não popula lastFailedSendRef
    4-7. location: sem phone (sendLocation nunca chamado), contactId JID (send chamado, insert não), lat/lng negativos exatos, sendLocation rejeitado (insert nunca chamado)
    8-10. interactive: buttons vazio (sem crash), sem phone (nunca chamado), botão sem title → onSendMessage(id)
    11-17. slash: callbacks ausentes (resolve/star sem crash), subCommands vazios (snooze/tag/note pedem valor), archive/priority honestos (nenhum callback chamado)
    18-19. realtime DELETE: payload.old sem id → não invalida; com id → invalida

Evidências

  • 20/20 testes verdes; suite chat 387/387 (27 files); tsc 5 pré-existentes.
  • Padrões de mock dos testes existentes (vi.mock '@/' absoluto, vi.hoisted).

Summary by CodeRabbit

  • Testes
    • Adicionados 19 cenários de simulação para validar o comportamento do painel de chat.
    • Cobertos envios com anexos, comandos slash, localizações, mensagens interativas e eventos de exclusão em tempo real.
    • Incluídas validações para autenticação ausente e mensagens inválidas.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zapp-web-v3 Ready Ready Preview Jul 31, 2026 4:34pm

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📏 PR acima do ideal — 665 linhas (+665/−0)

Este PR está acima do tamanho ideal de 300 linhas (teto: 800).
Considere dividir se possível — não é obrigatório, mas é recomendado.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d200b69c-77ed-4b65-af7d-bdc3a1dfe0a5

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5df46 and 6e54429.

📒 Files selected for processing (1)
  • src/features/inbox/components/chat/__tests__/chatpanel.simulation.test.ts

Walkthrough

Adiciona um arquivo de testes de simulação com 19 cenários para handlers do chat e ChatMessagesArea. Os testes cobrem envios, whispers, produtos, comandos slash, autenticação, callbacks inválidos e eventos realtime de exclusão.

Changes

Simulações do chat

Layer / File(s) Summary
Infraestrutura e envio do chat
src/features/inbox/components/chat/__tests__/chatpanel.simulation.test.ts
Adiciona mocks, fixtures e utilitários. Testa envios com anexos, mídia, whispers, toasts, callbacks, estado de envio e retry.
Simulações de produtos e entrada
src/features/inbox/components/chat/__tests__/chatpanel.simulation.test.ts
Testa localizações, contatos JID, coordenadas negativas, mensagens interativas, callbacks ausentes, parâmetros inválidos e os comandos /archive e /priority.
Invalidação realtime de mensagens
src/features/inbox/components/chat/__tests__/chatpanel.simulation.test.ts
Valida que payloads DELETE sem old.id não invalidam queries. Payloads com identificador invalidam ['messages'] uma vez.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/features/inbox/components/chat/__tests__/chatpanel.simulation.test.ts

Oops! Something went wrong! :(

ESLint: 10.8.0

SyntaxError: Unexpected token '{'
at compileSourceTextModule (node:internal/modules/esm/utils:318:16)
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:90:18)
at #translate (node:internal/modules/esm/loader:451:20)
at afterLoad (node:internal/modules/esm/loader:507:29)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:512:12)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36)
at afterResolve (node:internal/modules/esm/loader:603:52)
at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:609:12)
at node:internal/modules/esm/loader:628:32
at TracingChannel.tracePromise (node:diagnostics_channel:362:14)


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

@adm01-debug
adm01-debug force-pushed the test/chat-simulation-v1 branch from aa2b006 to 6e54429 Compare July 31, 2026 16:32
@github-actions github-actions Bot added size/L and removed size/L labels Jul 31, 2026
@adm01-debug
adm01-debug merged commit f278fe0 into main Jul 31, 2026
26 of 30 checks passed
@adm01-debug
adm01-debug deleted the test/chat-simulation-v1 branch July 31, 2026 16:33

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

Copy link
Copy Markdown

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: aa2b006055

ℹ️ 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 src/hooks/useContactIntelligence.ts Outdated
Comment on lines 44 to 45
if (digits.length < 8) return null;
return { kind: 'phone', value: sanitizePostgrestFilter(digits) };

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 Route newly admitted LIDs through a valid lookup

For a newly admitted 14+ digit LID, this now proceeds to the phone.eq filter at line 286, but the configured Supabase client queries zapp; supabase/migrations/20260727120000_qa_round_2_3_corrigido_consolidado.sql explicitly records that zapp.contact_intelligence has no phone column and that it exists only on the public view. The request therefore returns 42703, leaves raw null, and the new isLid branch then skips the Evolution fallback, so the advertised LID briefing still cannot load and every such contact adds a failing request. Use a contact-ID join/RPC or the API relation that actually exposes phone.

AGENTS.md reference: AGENTS.md:L11-L15

Useful? React with 👍 / 👎.

Comment thread src/hooks/useContactIntelligence.ts Outdated
Comment on lines +309 to +310
const phoneDigits = ident.kind === 'phone' ? ident.value : null;
const isLid = phoneDigits != null && (phoneDigits.length > 13 || phoneDigits.length < 10);

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 Do not infer LIDs from phone length alone

When an Evolution contact has a valid 14- or 15-digit international E.164 number, this condition classifies it as a LID solely because of its length and skips the evolution_messages fallback. The repository's canonical JID contract explicitly accepts phone-only identifiers of 8–15 digits (src/features/inbox/utils/contactRef.ts:41-53), so these contacts can legitimately have messages under <number>@s.whatsapp.net; whenever their intelligence row is absent or lacks total_messages/days_since_contact, the briefing consequently loses its last-contact data. Preserve the JID suffix/type when resolving the identifier, or probe the exact individual JID instead of using a length heuristic.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant