Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🛠️ adds missing validation on Agreement form #2832

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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
6 changes: 6 additions & 0 deletions frontend/src/pages/agreements/approve/ApproveAgreement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const ApproveAgreement = () => {
if (!agreement) {
return <div>No agreement data available.</div>;
}

/*
TODO: Add FE validation to ensure that the user is authorized to approve the agreement
and if not, display an error page
to prevent unauthorized users from accessing this page
*/
const BeforeApprovalContent = React.memo(
({ groupedBudgetLinesByServicesComponent, servicesComponents, changeRequestTitle, urlChangeToStatus }) => (
<>
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