Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Dec 17, 2024
1 parent 093fc7b commit 6c80632
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@
"ts-prune": "^0.10.3",
"typescript": "^5.6.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
});

it("deactivates establishments with 50+ unanswered discussions and no recent conventions", async () => {
// Create establishment that should be deactivated
const establishment = new EstablishmentAggregateBuilder()
.withEstablishmentSiret("12345678901234")
.withMaxContactsPerMonth(10)
Expand All @@ -189,7 +188,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
])
.build();

// Create 50 unanswered discussions
const discussions = Array.from({ length: 50 }, (_, i) =>
new DiscussionBuilder()
.withSiret(establishment.establishment.siret)
Expand All @@ -210,22 +208,18 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
.build(),
);

// Insert test data
await pgEstablishmentAggregateRepository.insertEstablishmentAggregate(
establishment,
);
await Promise.all(
discussions.map((d) => pgDiscussionRepository.insert(d)),
);

// Run the deactivation query
const updatedEstablishments =
await deactivateUnresponsiveEstablishmentsQuery(db);

// Verify the count of updated establishments
expectToEqual(updatedEstablishments.length, 1);

// Verify the establishment was deactivated using direct DB query
const result = await db
.selectFrom("establishments")
.select(["max_contacts_per_month", "status", "status_updated_at"])
Expand All @@ -238,7 +232,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
});

it("does not deactivate establishments with recent conventions", async () => {
// Create establishment
const establishment = new EstablishmentAggregateBuilder()
.withEstablishmentSiret("12345678901234")
.withMaxContactsPerMonth(10)
Expand All @@ -252,7 +245,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
])
.build();

// Create agency and convention
const agency = new AgencyDtoBuilder().build();
await pgAgencyRepository.insert(toAgencyWithRights(agency));

Expand All @@ -263,7 +255,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
.withDateStart(new Date().toISOString())
.build();

// Create 50 unanswered discussions
const discussions = Array.from({ length: 50 }, (_, i) =>
new DiscussionBuilder()
.withSiret(establishment.establishment.siret)
Expand All @@ -284,7 +275,6 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
.build(),
);

// Insert test data
await pgEstablishmentAggregateRepository.insertEstablishmentAggregate(
establishment,
);
Expand All @@ -293,14 +283,11 @@ describe("SQL queries, independent from PgEstablishmentAggregateRepository", ()
discussions.map((d) => pgDiscussionRepository.insert(d)),
);

// Run the deactivation query
const updatedEstablishments =
await deactivateUnresponsiveEstablishmentsQuery(db);

// Verify no establishments were updated
expectToEqual(updatedEstablishments.length, 0);

// Verify the establishment was not deactivated using direct DB query
const result = await db
.selectFrom("establishments")
.select(["max_contacts_per_month", "status", "status_updated_at"])
Expand Down

0 comments on commit 6c80632

Please sign in to comment.