Link da PR
https://github.com/infinitybase/bauhaus-ambiental-api/pull/1513
Tipo do problema
false-positive
Projeto
BAUHAUS
Repositorio
infinitybase/bauhaus-ambiental-api
Codigo flaggado
it('returns the just-updated status, not the pre-transaction snapshot', async () => {
const LicensesType = await models.LicensesType.findOne();
const licensing = await models.Licensing.create({
number: `TEST-${Date.now()}`,
key: `KEY-${Date.now()}`,
idUser: adminUser.id,
idSupervisor: adminUser.id,
idResponsible: adminUser.id,
status: 11, // Aguardando Assinatura — matches the real pre-finalize state
provisionalStatus: 4,
step: 1,
typeLicense: LicensesType ? LicensesType.id : null,
});
Comentario da IA
SUGGESTION: No cleanup of created Licensing row
Problem: The test creates a Licensing row (and relies on createAdminUser) but never removes it afterward. If this suite runs repeatedly against a persistent/staging DB (not a fully reset test DB per run), rows accumulate over time and could interfere with other tests/queries that do unscoped findOne()/findAll() over the Licensing table.
Suggestion: Add an afterEach/afterAll that destroys the created licensing record (and admin user, if not already handled by the helper).
Severidade do comentario da IA
SUGGESTION
Por que esta errado
O suite roda contra um Postgres efemero via Testcontainers, nao um banco persistente/staging. tests/setup/setupTests.js registra um beforeEach global (clearDataTables()) que faz TRUNCATE TABLE ... RESTART IDENTITY CASCADE em todas as tabelas de dados relevantes, incluindo Licensing, antes de CADA teste da suite inteira — nao so deste arquivo. Isso ja garante isolamento total entre testes sem cleanup manual.
Essa e uma convencao ja estabelecida e documentada explicitamente em outro arquivo do mesmo diretorio, tests/integration/licensing/licensingStatusPreservation.test.js:
// No afterEach cleanup needed: setupTests.js runs TRUNCATE on all relevant tables
// (Licensing, LicensingActs, Setor, SetorUsuario, etc.) in its global beforeEach,
// which executes before every test across the entire suite.
Adicionar afterEach/afterAll manual seria redundante com o TRUNCATE global e nao resolve nenhum problema real neste projeto — a premissa do comentario ("se rodar repetidamente contra um banco persistente") nao se aplica a arquitetura de testes deste repo.
Link da PR
https://github.com/infinitybase/bauhaus-ambiental-api/pull/1513
Tipo do problema
false-positive
Projeto
BAUHAUS
Repositorio
infinitybase/bauhaus-ambiental-api
Codigo flaggado
Comentario da IA
SUGGESTION: No cleanup of created Licensing row
Problem: The test creates a
Licensingrow (and relies oncreateAdminUser) but never removes it afterward. If this suite runs repeatedly against a persistent/staging DB (not a fully reset test DB per run), rows accumulate over time and could interfere with other tests/queries that do unscopedfindOne()/findAll()over theLicensingtable.Suggestion: Add an
afterEach/afterAllthat destroys the createdlicensingrecord (and admin user, if not already handled by the helper).Severidade do comentario da IA
SUGGESTION
Por que esta errado
O suite roda contra um Postgres efemero via Testcontainers, nao um banco persistente/staging.
tests/setup/setupTests.jsregistra umbeforeEachglobal (clearDataTables()) que fazTRUNCATE TABLE ... RESTART IDENTITY CASCADEem todas as tabelas de dados relevantes, incluindoLicensing, antes de CADA teste da suite inteira — nao so deste arquivo. Isso ja garante isolamento total entre testes sem cleanup manual.Essa e uma convencao ja estabelecida e documentada explicitamente em outro arquivo do mesmo diretorio,
tests/integration/licensing/licensingStatusPreservation.test.js:Adicionar
afterEach/afterAllmanual seria redundante com o TRUNCATE global e nao resolve nenhum problema real neste projeto — a premissa do comentario ("se rodar repetidamente contra um banco persistente") nao se aplica a arquitetura de testes deste repo.