WebMCP on your site|INEMA.CLUB-PRO

Lesson 8 · 18 min

Test it yourself: run the suite in all three modes, checklist and plan

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
Dark workbench with a laptop running a terminal and an industrial humanoid robot with a black visor watching a second monitor with a browser.

In this lesson you will

  1. 1What the suite checks in each mode
  2. 2A dangerous "optimization" and the test that catches it
  3. 3The checklist before you publish
  4. 4The dated plan for your site

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.

01The course map

Four steps and what each one delivers. Click an exercise to see the "done when".

Day 1Kit and modes

sem, polyfill, nativo

3 exercises

The same page in all three modes, at no cost.

See the lesson
Day 1Tools

register and call

3 exercises

A tool of your own, called by executeTool.

See the lesson
Day 2Confirmation

annotations and gate

3 exercises

Every action with an effect behind Confirmar.

See the lesson
Day 3Test suite

three modes

3 exercises

An automatic test that catches a break before your visitor does.

See the lesson
At the end of the courseA page with WebMCP tools, identical without the API, with confirmation and an automatic test suite.
22 exercises
Click an exercise to see what to do and the "done when".
  1. 1/4

    Kit and modes

    The base: kit installed, secure context and the certainty that the Sem mode (no API) works.

  2. 2/4

    Tools

    Requires step 1. Definition, registration with detection and the result as JSON text.

  3. 3/4

    Confirmation

    Requires step 2. Correct annotations, third-party text as data and the person deciding.

  4. 4/4

    Test suite

    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.

02The full test suite

First the rule tests (node --test, no browser), then testar.mjs in all three modes. No model calls.

Terminal · test suite
cd ~/projetos/formacao-webmcp-site-v72/kit
node --test 2>&1 | grep -E "^ℹ (pass|fail)"
node scripts/testar.mjs; echo "saída: $?"
Example from the repository
ℹ 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.

03Cause the break

The rehearsal copies the page, makes the dangerous swap in the copy and runs the test suite in native mode only.

Terminal · provoked break
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]}"

04Checklist before you publish

Dated: 10/19/2026, spec from 10/16/2026.

1. Fallback

The site works the same without document.modelContext.

No polyfill in production: it is only for the rehearsal.

05Practice

The green battery, the break that gets caught, and your plan. Each exercise ends with a done when.

E1 · Green battery

5 min

Run the full battery.

Done when: node scripts/testar.mjs; echo "saída: $?" → BATERIA: 31/31 ok and saída: 0.

E2 · Catch the break

5 min

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.

E3 · Dated plan

10 min

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.

06Generate your plan with dates

Pick the start date and how much time you have per week.

07Lesson quiz

The explanation appears after your answer.

Question 1 of 4

Which check catches swapping the confirmation for const ok = true?

08In three sentences

Test suiteThree modes, tool identical to the form, confirmation, invalid input, and removal.
BreakThe "decline" case catches anyone who removes the confirmation to speed things up.
PlanA dated checklist and a retest scheduled for when the spec changes.

To go further