E1 · Green battery
5 minRun the full battery.
Done when: node scripts/testar.mjs; echo "saída: $?" → BATERIA: 31/31 ok and saída: 0.
Lesson 8 · 18 min
A tool is only ready when a test proves it works and that the page stays the same without it. The kit's test suite runs with no model in all three modes, compares tool with form, and tests the confirmation and the cleanup. In this lesson you run it, watch a break get caught and leave with a dated plan for your site.
Start the lesson
Goal: run the automatic test suite in all three modes, watch a break get caught and leave with the checklist and the dated plan for your page.
Four steps and what each one delivers. Click an exercise to see the "done when".
sem, polyfill, nativo
3 exercises
The same page in all three modes, at no cost.
See the lessonannotations and gate
3 exercises
Every action with an effect behind Confirmar.
See the lessonthree modes
3 exercises
An automatic test that catches a break before your visitor does.
See the lessonThe base: kit installed, secure context and the certainty that the Sem mode (no API) works.
Requires step 1. Definition, registration with detection and the result as JSON text.
Requires step 2. Correct annotations, third-party text as data and the person deciding.
Requires all three. The suite green, a deliberate break and the plan for your site.
Lifecycle, form and catalog (lessons 4, 6 and 7) go into the generator below.
First the rule tests (node --test, no browser), then testar.mjs in all three modes. No model calls.
cd ~/projetos/formacao-webmcp-site-v72/kit node --test 2>&1 | grep -E "^ℹ (pass|fail)" node scripts/testar.mjs; echo "saída: $?"
ℹ pass 4 ℹ fail 0 == sem Chromium 156.0.8078.4 (Playwright) ok [sem] página sem erro de JavaScript ok [sem] sem rolagem horizontal em 390 px ok [sem] estado WebMCP esperado (sem) · sem ok [sem] busca pelo formulário funciona · of-301 ok [sem] reserva pelo formulário funciona == polyfill ok [polyfill] página sem erro de JavaScript ok [polyfill] sem rolagem horizontal em 390 px ok [polyfill] estado WebMCP esperado (com) · com ok [polyfill] busca pelo formulário funciona · of-301 ok [polyfill] reserva pelo formulário funciona ok [polyfill] as 4 ferramentas do kit registradas · buscar_oficinas, listar_comentarios, minhas_reservas, reservar_vaga ok [polyfill] ferramenta devolve o mesmo que o formulário · of-301 ok [polyfill] a tela mostra o que o agente recebeu · of-301 ok [polyfill] reserva recusada na tela não reserva ok [polyfill] reserva confirmada aparece na tela ok [polyfill] entrada inválida volta erro legível, sem mudar nada · tema inválido: cobol ok [polyfill] ao sair da página as ferramentas saem (AbortSignal) · 0 restantes, toolchange 4x, getTools depois: NotAllowedError ok [polyfill] nenhum erro de JavaScript na sessão do agente == nativo ok [nativo] página sem erro de JavaScript ok [nativo] sem rolagem horizontal em 390 px ok [nativo] estado WebMCP esperado (com) · com ok [nativo] busca pelo formulário funciona · of-301 ok [nativo] reserva pelo formulário funciona ok [nativo] as 4 ferramentas do kit registradas · buscar_oficinas, listar_comentarios, minhas_reservas, reservar_vaga ok [nativo] ferramenta devolve o mesmo que o formulário · of-301 ok [nativo] a tela mostra o que o agente recebeu · of-301 ok [nativo] reserva recusada na tela não reserva ok [nativo] reserva confirmada aparece na tela ok [nativo] entrada inválida volta erro legível, sem mudar nada · tema inválido: cobol ok [nativo] ao sair da página as ferramentas saem (AbortSignal) · 0 restantes, toolchange 4x ok [nativo] nenhum erro de JavaScript na sessão do agente BATERIA: 31/31 ok saída: 0
In the polyfill, getTools after pagehide gives NotAllowedError: it shuts the whole API off. The test accepts both ways of "leaving": zero tools and toolchange fired.
FALHA [nativo] reserva recusada na tela não reserva BATERIA: 12/13 ok saída: 1
Someone replaces the wait for the click with const ok = true to "speed things up". The test suite fails on "reserva recusada na tela não reserva" and exits with 1. That is what it is for.
The rehearsal copies the page, makes the dangerous swap in the copy and runs the test suite in native mode only.
cd ~/projetos/formacao-webmcp-site-v72/kit
E=${TMPDIR:-/tmp}/ensaio-webmcp-site/a8; rm -rf $E; mkdir -p $E; cp -r pagina/. $E/
# the dangerous "optimization": booking without waiting for the person
sed -i 's/const ok = await ui.pedirConfirmacao({ oficina, nome }, signal);/const ok = true;/' $E/ferramentas.mjs
PAGINA=$E node scripts/testar.mjs nativo | grep -E "FALHA|BATERIA"; echo "saída: ${PIPESTATUS[0]}"Dated: 10/19/2026, spec from 10/16/2026.
The site works the same without document.modelContext.
No polyfill in production: it is only for the rehearsal.
validar-catalogo.mjs with 0 errors.
Each tool has one intent and the right annotation.
Every tool with consequentialHint waits for the person.
Battery with the "decline" case passing.
A comment with the spec date in the tools file.
Origin trial token with the end date (Chrome 156) in your calendar.
When the spec changes date, run the battery and reread what changed.
The green battery, the break that gets caught, and your plan. Each exercise ends with a done when.
Run the full battery.
Done when: node scripts/testar.mjs; echo "saída: $?" → BATERIA: 31/31 ok and saída: 0.
Run the provoked-break rehearsal and read the line that failed.
Done when: The block prints FALHA [nativo] reserva recusada na tela não reserva, BATERIA: 12/13 ok and saída: 1.
Generate the plan below with your start date and the hours you have. Write into it the 3 tools from your catalog (lesson 7) and the date when you will run the battery again.
Done when: You downloaded the plan (.md or .ics) and it has the battery retest date.
Pick the start date and how much time you have per week.
The explanation appears after your answer.
Question 1 of 4
Which check catches swapping the confirmation for const ok = true?
Question 2 of 4
Why does the battery compare the tool with the form?
Question 3 of 4
Where does the polyfill go on the published site?
Question 4 of 4
The spec got a new date. First step?
Pick an answer. The explanation shows up after you try.