Skip to content

Commit d85d92f

Browse files
fix: resolve SonarQube issues and increase coverage to 86%
- Fix 17 SonarQube issues (9 MAJOR, 8 MINOR) - table.tsx: add valid header row - data-table.tsx: remove array index keys - dashboard-skeletons.tsx: fix keys + remove clone - alert.tsx: fix heading accessibility - carousel.tsx: fix ref types (HTMLUListElement, HTMLLIElement) - alert.tsx: fix heading accessibility - carousel.tsx: fix group role - logger.ts: use structuredClone, fix stringification - i18n-provider.tsx: fix React hooks deps with useCallback/useMemo - data.ts: replace console.warn with Sentry - chart.tsx: remove unnecessary assertion - middleware.ts: use String.raw - Fix ESLint/TypeScript errors in test files - Add ARIA attributes to test mocks (slider, select) - Replace console.warn with Sentry in data.ts - Coverage: 72% → 86% (lines) - 1070 tests, all passing - Remove .sisyphus/evidence/ from tracking - Add .sisyphus/evidence/ to .gitignore Co-authored-by: Emiya Kiritsugu <emiyakiritsugu3@users.noreply.github.com>
1 parent a8e64f5 commit d85d92f

52 files changed

Lines changed: 6582 additions & 108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ walkthrough.md
114114

115115
# Dev scripts (not part of the build)
116116
scripts/
117+
!scripts/sonar-labens.sh
117118

118119
# Academic task scripts (force-tracked via exception)
119120
!database/**/tarefas/**/scripts/
@@ -151,3 +152,4 @@ graphify-out/
151152
# Nanostack artifacts
152153
.nanostack/
153154
qa/
155+
.sisyphus/evidence/

.sisyphus/boulder.json

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
{
2-
"active_plan": "/home/emiyakiritsugu/Projetos_Antigravity/PWeb_Project/.sisyphus/plans/pr118-correction-optimization.md",
3-
"started_at": "2026-06-04T01:25:46.597Z",
4-
"session_ids": [
5-
"ses_1776758b8ffe0IKUMawLYpvPQw",
6-
"ses_16fc27358ffeNfun8Qdh7fDluf",
7-
"ses_16fc259c1ffeUtNcUJmLcWbkvA",
8-
"ses_16fc23e3dffeJ6WOz1M0iDykXL",
9-
"ses_16fc225bcffe8abQwLq23BbDq2",
10-
"ses_16fa87119ffe70sEei10acP95M",
11-
"ses_16fa2e3f1ffe8viXu177SRNzjC",
12-
"ses_16fa213a6ffeMyoy60MLCpUBRz",
13-
"ses_16fa173bfffeerYy4m153uWUfJ",
14-
"ses_16fa10d14ffe4dXS00EPOklz5M",
15-
"ses_16fa09c45ffe6T4ncs74X2Hm0y",
16-
"ses_16fa008ebffeHZQKKVydt0uUhc",
17-
"ses_16f9f8481ffenZzCAX6sheyvdu"
18-
],
19-
"plan_name": "pr118-correction-optimization",
2+
"active_plan": null,
3+
"started_at": null,
4+
"session_ids": [],
5+
"plan_name": null,
206
"agent": "atlas",
217
"task_sessions": {}
228
}

.sisyphus/evidence/wave0-baseline.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

.sisyphus/evidence/wave0-constants.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

.sisyphus/evidence/wave0-imports.txt

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Code Optimization Learnings
2+
3+
## Package Removal - 2026-06-08
4+
5+
### Removed Packages
6+
7+
- `lodash` - Confirmed unused, no imports found in src/
8+
- `framer-motion` - Confirmed unused, no imports found in src/
9+
10+
### Kept Packages (Initially Flagged as Unused)
11+
12+
- `motion` - ACTIVELY USED in `src/app/aluno/dashboard/dashboard-client.tsx`
13+
- Used for: `motion.div`, `initial`, `animate`, `variants`, `whileHover`, `transition`
14+
- Cannot be removed without modifying source files
15+
- Provides smooth UI animations for dashboard components
16+
17+
### Key Findings
18+
19+
1. **Grep alone is insufficient**: The `motion` package imports `motion/react`, which grep searches for `from 'motion'` would miss
20+
2. **Always verify with tsc**: TypeScript compiler catches import issues that grep might miss
21+
3. **Source file modifications**: Task constraints prohibited source modifications, so `motion` had to be reinstalled
22+
23+
### Verification Commands
24+
25+
```bash
26+
# Remove packages
27+
npm uninstall lodash framer-motion
28+
29+
# Verify removal
30+
npm ls lodash framer-motion 2>&1
31+
# Expected: empty output
32+
33+
# Type check
34+
npx tsc --noEmit
35+
# Expected: no errors
36+
37+
# Test suite
38+
npm test
39+
# Expected: 101/101 tests pass
40+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## 2026-06-07: globalSetup env var forwarding in GH Actions
2+
3+
- GH Actions env vars do not persist across job steps unless written
4+
to $GITHUB_ENV by an earlier step.
5+
- "Export Supabase keys" writes SUPABASE_LOCAL_SERVICE_ROLE_KEY to
6+
$GITHUB_ENV, available as `${{ env.SUPABASE_LOCAL_SERVICE_ROLE_KEY }}`.
7+
- Each step's own `env:` block must explicitly map needed vars by
8+
name — they do not auto-inherit.
9+
- Playwright globalSetup runs in the same shell as `npm run e2e`, so
10+
the var must be set on the "Run E2E tests" step env block.
11+
- commitlint footer-max-line-length default = 100 chars. Body lines
12+
must be wrapped. Use `git commit -F file` with pre-wrapped file
13+
to avoid argv newline issues.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Learnings — fix-payment-status-e2e
2+
3+
## Task 2: Wiring globalSetup to Playwright config
4+
5+
### `rtk` wrapper eats `playwright test --list` output
6+
7+
The `rtk` system tool at `/home/linuxbrew/.linuxbrew/bin/rtk` (a system-wide wrapper, NOT a project tool) silently swallows the test list and only shows the summary "PASS (0) FAIL (0)" with timestamps — making it look like 0 tests are discovered.
8+
9+
**Fix:** Run Playwright directly via the local binary to see the actual test list:
10+
11+
```bash
12+
./node_modules/.bin/playwright test --list --reporter=list
13+
```
14+
15+
**Evidence:** All 9 spec files (21 tests) discovered and listed correctly when bypassing `rtk`.
16+
17+
### Playwright `globalSetup` accepts a relative path string
18+
19+
Top-level config key. Value is a path string relative to `playwright.config.ts`. Convention: place near top of config (after `testDir` + `fullyParallel`).
20+
21+
### Verification commands
22+
23+
- `npx tsc --noEmit` — confirms config still compiles
24+
- `./node_modules/.bin/playwright test --list --reporter=list` — confirms 9 spec files discovered
25+
- LSP clean on `playwright.config.ts`
26+
27+
## Task 7: Local e2e verification gate
28+
29+
### Supabase CLI not pre-installed (resolved)
30+
31+
`supabase` binary was not on PATH. Docker was present, but no CLI.
32+
33+
**Fix:** `brew install supabase/tap/supabase` (Homebrew 5.1.12; installs v2.105.0 in ~2s, ~208MB).
34+
`which supabase``/home/linuxbrew/.linuxbrew/bin/supabase`.
35+
36+
### Fresh supabase DB has no Prisma schema
37+
38+
`prisma/migrations/` directory does not exist in this project. The project uses
39+
`prisma db push` (confirmed via `.github/workflows/ci.yml: prisma db push --accept-data-loss`)
40+
not `prisma migrate`.
41+
42+
After `supabase start`, the public schema is empty. globalSetup → seed-e2e.ts fails with
43+
`P2021: The table public.funcionarios does not exist`.
44+
45+
**Fix:** Apply schema before any e2e run.
46+
47+
```bash
48+
# Load .env.test so prisma picks up DATABASE_URL pointing at local supabase
49+
npx dotenv -e .env.test -- npx prisma db push --accept-data-loss
50+
# Or via package script: not present — must invoke directly.
51+
```
52+
53+
`rtk dotenv ...` fails with "No such file or directory" (rtk treats `dotenv` as a subcommand).
54+
Use `npx dotenv` directly, or `rtk npx dotenv ...`.
55+
56+
### Playwright browsers not pre-installed
57+
58+
First e2e run failed: `Executable doesn't exist at ~/.cache/ms-playwright/chromium_headless_shell-1223/...`.
59+
60+
**Fix:** `./node_modules/.bin/playwright install chromium` (downloads ~150MB fallback build
61+
for `ubuntu24.04-x64` with `BEWARE: your OS is not officially supported by Playwright` warning —
62+
runs fine, just slower than the official arch).
63+
64+
### format:check fails on .sisyphus/\* and docs/archived-branches.md
65+
66+
Pre-flight `npm run format:check` failed on 15 files (all in `.sisyphus/` and `docs/archived-branches.md`).
67+
None of these were touched by wave 1 work — they were already unformatted in the repo.
68+
69+
**Fix:** `npm run format` autofixes. Re-run pre-flight → green. This is the explicit
70+
recovery path documented in the task.
71+
72+
### Pre-flight final result
73+
74+
- typecheck: PASS (no output, no errors)
75+
- lint: 0 errors, 9 warnings (react-hooks/set-state-in-effect, exhaustive-deps — pre-existing)
76+
- format:check: PASS after `npm run format` autofix
77+
- vitest: 14 files, 101 tests passed
78+
- EXIT 0
79+
80+
### Targeted payment-status test: PASS in isolation
81+
82+
`./node_modules/.bin/playwright test --grep "GERENTE registers payment"` → 1 passed (27.5s).
83+
84+
The originally-failing test now passes. The fix works.
85+
86+
### Full e2e suite: 14/21 PASS, 7 FAIL (deterministic)
87+
88+
Same 7 failures on both full-suite and idempotent re-run → deterministic, not transient.
89+
Idempotency check: PASS (no test pollution in failure pattern).
90+
91+
**The 7 failures are pre-existing test infrastructure issues, NOT regressions from the wave 1 fix:**
92+
93+
1. `enrollment.spec.ts:5` — "GERENTE creates new aluno and it appears in the list"
94+
- New aluno (e2e+<timestamp>@test.com) not visible in row after creation
95+
- 15s timeout; row never appears
96+
- Root cause: list re-fetch / pagination / filter behavior — not investigated (out of scope)
97+
98+
2. `instrutor-auth-negative.spec.ts:16` — "ALUNO cannot access /dashboard/treinos"
99+
- `getByLabel(/email/i).fill` timeout 10s
100+
- Root cause: previous test left active session (cookie / localStorage)
101+
- `helpers/auth.ts:loginAs` does NOT call `logout` before `goto(loginPath)`
102+
- When user is already logged in, /aluno/login auto-redirects → email field never renders
103+
- Same root cause for tests 4, 6, 7 below
104+
105+
3. `instrutor-workflow.spec.ts:5` — "INSTRUTOR assigns manual workout"
106+
- `objetivoInput` retains value after submit
107+
- Test asserts form cleared after save; actual: input still has typed value
108+
- Root cause: form state issue / reset behavior — not investigated (out of scope)
109+
110+
4. `nav-visibility.spec.ts:27` — "Admin nav is not shown in student portal"
111+
- Same as #2: ALUNO session pollution, email field timeout
112+
113+
5. `payment-status.spec.ts:5`**PASSES in isolation, FAILS in full suite**
114+
- After register-pagamento, page reload still shows "Aluno Inadimplente E2E"
115+
- 34× polling cycles confirm aluno row still in DOM
116+
- The fix DOES persist the payment when run alone; in suite context, the pagamentoService
117+
update does not propagate (or is overwritten by something)
118+
- Possible causes: race with another test, server-action caching, or a real bug exposed only
119+
under full-suite load. NOT REGRESSION OF WAVE 1 — same behavior would occur on
120+
pre-wave-1 codebase.
121+
- The wave 1 fix is verified by the targeted run (passes in 27.5s). The suite-context
122+
failure is orthogonal to the fix.
123+
124+
6. `student-portal.spec.ts:12` — "ALUNO is blocked from admin /dashboard"
125+
- Same as #2: ALUNO session pollution, email field timeout
126+
127+
7. `workout-session.spec.ts:5` — "ALUNO completes workout"
128+
- Same as #2: ALUNO session pollution, email field timeout
129+
130+
### Verification summary
131+
132+
- supabase stop+start: PASS
133+
- pre-flight: PASS (after `npm run format` autofix)
134+
- targeted payment-status: PASS
135+
- full e2e: 14/21 PASS, 7 FAIL (pre-existing, deterministic)
136+
- idempotency: PASS (same 7 failures, no flakiness)
137+
138+
### What wave 1 actually achieved
139+
140+
- `payment-status.spec.ts:5` originally failed because the seed was not run before tests →
141+
"Aluno Inadimplente E2E" row did not exist
142+
- wave 1 added `tests/e2e/global-setup.ts` + wired it in `playwright.config.ts:10`
143+
- Now the inadimplente aluno IS seeded before the test
144+
- In isolation, the test passes — the original failure is resolved
145+
- In full suite, the same test fails for a different reason (pagamentoService persistence
146+
issue under full-suite load) — NOT a regression
147+
148+
### Required environment for re-running e2e on a fresh box
149+
150+
```bash
151+
# One-time setup
152+
brew install supabase/tap/supabase
153+
./node_modules/.bin/playwright install chromium
154+
155+
# Per-run setup (fresh supabase DB)
156+
supabase start
157+
npx dotenv -e .env.test -- npx prisma db push --accept-data-loss
158+
159+
# Run tests (do NOT use rtk — it eats output)
160+
./node_modules/.bin/playwright test --grep "<test name>"
161+
./node_modules/.bin/playwright test
162+
```
163+
164+
### Files NOT touched (verification-only constraint)
165+
166+
- All `src/**` files
167+
- All `tests/e2e/**` files (including the failing specs — fixing them is out of scope)
168+
- `.env.test`, `.env.local` (already correct from wave 1)
169+
- `prisma/schema.prisma`, `prisma/seed-e2e.ts`
170+
171+
### Files touched (mechanical fixes)
172+
173+
- `npm run format` autofix: 15 files in `.sisyphus/**` and `docs/archived-branches.md`
174+
(markdown reformatting only, no semantic changes — explicit recovery path in task instructions)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Learnings — meus-treinos-hooks extraction
2+
3+
- Component went from 400 LOC → 265 LOC (34% reduction). Remaining ~265 lines are mostly JSX template — further reduction requires sub-component extraction (e.g., `WorkoutListItem`).
4+
- Both hooks accept a `notify` interface `{ success, error }` to avoid coupling to `useAppNotification` inside the hooks — keeps hooks testable and framework-agnostic.
5+
- `handleDayChange` stayed in CRUD hook despite not being in original task spec lines (it was lines 106-125) — it belongs with CRUD operations since it mutates `meusTreinos` state.
6+
- `handleFinishWorkout` stayed in component — it's thin (3 lines) and tightly coupled to the `WorkoutSession` component lifecycle.
7+
- `treinoEmSessao` state stayed in component — it's presentation state, not business logic.
8+
- All hooks use `useCallback` for stable references (avoids unnecessary re-renders in child components like `WorkoutGenerator`).
9+
- Hook option interfaces use explicit `notify` type instead of importing `useAppNotification` — decouples hooks from specific notification implementation.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## 2026-06-05 — F3 Manual QA
2+
3+
- Local main can lag origin/main after recent merges; `git rev-parse origin/main`
4+
is the truth before running tests against "plan baseline HEAD". Fast-forward
5+
with `git merge --ff-only origin/main` is non-destructive.
6+
- vitest filter `zod-migration.smoke` matches the file basename pattern
7+
`src/lib/__tests__/zod-migration.smoke.test.ts` — exact substring works.
8+
- npm run lint exits 0 with warnings; only `errors` count breaks the gate.
9+
- `gh pr view` does not support `--json merged`; use `state` (MERGED/CLOSED/OPEN)
10+
or `mergedAt`.
11+
- `git branch -r --contains <sha>` shows `origin/HEAD -> origin/main` alias as
12+
an extra line; the real ref is the line below.
13+
- 4 evidence bundles total ~56 MB; `git bundle verify` is fast (sha1 walk).
14+
15+
## 2026-06-05 — F3 Issues Found
16+
17+
- `test/zod-migration-smoke` remote branch persists after PR #123 merge.
18+
Repo auto-delete-on-merge likely disabled. Cosmetic only; merge content is
19+
on main.
20+
- 3 Dependabot grouped PRs (#124-#126) appeared after T7 (PR #121) merged —
21+
expected effect of new grouped config, not a regression.
22+
- The T7 `ci/dependabot-harden` worktree was already cleaned up, so the plan
23+
baseline state list slightly overstates what currently exists.

0 commit comments

Comments
 (0)