Skip to content

Commit

Permalink
chore(3314): enforce distinct PO and TL idir for edit requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinedu Olebu committed Nov 12, 2024
1 parent fa173cd commit 13e7d3d
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function makeBasicProductChange(extra = {}) {
const response = await editPrivateCloudProject(requests.create.licencePlate, {
...requests.create.decisionData,
developmentQuota: newDevelopmentQuota,
isAgMinistryChecked: true,
...extra,
});

Expand Down
3 changes: 2 additions & 1 deletion app/app/api/private-cloud/products/_operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default async function updateOp({
return UnauthorizedResponse();
}

const { requestComment, quotaContactName, quotaContactEmail, quotaJustification, ...rest } = body;
const { requestComment, quotaContactName, quotaContactEmail, quotaJustification, isAgMinistryChecked, ...rest } =
body;

if (!product._permissions.manageMembers) {
rest.members = product.members;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ describe('Review Private Cloud Update Request - Permissions', () => {
const response = await editPrivateCloudProject(requests.main.licencePlate, {
...requests.main.decisionData,
developmentQuota: newDevelopmentQuota,
isAgMinistryChecked: true,
});

expect(response.status).toBe(200);
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/products/_operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default async function updateOp({
return UnauthorizedResponse();
}

const { requestComment, accountCoding, ...rest } = body;
const { requestComment, accountCoding, isAgMinistryChecked, isEaApproval, ...rest } = body;

if (!product._permissions.manageMembers) {
rest.members = product.members;
Expand Down
2 changes: 2 additions & 0 deletions app/app/api/public-cloud/requests/[id]/decision/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ describe('Review Public Cloud Update Request - Permissions', () => {
...requests.main.decisionData,
accountCoding: requests.main.decisionData.billing.accountCoding,
environmentsEnabled: newEnvironmentsEnabled,
isAgMinistryChecked: true,
});

expect(response.status).toBe(200);

requests.main = await response.json();
Expand Down
90 changes: 90 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions app/validation-schemas/private-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,25 @@ const _privateCloudEditRequestBodySchema = _privateCloudCreateRequestBodySchema.
}),
);

export const privateCloudEditRequestBodySchema = _privateCloudEditRequestBodySchema.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});
export const privateCloudEditRequestBodySchema = _privateCloudEditRequestBodySchema
.merge(
z.object({
isAgMinistryChecked: z.boolean().optional(),
}),
)
.refine(
(formData) => {
return AGMinistries.includes(formData.ministry) ? formData.isAgMinistryChecked : true;
},
{
message: 'AG Ministry Checkbox should be checked.',
path: ['isAgMinistryChecked'],
},
)
.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
path: ['primaryTechnicalLead'],
});

export const privateCloudRequestDecisionBodySchema = _privateCloudEditRequestBodySchema.merge(
z.object({
Expand Down
23 changes: 20 additions & 3 deletions app/validation-schemas/public-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,26 @@ const _publicCloudEditRequestBodySchema = _publicCloudCreateRequestBodySchema.me
}),
);

export const publicCloudEditRequestBodySchema = _publicCloudEditRequestBodySchema.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});
export const publicCloudEditRequestBodySchema = _publicCloudEditRequestBodySchema
.merge(
z.object({
isAgMinistryChecked: z.boolean().optional(),
isEaApproval: z.boolean().optional(),
}),
)
.refine(
(formData) => {
return AGMinistries.includes(formData.ministry) ? formData.isAgMinistryChecked : true;
},
{
message: 'AG Ministry Checkbox should be checked.',
path: ['isAgMinistryChecked'],
},
)
.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
path: ['primaryTechnicalLead'],
});

export const publicCloudRequestDecisionBodySchema = _publicCloudEditRequestBodySchema.merge(
z.object({
Expand Down

0 comments on commit 13e7d3d

Please sign in to comment.