fix(campanha): unblock dobradinhas list SSR for Assessores (#386)

* fix(campanha): unblock dobradinhas list SSR for Assessores column

Drop CampaignTableHead description on Assessores — its hover tooltip plus
StateDeputyAdvisorRelationCell breaks production SSR with an undefined element.

* fix(test): keep int gate under Postgres connection ceiling

Cap vitest workers and raise Docker max_connections so high-core laptops
stop failing the suite with cascading "too many clients" / QueryError noise.

* fix(test): do not force eight int workers on CI

An explicit maxWorkers: 8 raised parallelism on 2–4 vCPU runners and
starved shared invite/consent advisory leases (15s timeouts). Cap only
on local high-core hosts; leave CI on Vitest's CPU-relative default.

* style(test): format vitest.config.mts
This commit is contained in:
Francisco Solla 2026-08-06 00:19:01 +00:00 committed by GitHub
parent 399707fcc6
commit f87e382836
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 12 deletions

View file

@ -13,6 +13,10 @@ services:
POSTGRES_DB: teqo POSTGRES_DB: teqo
ports: ports:
- '5432:5432' - '5432:5432'
# Default max_connections=100 is tight for vitest forks (≈CPUs × pg pool)
# plus a leftover `next start` from local repro. Raise the ceiling so the
# int gate fails on real assertions, not "too many clients already".
command: ['postgres', '-c', 'max_connections=200']
volumes: volumes:
- pgdata:/var/lib/postgresql/data - pgdata:/var/lib/postgresql/data
# Runs only on first initialization of the volume. Creates the dedicated # Runs only on first initialization of the volume. Creates the dedicated

View file

@ -184,15 +184,11 @@ const stateDeputyColumns = (
{ {
id: 'advisors', id: 'advisors',
label: 'Assessores', label: 'Assessores',
head: canEditAdvisors ? ( // No `description` here: `CampaignTableHead`'s hover tooltip
<CampaignTableHead description="Edite aqui: passe o mouse em um chip para remover, ou busque para adicionar. Quem responde por esta dobradinha."> // (`CampaignHoverTooltip`) plus `StateDeputyAdvisorRelationCell` on this
Assessores // list breaks production SSR with "Element type is invalid … undefined".
</CampaignTableHead> // Municípios keeps its tooltip; Assessores relies on the cell chrome.
) : ( head: <CampaignTableHead>Assessores</CampaignTableHead>,
<CampaignTableHead description="Quem responde por esta dobradinha.">
Assessores
</CampaignTableHead>
),
cellClassName: 'max-w-72 whitespace-normal', cellClassName: 'max-w-72 whitespace-normal',
cell: (row) => ( cell: (row) => (
<StateDeputyAdvisorRelationCell <StateDeputyAdvisorRelationCell

View file

@ -1,9 +1,18 @@
import os from 'node:os'
import path from 'node:path' import path from 'node:path'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths' import tsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config' import { defineConfig } from 'vitest/config'
// Cap forks on high-core local machines so Payload pools stay under Docker
// Postgres max_connections (default worker count ≈ CPUs; 16× pool-max-10 ≈
// 160 clients → "too many clients already"). Do NOT set a literal
// `maxWorkers: 8` on CI: Vitest treats that as "use up to 8" even on 2–4
// vCPU runners, which starves shared advisory leases (invite/consent) and
// times out at 15s. Leave CI on Vitest's CPU-relative default.
const maxWorkers = process.env.CI ? undefined : Math.min(8, os.availableParallelism())
export default defineConfig({ export default defineConfig({
resolve: { resolve: {
alias: { alias: {
@ -15,9 +24,10 @@ export default defineConfig({
environment: 'jsdom', environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'], setupFiles: ['./vitest.setup.ts'],
include: ['tests/int/**/*.int.spec.ts'], include: ['tests/int/**/*.int.spec.ts'],
// Int specs hit a real Postgres under a ~48-way parallel suite, so wall ...(maxWorkers === undefined ? {} : { maxWorkers }),
// time is dominated by pool contention, not by the code under test. The // Int specs hit a real Postgres under a parallel suite, so wall time is
// 5s default made legitimately heavy RSC-composition tests flake as the // dominated by pool contention, not by the code under test. The 5s
// default made legitimately heavy RSC-composition tests flake as the
// suite grew (municipalityPageData was the first); one global budget // suite grew (municipalityPageData was the first); one global budget
// beats per-test overrides. Genuinely hung tests still fail — just 10s // beats per-test overrides. Genuinely hung tests still fail — just 10s
// later. The unit suite keeps the 5s default. // later. The unit suite keeps the 5s default.