-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f71d69
commit 5a8e55b
Showing
5 changed files
with
73 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ describe("bulk create users and companies from csv files", () => { | |
jest.mock("../../../companies/search"); | ||
(searchCompany as jest.Mock) | ||
.mockResolvedValue({ | ||
siret: "85001946400013", | ||
siret: "85001946400021", | ||
name: "Code en stock", | ||
statutDiffusionEtablissement: "O", | ||
etatAdministratif: "A" | ||
|
@@ -54,7 +54,7 @@ describe("bulk create users and companies from csv files", () => { | |
// In the test data we have | ||
// | ||
// 2 companies: | ||
// - Code en Stock 85001946400013 | ||
// - Code en Stock 85001946400021 | ||
// - Frontier SAS 81343950200028 | ||
// | ||
// and 3 users | ||
|
@@ -115,7 +115,7 @@ describe("bulk create users and companies from csv files", () => { | |
|
||
// check fields are OK for first company | ||
const codeEnStock = await prisma.company.findUniqueOrThrow({ | ||
where: { siret: "85001946400013" } | ||
where: { siret: "85001946400021" } | ||
}); | ||
expect(codeEnStock.name).toEqual("NAME FROM SIRENE"); | ||
expect(codeEnStock.givenName).toEqual("Code en Stock"); | ||
|
@@ -145,15 +145,15 @@ describe("bulk create users and companies from csv files", () => { | |
|
||
test("already existing company", async () => { | ||
// assume Code en Stock was already created | ||
const codeEnStock = await companyFactory({ siret: "85001946400013" }); | ||
const codeEnStock = await companyFactory({ siret: "85001946400021" }); | ||
|
||
await bulkCreateIdempotent(); | ||
|
||
await expectNumberOfRecords(2, 3, 4); | ||
|
||
// Code en stock should be untouched | ||
expect( | ||
await prisma.company.findUnique({ where: { siret: "85001946400013" } }) | ||
await prisma.company.findUnique({ where: { siret: "85001946400021" } }) | ||
).toEqual(codeEnStock); | ||
}, 10000); | ||
|
||
|
@@ -181,7 +181,7 @@ describe("bulk create users and companies from csv files", () => { | |
|
||
// associations should exist between John Snow and Code en Stock | ||
const associations = await prisma.companyAssociation.findMany({ | ||
where: { user: { id: john.id }, company: { siret: "85001946400013" } } | ||
where: { user: { id: john.id }, company: { siret: "85001946400021" } } | ||
}); | ||
expect(associations).toHaveLength(1); | ||
expect(associations[0].role).toEqual("ADMIN"); | ||
|
@@ -190,7 +190,7 @@ describe("bulk create users and companies from csv files", () => { | |
test("already existing user with existing role in company", async () => { | ||
// John Snow and Code en Stock already exist | ||
const john = await userFactory({ email: "[email protected]" }); | ||
const codeEnStock = await companyFactory({ siret: "85001946400013" }); | ||
const codeEnStock = await companyFactory({ siret: "85001946400021" }); | ||
// and John Snow is member of Code en Stock | ||
const role = await prisma.companyAssociation.create({ | ||
data: { | ||
|
@@ -260,7 +260,7 @@ describe("bulk create users and companies from csv files", () => { | |
|
||
test("role in csv already in pending invitation", async () => { | ||
// assume John Snow was already invited to Trackdéchets | ||
const company = await companyFactory({ siret: "85001946400013" }); | ||
const company = await companyFactory({ siret: "85001946400021" }); | ||
const invitation = await prisma.userAccountHash.create({ | ||
data: { | ||
email: "[email protected]", | ||
|
@@ -292,4 +292,28 @@ describe("bulk create users and companies from csv files", () => { | |
}); | ||
expect(updatedInvitation.acceptedAt).not.toBeNull(); | ||
}, 10000); | ||
|
||
test("should fill company's splitted address", async () => { | ||
await bulkCreateIdempotent(); | ||
|
||
await expectNumberOfRecords(2, 3, 4); | ||
|
||
// check fields are OK for first user | ||
const john = await prisma.user.findUniqueOrThrow({ | ||
where: { email: "[email protected]" } | ||
}); | ||
expect(john.name).toEqual("[email protected]"); | ||
expect(john.isActive).toEqual(true); | ||
expect(john.activatedAt).toBeTruthy(); | ||
expect(john.firstAssociationDate).toBeTruthy(); | ||
|
||
// check fields are OK for first company | ||
const codeEnStock = await prisma.company.findUniqueOrThrow({ | ||
where: { siret: "85001946400021" } | ||
}); | ||
expect(codeEnStock.street).toEqual("40 BOULEVARD VOLTAIRE BAT G"); | ||
expect(codeEnStock.postalCode).toEqual("13001"); | ||
expect(codeEnStock.city).toEqual("MARSEILLE"); | ||
expect(codeEnStock.country).toEqual("FR"); | ||
}, 10000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"siret";"gerepId";"companyTypes";"collectorTypes";"wasteProcessorTypes";"wasteVehiclesTypes";"givenName";"contactEmail";"contactPhone";"contact";"website" | ||
"85001946400013";"1234";"PRODUCER";;;;"Code en Stock";"[email protected]";"0600000000";"Marcel Machin";"https://codeenstock.trackdechets.fr" | ||
"85001946400021";"1234";"PRODUCER";;;;"Code en Stock";"[email protected]";"0600000000";"Marcel Machin";"https://codeenstock.trackdechets.fr" | ||
"81343950200028";"2345";"PRODUCER,WASTEPROCESSOR";;"OTHER_DANGEROUS_WASTES";;"Frontier SAS";"[email protected]";"0700000000";;"https://frontier.trackdechets.fr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
"siret";"email";"role" | ||
"85001946400013";"[email protected]";"ADMIN" | ||
"85001946400021";"[email protected]";"ADMIN" | ||
"81343950200028";"[email protected]";"ADMIN" | ||
"85001946400013";"[email protected]";"MEMBER" | ||
"85001946400021";"[email protected]";"MEMBER" | ||
"81343950200028";"[email protected]";"MEMBER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters