From 854daf630960ab279cd321e1f6c9760ada769917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?=
Date: Sun, 2 Aug 2026 01:41:53 -0300
Subject: [PATCH] Allow agents to rewrite prior code; stop pinning layout
Tailwind.
Clarify that new Issues track work and do not fence closed-ticket code, and replace brittle className layout assertions with structure/data-slot contracts.
---
.cursor/skills/capture-review-debts/SKILL.md | 4 +--
.cursor/skills/plan-issue/SKILL.md | 1 +
.cursor/skills/plan-issue/plan-template.md | 8 ++++-
.cursor/skills/work-issue/SKILL.md | 8 +++++
docs/AGENT-OPS.md | 4 +++
docs/TESTING.md | 7 +++++
.../campaignHomeActionButton.unit.spec.tsx | 20 +++++--------
tests/unit/campaignHomeLayout.unit.spec.tsx | 29 ++-----------------
.../unit/campaignListPageHeader.unit.spec.ts | 7 ++---
.../campaignQuickActionsDrawer.unit.spec.tsx | 24 ++++++---------
tests/unit/campaignWizardShell.unit.spec.tsx | 27 ++++++++---------
.../homeSearchResultsLayout.unit.spec.tsx | 4 +--
12 files changed, 66 insertions(+), 77 deletions(-)
diff --git a/.cursor/skills/capture-review-debts/SKILL.md b/.cursor/skills/capture-review-debts/SKILL.md
index c834c85c..0f2eb6d8 100644
--- a/.cursor/skills/capture-review-debts/SKILL.md
+++ b/.cursor/skills/capture-review-debts/SKILL.md
@@ -49,7 +49,7 @@ Contra o repositório **antes** de pontuar:
| Check | Ação se verdadeiro |
| ------------------------------------------------------ | --------------------------------------------------------------- |
-| Já no diff / código da sessão | → balde **já_resolvido** (não reabrir) |
+| Já no diff / código da sessão | → balde **já_resolvido** (já coberto nesta sessão — não registrar de novo) |
| Já em `docs/plans/*.md` ou numa Issue (grep + `gh issue list`) | → **absorver** no plano existente ou **descartar** como coberto |
| Pré-existente em `main`, fora do escopo da entrega | → **descartar** deste lote (bug separado só se o usuário pedir) |
| Intentional em `DESIGN.md` / decisão travada | → **descartar** (ex.: field-mode mobile documentado) |
@@ -135,7 +135,7 @@ Para cada lote com destino **registrar** ou **absorver**:
3. Se **absorver** num plano existente: edite o plano (nova fase/seção) — mesmo precedente "Gap vs 2022". **Se a Issue dona do plano estiver `in-progress`, NÃO a edite** — registra como Issue nova com `--depends ` (destrava sozinha quando o pai flipar `done`).
4. Se **defer**: anote o gatilho no plano-pai (Adiado com gatilho / Explicitamente fora) ou na mensagem de triage confirmada — não crie Issue só por isso.
5. No plano, seções obrigatórias além do template:
- - **Já resolvido no simplify/critique (não reabrir)**
+ - **Já resolvido no simplify/critique** (coberto nesta sessão — não registrar de novo; o implementador **pode** ainda mudar esse código numa Issue futura se o fix correcto exigir)
- **Explicitamente fora** (skips dos revisores + descartes + defers com gatilho deste triage)
6. Self-score de decisão ≥4/5 antes de gravar; classe Impeccable A–D conforme o lote (só-backend = A; UX pós-critique = B/C).
diff --git a/.cursor/skills/plan-issue/SKILL.md b/.cursor/skills/plan-issue/SKILL.md
index eab5eebb..350ee7f6 100644
--- a/.cursor/skills/plan-issue/SKILL.md
+++ b/.cursor/skills/plan-issue/SKILL.md
@@ -78,6 +78,7 @@ Ordem topológica intra-lote (o plano do dependente cita o ID do dependido, que
3. **Classificar superfície UI (A–D)** e semear âncoras: `PRODUCT.md`/`DESIGN.md`, design-ref em `docs/design-refs/latest/` se houver, shells existentes. Classe C exige **brief compacto** (persona, job, estratégia de cor, anti-goals) no plano. Proibido: rodar craft/critique/polish aqui.
4. **Dados → decisão → apresentação** ([data-presentation.md](data-presentation.md)) ou `Dados: N/A`.
5. **Decisões caras + doubt (quando couber):** para cada decisão caro-de-reverter (schema, access, Consent, URL imutável, multi-collection), use a forma Opções+Recomendação+rejeitadas. Se a decisão for **não trivial** no sentido de [decision-quality.md](decision-quality.md) § Doubt, faça um ciclo curto CLAIM → adversarial self-check (ou `Task` fresh-context) **antes** de gravar como Decisão travada. Não doubt em rename/copy.
+ - **Continuação de UI/layout:** Issue nova para tracking é OK. **Proibido** travar "Item novo, não reabrir Bxx / Issues fechadas" como desculpa para só patchar localmente e deixar CSS compensatório intacto. Se o sintoma já teve 1+ tickets no mesmo eixo (padding, bleed, snap), a Decisão travada deve dizer **quem possui o inset/altura** e autorizar reescrever o código das Issues anteriores. "Não reabrir Issue fechada" = bookkeeping do GitHub, não cerca de código.
6. **Posicionamento:** prioridade `P0..P3` (jurídico/caminho crítico > base de dados > operação de campo > inteligência > plataforma), `depends` (IDs duros), appetite, janela do calendário eleitoral quando relevante, `serializes` quando toca recurso compartilhado (ex.: migrations).
7. **Fatiar em fases verticais** ([decision-quality.md](decision-quality.md) § Fatias): não “toda a DB → toda a API → toda a UI”. Cada fase = caminho fino ponta a ponta (ou o pedaço mínimo que deixa o sistema verde), com **aceite**, **verify** (`pnpm gate:fast` / pin unit|int / check manual), arquivos prováveis, tamanho S/M. **Fase 1 = tracer bullet** (schema mínimo → uma action → uma superfície, ou o menor path que prova a aposta). High-risk / incerteza primeiro. Se a fatia seria L/XL (≫5 arquivos ou >1 sessão focada) → mais fases **ou** Issue bipartida `{id}-plan` / `{id}-exec`.
8. **Boundaries Teqo** no plano (sempre, compacto): o que esta entrega **Always** / **Ask first** / **Never** — ver template. Defaults do repo (overrideAccess, transação, Consent fail-closed, sem Neon) entram em Always/Never sem inventário genérico.
diff --git a/.cursor/skills/plan-issue/plan-template.md b/.cursor/skills/plan-issue/plan-template.md
index 6f667391..03c5476c 100644
--- a/.cursor/skills/plan-issue/plan-template.md
+++ b/.cursor/skills/plan-issue/plan-template.md
@@ -108,7 +108,13 @@ de produto que originou o item, com data. Responde "por que isso existe".>
+ Decisão repo-wide além deste item → marcar "candidata a doc em docs/" (não criar ADR schema novo sem precedente).
+
+ ANTI-PADRÃO (layout/UI): NÃO escreva "Item novo, não reabrir Bxx / Issues fechadas"
+ como se isso proibisse tocar código antigo. Issue nova = tracking. Se o fix correcto
+ exige reescrever o as-built de Issues fechadas (apagar bleed compensatório, mover
+ ownership de padding), diga isso explicitamente aqui e autorize o work-issue a fazê-lo.
+ "Não reabrir Issue no GitHub" ≠ "não mude o código daquela Issue". -->
- **.** **Rejeitado:** .
- **i18n e naming** seguem o AGENTS.md: identificadores em inglês ( {
expect(screen.getByLabelText('Em breve').getAttribute('aria-disabled')).toBe('true')
})
- it('uses a wider control column for two-line labels (B109)', () => {
+ it('exports a shared control class for two-line labels (B109)', () => {
renderActionButton({ label: 'Registrar', icon: BarChart3 })
const control = screen.getByRole('button', { name: 'Registrar' })
- expect(control.className).toContain('box-content')
- expect(control.className).toContain('w-[5.5rem]')
- expect(actionControlClassName).toContain('box-content')
- expect(actionControlClassName).toContain('w-[5.5rem]')
+ for (const token of actionControlClassName.split(/\s+/).filter(Boolean)) {
+ expect(control.className.split(/\s+/)).toContain(token)
+ }
})
it('opens the description drawer on long-press when the pointer is coarse', () => {
@@ -188,14 +187,11 @@ describe('CampaignHomeActionStrip', () => {
)
const scroller = getScroller(container)
- expect(scroller?.className).toContain('overflow-x-auto')
- expect(scroller?.className).toContain('scrollbar-width:none')
- const list = scroller?.querySelector('ul[role="list"]')
+ expect(scroller).toBeTruthy()
+ expect(scroller.getAttribute('aria-label')).toBe('Ações rápidas')
+ const list = scroller.querySelector('ul[role="list"]')
expect(list).toBeTruthy()
- expect(list?.className).toContain('gap-0')
- expect(list?.className).toContain('px-0')
- expect(list?.className).not.toContain('px-4')
- expect(list?.className).not.toContain('gap-2')
+ expect(list?.querySelectorAll(':scope > li')).toHaveLength(2)
})
it('scrolls horizontally on pointer-fine drag past the threshold', () => {
diff --git a/tests/unit/campaignHomeLayout.unit.spec.tsx b/tests/unit/campaignHomeLayout.unit.spec.tsx
index aee45f74..a9d8c85f 100644
--- a/tests/unit/campaignHomeLayout.unit.spec.tsx
+++ b/tests/unit/campaignHomeLayout.unit.spec.tsx
@@ -4,14 +4,6 @@ import { describe, expect, it } from 'vitest'
import { CampaignHomeLayout } from '@/components/campaign/dashboard/CampaignHomeLayout'
describe('CampaignHomeLayout', () => {
- it('fills the scrollport height on mobile', () => {
- const { container } = render(Actions block
} />)
-
- const root = container.firstElementChild
- expect(root?.className).toContain('h-full')
- expect(root?.className).toContain('min-h-0')
- })
-
it('renders actions in the home-actions slot inside home-dock', () => {
const { container } = render(Actions block} />)
@@ -20,24 +12,12 @@ describe('CampaignHomeLayout', () => {
expect(actions?.closest('[data-slot="home-dock"]')).not.toBeNull()
})
- it('bleeds home-actions edge-to-edge on mobile (compensates scroll p-4)', () => {
- const { container } = render(Actions block} />)
-
- const actions = container.querySelector('[data-slot="home-actions"]')
- expect(actions?.className).toContain('-mx-4')
- expect(actions?.className).toContain('w-[calc(100%+2rem)]')
- expect(actions?.className).toContain('md:mx-0')
- expect(actions?.className).toContain('md:w-auto')
- })
-
- it('does not clip horizontal bleed on the actions retraction shell', () => {
+ it('allows horizontal bleed on the actions retraction shell', () => {
const { container } = render(Actions block} />)
const actionsChrome = container.querySelector('[data-slot="home-actions-chrome"]')
const bleedWrapper = actionsChrome?.querySelector('[data-allow-horizontal-bleed="true"]')
expect(bleedWrapper).not.toBeNull()
- expect(bleedWrapper?.className).toContain('overflow-y-hidden')
- expect(bleedWrapper?.className).not.toContain('overflow-hidden')
})
it('renders search slot inside home-dock when provided', () => {
@@ -68,8 +48,6 @@ describe('CampaignHomeLayout', () => {
expect(chrome).not.toBeNull()
expect(spacer).not.toBeNull()
expect(spacer?.getAttribute('aria-hidden')).toBe('true')
- expect(spacer?.className).toContain('flex-1')
- expect(spacer?.className).toContain('md:hidden')
expect(chrome?.nextElementSibling?.getAttribute('data-slot')).toBe('home-dock')
})
@@ -85,12 +63,11 @@ describe('CampaignHomeLayout', () => {
const homeChrome = container.querySelector('[data-slot="home-chrome"]')
expect(homeChrome?.getAttribute('data-retracted')).toBe('true')
- expect(homeChrome?.className).toContain('grid-rows-[0fr]')
- expect(homeChrome?.className).toContain('opacity-0')
+ expect(homeChrome?.getAttribute('aria-hidden')).toBe('true')
const actionsChrome = container.querySelector('[data-slot="home-actions-chrome"]')
expect(actionsChrome?.getAttribute('data-retracted')).toBe('true')
- expect(actionsChrome?.className).toContain('grid-rows-[0fr]')
+ expect(actionsChrome?.getAttribute('aria-hidden')).toBe('true')
expect(container.querySelector('[data-slot="home-thumb-spacer"]')).not.toBeNull()
expect(container.querySelector('[data-slot="home-summary"]')).not.toBeNull()
diff --git a/tests/unit/campaignListPageHeader.unit.spec.ts b/tests/unit/campaignListPageHeader.unit.spec.ts
index 2f6780f9..c81e29a6 100644
--- a/tests/unit/campaignListPageHeader.unit.spec.ts
+++ b/tests/unit/campaignListPageHeader.unit.spec.ts
@@ -6,7 +6,7 @@ import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignLis
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
describe('CampaignListPageHeader (B118)', () => {
- it('keeps h1 in the DOM with sr-only on mobile and hides subtitle and scope chip below md', () => {
+ it('keeps h1 in the DOM with sr-only chrome on mobile (B118)', () => {
const html = renderToStaticMarkup(
createElement(CampaignListPageHeader, {
title: 'Municípios',
@@ -17,11 +17,8 @@ describe('CampaignListPageHeader (B118)', () => {
expect(html).toContain(' {
expect(screen.getByRole('button', { name: 'Mostrar ações rápidas' })).toBeTruthy()
})
- it('bleeds the action strip edge-to-edge inside the drawer gutter (B101)', () => {
+ it('mounts the action strip inside the drawer context (B101)', () => {
vi.mocked(postCampaignJson).mockResolvedValue({
ok: true,
payload: idleSuggestPayload,
@@ -171,10 +171,8 @@ describe('CampaignQuickActionsDrawer (B105)', () => {
)
const context = document.getElementById('quickActionContext')
- const stripBleed = context?.firstElementChild
- expect(stripBleed?.className).toContain('-mx-4')
- expect(stripBleed?.className).toContain('w-[calc(100%+2rem)]')
- expect(stripBleed?.querySelector('[aria-label="Ações rápidas"]')).not.toBeNull()
+ expect(context?.querySelector('[aria-label="Ações rápidas"]')).not.toBeNull()
+ expect(screen.getByRole('link', { name: 'Registrar' })).toBeTruthy()
})
it('posts home-search when the drawer query is active', async () => {
@@ -365,7 +363,7 @@ describe('CampaignQuickActionsDrawer (B105)', () => {
expect((screen.getByLabelText('Buscar na campanha') as HTMLInputElement).value).toBe('')
})
- it('uses compact bottom stack spacing in the drawer (B112)', () => {
+ it('keeps search results under the drawer search stack (B112)', () => {
vi.mocked(postCampaignJson).mockResolvedValue({
ok: true,
payload: idleSuggestPayload,
@@ -374,11 +372,10 @@ describe('CampaignQuickActionsDrawer (B105)', () => {
renderQuickActionsChrome()
const context = document.getElementById('quickActionContext')
- expect(context?.className).toContain('gap-1')
- expect(context?.className).toContain('pb-[max(0.25rem,env(safe-area-inset-bottom,0px))]')
-
- const searchStack = document.querySelector('[data-slot="home-search-results"]')?.parentElement
- expect(searchStack?.className).toContain('gap-1.5')
+ expect(context).not.toBeNull()
+ const results = document.querySelector('[data-slot="home-search-results"]')
+ expect(results).not.toBeNull()
+ expect(context?.contains(results)).toBe(true)
})
it('toggles between dock and collapsed from the handle', () => {
@@ -430,7 +427,7 @@ describe('CampaignQuickActionsDrawer (B105)', () => {
})
describe('CampaignContentScroll quick-actions direction (B105)', () => {
- it('uses compact bottom padding on Início when quick-actions peek is off (B116)', () => {
+ it('marks compact home bottom padding on Início when quick-actions peek is off (B116)', () => {
render(
@@ -439,9 +436,6 @@ describe('CampaignContentScroll quick-actions direction (B105)', () => {
const scrollport = document.querySelector('[data-slot="campaign-content-scroll"]')
expect(scrollport?.getAttribute('data-home-compact-bottom-padding')).toBe('true')
- expect(scrollport?.className).toContain('pb-2')
- expect(scrollport?.className).toContain('px-4')
- expect(scrollport?.className).not.toContain(' p-4')
})
it('collapses on scroll down and re-docks on scroll up', () => {
diff --git a/tests/unit/campaignWizardShell.unit.spec.tsx b/tests/unit/campaignWizardShell.unit.spec.tsx
index f69f7a11..44ddff82 100644
--- a/tests/unit/campaignWizardShell.unit.spec.tsx
+++ b/tests/unit/campaignWizardShell.unit.spec.tsx
@@ -102,7 +102,7 @@ describe('CampaignWizardShell', () => {
expect(main.getAttribute('aria-label')).toBe(wizardFlowChromeAriaLabel('Ajustar votos'))
})
- it('uses tighter top padding on mobile when step title is omitted', () => {
+ it('renders main without step title when step title is omitted', () => {
const { container } = renderWizardShell({
flowTitle: 'Ajustar votos',
stepTitle: null,
@@ -112,10 +112,8 @@ describe('CampaignWizardShell', () => {
})
const main = container.querySelector('main')
- expect(main?.className).toMatch(/pt-2/)
- expect(main?.className).not.toMatch(/pt-3/)
- expect(main?.className).toMatch(/pb-6/)
- expect(main?.className).toMatch(/md:py-6/)
+ expect(main).not.toBeNull()
+ expect(main?.getAttribute('aria-label')).toBe(wizardFlowChromeAriaLabel('Ajustar votos'))
})
it('skips title focus when contentFocus is none', () => {
@@ -194,7 +192,7 @@ describe('CampaignWizardShell', () => {
expect(document.activeElement).toBe(screen.getByRole('heading', { level: 1, name: 'Passo 2' }))
})
- it('shows municipality caption in main on desktop breakpoint classes', () => {
+ it('shows municipality caption in main', () => {
const { container } = renderWizardShell({
flowTitle: 'Ajustar votos',
stepTitle: 'Pergunta',
@@ -204,12 +202,16 @@ describe('CampaignWizardShell', () => {
children: null,
})
- const caption = container.querySelector('main p.md\\:block')
- expect(caption?.textContent).toBe('Cairu')
- expect(caption?.className).toMatch(/md:block/)
+ const main = container.querySelector('main')
+ expect(main).not.toBeNull()
+ expect(
+ within(main as HTMLElement)
+ .getByText('Cairu')
+ .tagName.toLowerCase(),
+ ).toBe('p')
})
- it('uses tighter top padding on mobile main content', () => {
+ it('renders main content for the municipality entry step', () => {
const { container } = renderWizardShell({
flowTitle: 'Ajustar votos',
stepTitle: WIZARD_MUNICIPALITY_STEP_TITLE,
@@ -219,8 +221,7 @@ describe('CampaignWizardShell', () => {
})
const main = container.querySelector('main')
- expect(main?.className).toMatch(/pt-3/)
- expect(main?.className).toMatch(/pb-6/)
- expect(main?.className).toMatch(/md:py-6/)
+ expect(main).not.toBeNull()
+ expect(within(container).getByText(WIZARD_MUNICIPALITY_STEP_TITLE)).toBeTruthy()
})
})
diff --git a/tests/unit/homeSearchResultsLayout.unit.spec.tsx b/tests/unit/homeSearchResultsLayout.unit.spec.tsx
index 5ab0334c..c9600f0e 100644
--- a/tests/unit/homeSearchResultsLayout.unit.spec.tsx
+++ b/tests/unit/homeSearchResultsLayout.unit.spec.tsx
@@ -40,9 +40,7 @@ describe('HomeSearchResultsLayout', () => {
)
const layout = container.querySelector('[data-slot="home-search-results-layout"]')
- expect(layout?.className).toContain('flex-col')
- expect(layout?.className).toContain('md:grid-cols-2')
- expect(layout?.className).toContain('lg:grid-cols-3')
+ expect(layout).not.toBeNull()
expect(screen.getByText('Group A')).toBeTruthy()
expect(screen.getByText('Group B')).toBeTruthy()
})