-
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.
Apply plates number validation on transporter mutations
- Loading branch information
Showing
18 changed files
with
548 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,6 +572,93 @@ describe("Mutation.Bsda.create", () => { | |
]); | ||
}); | ||
|
||
it("should fail creating the form if plate numbers are invalid", async () => { | ||
const { user, company } = await userWithCompanyFactory("MEMBER"); | ||
const { company: destinationCompany } = await userWithCompanyFactory( | ||
"MEMBER" | ||
); | ||
const { company: transporterCompany } = await userWithCompanyFactory( | ||
"MEMBER" | ||
); | ||
const worker = await companyFactory(); | ||
|
||
const input: BsdaInput = { | ||
type: "OTHER_COLLECTIONS", | ||
emitter: { | ||
isPrivateIndividual: false, | ||
company: { | ||
siret: company.siret, | ||
name: "The crusher", | ||
address: "Rue de la carcasse", | ||
contact: "Centre amiante", | ||
phone: "0101010101", | ||
mail: "[email protected]" | ||
} | ||
}, | ||
worker: { | ||
company: { | ||
siret: worker.siret, | ||
name: "worker", | ||
address: "address", | ||
contact: "contactEmail", | ||
phone: "contactPhone", | ||
mail: "[email protected]" | ||
} | ||
}, | ||
waste: { | ||
code: "06 07 01*", | ||
adr: "ADR", | ||
pop: true, | ||
consistence: "SOLIDE", | ||
familyCode: "Code famille", | ||
materialName: "A material", | ||
sealNumbers: ["1", "2"] | ||
}, | ||
packagings: [{ quantity: 1, type: "PALETTE_FILME" }], | ||
weight: { isEstimate: true, value: 1.2 }, | ||
destination: { | ||
cap: "A cap", | ||
plannedOperationCode: "D 9", | ||
company: { | ||
siret: destinationCompany.siret, | ||
name: "destination", | ||
address: "address", | ||
contact: "contactEmail", | ||
phone: "contactPhone", | ||
mail: "[email protected]" | ||
} | ||
}, | ||
transporter: { | ||
company: { | ||
siret: transporterCompany.siret, | ||
name: "The Transporter", | ||
address: "Rue du bsda", | ||
contact: "Un transporter", | ||
phone: "0101010101", | ||
mail: "[email protected]" | ||
}, | ||
transport: { plates: ["SD"] } | ||
} | ||
}; | ||
|
||
const { mutate } = makeClient(user); | ||
const { errors } = await mutate<Pick<Mutation, "createBsda">>(CREATE_BSDA, { | ||
variables: { | ||
input | ||
} | ||
}); | ||
|
||
expect(errors).toEqual([ | ||
expect.objectContaining({ | ||
message: | ||
"Le numéro d'immatriculation doit faire entre 4 et 12 caractères", | ||
extensions: expect.objectContaining({ | ||
code: ErrorCode.BAD_USER_INPUT | ||
}) | ||
}) | ||
]); | ||
}); | ||
|
||
it("should fail creating the form if a required field like the waste code is missing", async () => { | ||
const { user, company } = await userWithCompanyFactory("MEMBER"); | ||
const { company: destinationCompany } = await userWithCompanyFactory( | ||
|
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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 |
---|---|---|
|
@@ -877,6 +877,78 @@ describe("Mutation.createDasri validation scenarii", () => { | |
]); | ||
}); | ||
|
||
it("should fail creating the form if plate humbers are invalid", async () => { | ||
const { user, company } = await userWithCompanyFactory("MEMBER"); | ||
const transporterCompany = await companyFactory(); | ||
|
||
const input = { | ||
waste: { adr: "xyz 33", code: "18 01 03*" }, | ||
emitter: { | ||
company: { | ||
name: "hopital blanc", | ||
siret: company.siret, | ||
contact: "jean durand", | ||
phone: "06 18 76 02 00", | ||
|
||
address: "avenue de la mer" | ||
}, | ||
emission: { | ||
weight: { value: 23.2, isEstimate: false }, | ||
|
||
packagings: [ | ||
{ | ||
type: "BOITE_CARTON", | ||
volume: 22, | ||
quantity: 3 | ||
} | ||
] | ||
} | ||
}, | ||
|
||
transporter: { | ||
company: { | ||
mail: "[email protected]", | ||
name: "El transporter", | ||
siret: transporterCompany.siret, | ||
contact: "Jason Statham", | ||
phone: "06 18 76 02 00", | ||
address: "avenue de la mer" | ||
}, | ||
transport: { | ||
plates: ["AB"], | ||
weight: { value: 22, isEstimate: false }, | ||
packagings: [ | ||
{ | ||
type: "BOITE_CARTON", | ||
volume: 22, | ||
quantity: 3 | ||
} | ||
] | ||
} | ||
}, | ||
...(await getDestinationCompanyInfo()) | ||
}; | ||
|
||
const { mutate } = makeClient(user); | ||
const { errors } = await mutate<Pick<Mutation, "createBsdasri">>( | ||
CREATE_DASRI, | ||
{ | ||
variables: { | ||
input | ||
} | ||
} | ||
); | ||
expect(errors).toEqual([ | ||
expect.objectContaining({ | ||
message: | ||
"Le numéro d'immatriculation doit faire entre 4 et 12 caractères", | ||
extensions: expect.objectContaining({ | ||
code: ErrorCode.BAD_USER_INPUT | ||
}) | ||
}) | ||
]); | ||
}); | ||
|
||
it("create a dasri without transport quantity and type", async () => { | ||
const { user, company } = await userWithCompanyFactory("MEMBER"); | ||
const transporterCompany = await companyFactory(); | ||
|
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
Oops, something went wrong.