Skip to content

Commit

Permalink
Merge branch 'main' into OPS-2833/add_permission_check
Browse files Browse the repository at this point in the history
  • Loading branch information
fpigeonjr committed Sep 24, 2024
2 parents a4dab5d + 4a20a8f commit 8f982a4
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 32 deletions.
12 changes: 5 additions & 7 deletions frontend/cypress/e2e/createAgreement.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ it("can create an SEVERABLE agreement", () => {
// complete contract type and service req type
cy.get("#contract-type").select("FIRM_FIXED_PRICE");
// test default should be NON-SEVERABLE
cy.get("#serviceReqType").should("contain", "Non-Severable");
cy.get("#serviceReqType").select("-Select Service Requirement Type-");
cy.get(".usa-error-message").should("contain", "This is required information");
cy.get("[data-cy='continue-btn']").should("be.disabled");
cy.get("[data-cy='save-draft-btn']").should("be.disabled");
cy.get("#service_requirement_type").should("contain", "Non-Severable");
cy.get("#service_requirement_type").select("-Select Service Requirement Type-");
cy.get(".usa-error-message").should("exist");
// change to SEVERABLE
cy.get("#serviceReqType").select("SEVERABLE");
cy.get("#service_requirement_type").select("SEVERABLE");
cy.get(".usa-error-message").should("not.exist");
cy.get("[data-cy='continue-btn']").should("not.be.disabled");
cy.get("[data-cy='save-draft-btn']").should("not.be.disabled");
Expand Down Expand Up @@ -201,7 +199,7 @@ it("can create an NON-SEVERABLE agreement", () => {
// complete contract type and service req type
cy.get("#contract-type").select("FIRM_FIXED_PRICE");
// test default should be NON-SEVERABLE
cy.get("#serviceReqType").should("contain", "Non-Severable");
cy.get("#service_requirement_type").should("contain", "Non-Severable");
cy.get(".usa-error-message").should("not.exist");
cy.get("[data-cy='continue-btn']").should("not.be.disabled");
cy.get("[data-cy='save-draft-btn']").should("not.be.disabled");
Expand Down
28 changes: 24 additions & 4 deletions frontend/cypress/e2e/createAgreementWithValidations.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe("create agreement and test validations", () => {
cy.intercept("PATCH", "**/agreements/**").as("patchAgreement");
cy.visit(`/agreements/review/${agreementId}?mode=review`).wait(1000);
cy.get("h1").should("have.text", "Please resolve the errors outlined below");

cy.get('[data-cy="error-list"]').should("exist");
cy.get('[data-cy="error-item"]').should("have.length", 9);
//send-to-approval button should be disabled
Expand All @@ -61,12 +60,33 @@ describe("create agreement and test validations", () => {
//fix errors
cy.get('[data-cy="edit-agreement-btn"]').click();
cy.get("#continue").click();
// get all errors on page, should be 5
cy.get(".usa-form-group--error").should("have.length", 5);
// get all errors on page, should be 6
cy.get(".usa-form-group--error").should("have.length", 6);
// test description
cy.get("#description").type("Test Description");
cy.get("#description").clear();
cy.get("#description").blur();
cy.get(".usa-error-message").should("exist");
cy.get("#description").type("Test Description");
// test contract type
cy.get("#contract-type").select("Firm Fixed Price (FFP)");
cy.get("#contract-type").select("-Select an option-");
cy.get(".usa-error-message").should("exist");
cy.get("#contract-type").select("Firm Fixed Price (FFP)");
// test service requirement select
cy.get("#service_requirement_type").select("Severable");
cy.get("#service_requirement_type").select("-Select Service Requirement Type-");
cy.get(".usa-error-message").should("exist");
cy.get("#service_requirement_type").select("Severable");
// test product service code
cy.get("#product_service_code_id").select(1);
cy.get("#product_service_code_id").select(0);
cy.get(".usa-error-message").should("exist");
cy.get("#product_service_code_id").select(1);
cy.get("#serviceReqType").select("Severable");
// test agreement type
cy.get("#agreement_reason").select("NEW_REQ");
cy.get("#agreement_reason").select(0);
cy.get(".usa-error-message").should("exist");
cy.get("#agreement_reason").select("NEW_REQ");
cy.get("#project-officer-combobox-input").type("Chris Fortunato{enter}");
cy.get("#team-member-combobox-input").type("Admin Demo{enter}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ export const AgreementEditForm = ({
handleConfirm={modalProps.handleConfirm}
/>
)}
<h2 className="font-sans-lg margin-top-3 margin-bottom-0">Agreement Type</h2>
<p className="margin-top-1">Select the agreement type to get started.</p>
<AgreementTypeSelect
messages={res.getErrors("agreement_type")}
className={cn("agreement_type")}
Expand Down Expand Up @@ -376,15 +374,15 @@ export const AgreementEditForm = ({
/>
<ContractTypeSelect
messages={res.getErrors("contract-type")}
className="margin-top-3"
className={`margin-top-3 ${cn("contract-type")}`}
value={contractType}
onChange={(name, value) => {
setContractType(value);
}}
/>
<ServiceReqTypeSelect
messages={res.getErrors("serviceReqType")}
className={`margin-top-3 ${cn("serviceReqType")}`}
messages={res.getErrors("service_requirement_type")}
className={`margin-top-3 ${cn("service_requirement_type")}`}
isRequired={true}
value={serviceReqType}
onChange={(name, value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const suite = create((data = {}, fieldName) => {
test("name", "This is required information", () => {
enforce(data.name).isNotBlank();
});
test("serviceReqType", "This is required information", () => {
enforce(data.serviceReqType).notEquals("-Select Service Requirement Type-");
test("service_requirement_type", "This is required information", () => {
enforce(data.service_requirement_type).notEquals("-Select Service Requirement Type-");
});
test("description", "This is required information", () => {
enforce(data.description).isNotBlank();
Expand All @@ -20,8 +20,6 @@ const suite = create((data = {}, fieldName) => {
});
test("agreement_reason", "This is required information", () => {
enforce(data.agreement_reason).isNotBlank();
});
test("agreement_reason", "This is required information", () => {
enforce(data.agreement_reason).notEquals("0");
});
test("incumbent", "This is required information", () => {
Expand All @@ -37,6 +35,7 @@ const suite = create((data = {}, fieldName) => {
});
test("contract-type", "This is required information", () => {
enforce(data.contract_type).notEquals("-Select an option-");
enforce(data.contract_type).isNotEmpty();
});
test("team-members", "This is required information", () => {
enforce(data.team_members).lengthNotEquals(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from "prop-types";
import React from "react";
import { convertCodeForDisplay } from "../../../helpers/utils";
import EditModeTitle from "../../../pages/agreements/EditModeTitle";
import AgreementBudgetLinesHeader from "../../Agreements/AgreementBudgetLinesHeader";
import AgreementTotalCard from "../../Agreements/AgreementDetailsCards/AgreementTotalCard";
Expand Down Expand Up @@ -61,7 +60,6 @@ export const CreateBLIsAndSCs = ({
setIncludeDrafts
}) => {
const {
budgetLinePageErrorsExist,
handleDeleteBudgetLine,
handleDuplicateBudgetLine,
handleEditBLI,
Expand Down Expand Up @@ -210,7 +208,7 @@ export const CreateBLIsAndSCs = ({
/>
)}

{budgetLinePageErrorsExist && (
{pageErrors && (
<ul
className="usa-list--unstyled font-12px text-error"
data-cy="error-list"
Expand All @@ -221,7 +219,6 @@ export const CreateBLIsAndSCs = ({
className="border-left-2px padding-left-1"
data-cy="error-item"
>
<strong>{convertCodeForDisplay("validation", key)}: </strong>
{
<span>
{value.map((message, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const suite = create((data) => {
only(data);

// test to ensure at least one budget line item exists
test("data", "Must have at least one budget line item", () => {
enforce(data.budgetLines).longerThan(0);
test("data", "Must have at least one budget line", () => {
enforce(data.budgetLines.length).greaterThan(0);
});
// test budget_line_items array
each(data.budgetLines, (item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function ContractTypeSelect({ value, onChange, ...rest }) {
<Select
name="contract-type"
label="Contract Type"
options={CONTRACT_TYPE_OPTIONS}
onChange={onChange}
value={value}
messages={[]}
options={CONTRACT_TYPE_OPTIONS}
{...rest}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SERVICE_REQ_TYPES_OPTIONS } from "../ServicesComponents.constants";
function ServiceReqTypeSelect({ value, onChange, ...rest }) {
return (
<Select
name="serviceReqType"
name="service_requirement_type"
label="Service Requirement Type"
onChange={onChange}
value={value}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/agreements/approve/ApproveAgreement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ const ApproveAgreement = () => {
const hasPermissionToViewPage =
userIsDivisionDirector && agreementIsInReview && doesAgreementBelongToDivisionDirector;

// if (!hasPermissionToViewPage) {
// return <ErrorPage />;
// }
if (!hasPermissionToViewPage) {
return <ErrorPage />;
}

if (isLoadingAgreement) {
return <div>Loading...</div>;
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/agreements/review/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const suite = create((fieldName) => {
enforce(fieldName.project_officer_id).isNotBlank();
});
test("contract-type", "This is required information", () => {
enforce(fieldName.contract_type).isNotBlank();
enforce(fieldName.contract_type).notEquals("-Select an option-");
enforce(fieldName.contract_type).isNotEmpty();
});
test("team-members", "This is required information", () => {
enforce(fieldName.team_members).longerThan(0);
Expand Down

0 comments on commit 8f982a4

Please sign in to comment.