diff --git a/source/frontend/src/components/layout/SideNavBar/__snapshots__/SideNavbar.test.tsx.snap b/source/frontend/src/components/layout/SideNavBar/__snapshots__/SideNavbar.test.tsx.snap index 785e9ebc34..d5a7e41ddc 100644 --- a/source/frontend/src/components/layout/SideNavBar/__snapshots__/SideNavbar.test.tsx.snap +++ b/source/frontend/src/components/layout/SideNavBar/__snapshots__/SideNavbar.test.tsx.snap @@ -356,596 +356,6 @@ exports[`SideNavbar display and logic > renders 1`] = ` min-width: max-content; } -.c3.active svg { - fill: #FDB913; -} - -@media (max-width:1225px) { - .c6 { - width: 32rem; - } - - .c6.show { - -webkit-transform: translateX(32rem); - -ms-transform: translateX(32rem); - transform: translateX(32rem); - } -} - -
-
-
-
-
- - - - - - - - - - -
-
-
-
-
-
-`; - -exports[`SideNavbar display and logic > renders 2`] = ` -.c4.btn { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; - padding: 0.4rem 1.2rem; - border: 0.2rem solid transparent; - border-radius: 0.4rem; - text-align: center; - -webkit-text-decoration: none; - text-decoration: none; - font-size: 1.8rem; - font-family: 'BCSans','Noto Sans',Verdana,Arial,sans-serif; - font-weight: 700; - -webkit-letter-spacing: 0.1rem; - -moz-letter-spacing: 0.1rem; - -ms-letter-spacing: 0.1rem; - letter-spacing: 0.1rem; - cursor: pointer; -} - -.c4.btn .Button__value { - width: -webkit-max-content; - width: -moz-max-content; - width: max-content; -} - -.c4.btn:hover { - -webkit-text-decoration: underline; - text-decoration: underline; - opacity: 0.8; -} - -.c4.btn:focus { - outline-width: 2px; - outline-style: solid; - outline-color: #2E5DD7; - outline-offset: 2px; - box-shadow: none; -} - -.c4.btn.btn-primary { - color: #FFFFFF; - background-color: #013366; -} - -.c4.btn.btn-primary:hover, -.c4.btn.btn-primary:active, -.c4.btn.btn-primary:focus { - background-color: #1E5189; -} - -.c4.btn.btn-secondary { - color: #013366; - background: none; - border-color: #013366; -} - -.c4.btn.btn-secondary:hover, -.c4.btn.btn-secondary:active, -.c4.btn.btn-secondary:focus { - color: #FFFFFF; - background-color: #013366; -} - -.c4.btn.btn-info { - color: #9F9D9C; - border: none; - background: none; - padding-left: 0.6rem; - padding-right: 0.6rem; -} - -.c4.btn.btn-info:hover, -.c4.btn.btn-info:active, -.c4.btn.btn-info:focus { - color: var(--surface-color-primary-button-hover); - background: none; -} - -.c4.btn.btn-light { - color: #FFFFFF; - background-color: #606060; - border: none; -} - -.c4.btn.btn-light:hover, -.c4.btn.btn-light:active, -.c4.btn.btn-light:focus { - color: #FFFFFF; - background-color: #606060; -} - -.c4.btn.btn-dark { - color: #FFFFFF; - background-color: #474543; - border: none; -} - -.c4.btn.btn-dark:hover, -.c4.btn.btn-dark:active, -.c4.btn.btn-dark:focus { - color: #FFFFFF; - background-color: #474543; -} - -.c4.btn.btn-danger { - color: #FFFFFF; - background-color: #CE3E39; -} - -.c4.btn.btn-danger:hover, -.c4.btn.btn-danger:active, -.c4.btn.btn-danger:focus { - color: #FFFFFF; - background-color: #CE3E39; -} - -.c4.btn.btn-warning { - color: #FFFFFF; - background-color: #FCBA19; - border-color: #FCBA19; -} - -.c4.btn.btn-warning:hover, -.c4.btn.btn-warning:active, -.c4.btn.btn-warning:focus { - color: #FFFFFF; - border-color: #FCBA19; - background-color: #FCBA19; -} - -.c4.btn.btn-link { - font-size: 1.6rem; - font-weight: 400; - color: var(--surface-color-primary-button-default); - background: none; - border: none; - -webkit-text-decoration: none; - text-decoration: none; - min-height: 2.5rem; - line-height: 3rem; - -webkit-box-pack: left; - -webkit-justify-content: left; - -ms-flex-pack: left; - justify-content: left; - -webkit-letter-spacing: unset; - -moz-letter-spacing: unset; - -ms-letter-spacing: unset; - letter-spacing: unset; - text-align: left; - padding: 0; - -webkit-text-decoration: underline; - text-decoration: underline; -} - -.c4.btn.btn-link:hover, -.c4.btn.btn-link:active, -.c4.btn.btn-link:focus { - color: var(--surface-color-primary-button-hover); - -webkit-text-decoration: underline; - text-decoration: underline; - border: none; - background: none; - box-shadow: none; - outline: none; -} - -.c4.btn.btn-link:disabled, -.c4.btn.btn-link.disabled { - color: #9F9D9C; - background: none; - pointer-events: none; -} - -.c4.btn:disabled, -.c4.btn:disabled:hover { - color: #9F9D9C; - background-color: #EDEBE9; - box-shadow: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - pointer-events: none; - cursor: not-allowed; -} - -.c4.Button .Button__icon { - margin-right: 1.6rem; -} - -.c4.Button--icon-only:focus { - outline: none; -} - -.c4.Button--icon-only .Button__icon { - margin-right: 0; -} - -.c5.btn.btn-light.Button { - padding: 0; - border: 0.1rem solid #9F9D9C; - background-color: white; - color: #474543; -} - -.c5.btn.btn-light.Button:focus, -.c5.btn.btn-light.Button:active { - background-color: white; - color: #474543; -} - -.c5.btn, -.c5 .Button__icon, -.c5 svg { - max-width: 2.4rem; - min-width: 2.4rem; - max-height: 2.4rem; - min-height: 2.4rem; - font-size: 1.4rem; -} - -.c1 { - height: calc( 100vh - 7.2rem - 4.4rem ); - overflow-y: auto; - overflow-x: hidden; - padding-top: 1.5rem; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - position: relative; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - grid-area: iconbar; - background-color: #003366; - -webkit-transition: 0.5s width; - transition: 0.5s width; - width: 6rem; -} - -.c1 label { - color: white; - min-width: 8rem; -} - -.c1.expanded { - width: 16rem; -} - -.c1 .nav-item svg { - min-width: 2.4rem; -} - -.c1 .to-bottom { - margin-top: auto; - margin-bottom: 1.6rem; -} - -.c1 .nav-link { - padding: 0.8rem 1.6rem; -} - -.c0 { - z-index: 1000; - position: relative; -} - -.c7 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - height: 100%; -} - -.c7 a { - font-size: 1.7rem; -} - -.c6 { - height: 100%; - overflow-y: auto; - position: absolute; - top: 0; - right: 0; - background-color: white; - z-index: -1; - width: 64rem; - padding: 0.8rem 1.6rem; - text-align: left; - -webkit-transition: -webkit-transform 0.3s ease-in-out; - -webkit-transition: transform 0.3s ease-in-out; - transition: transform 0.3s ease-in-out; - box-shadow: 0.3rem 0 0.4rem rgba(0,0,0,0.2); -} - -.c6.show { - -webkit-transform: translateX(64rem); - -ms-transform: translateX(64rem); - transform: translateX(64rem); -} - -.c2 { - width: 100%; - margin-bottom: 2rem; - fill: #f2f2f2; -} - -.c2:hover label { - color: #8ec6ff; -} - -.c2:hover svg { - fill: #8ec6ff; -} - -.c3 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c3 svg { - fill: white; - min-width: -webkit-max-content; - min-width: -moz-max-content; - min-width: max-content; -} - .c3.active svg { fill: #fdb913; } diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailView.tsx b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailView.tsx index fa08459e40..16c009e8bc 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailView.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailView.tsx @@ -44,28 +44,18 @@ export const LeaseDetailView: React.FunctionComponent< {hasClaim(Claims.LEASE_VIEW) && exists(leaseTypeCode) && leaseTypeCode === ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA && ( - onGenerate(lease)}> - - Generate H1005(a) + onGenerate(lease)}> + + Generate H-1005(a) )} {hasClaim(Claims.LEASE_VIEW) && exists(leaseTypeCode) && leaseTypeCode === ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY && ( - onGenerate(lease)}> - - Generate H1005 + onGenerate(lease)}> + + Generate H-1005 )} diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailsView.test.tsx b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailsView.test.tsx index 8e8478a3e0..fea5179f9f 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailsView.test.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseDetailsView.test.tsx @@ -133,11 +133,11 @@ describe('LeaseDetailView component', () => { }); it.each([ - [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H1005(a)'], - [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H1005'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H-1005(a)'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H-1005'], ])( 'does not render generation button if missing permissions - %s', - async (leaseTypeCode: string, buttonTitle: string) => { + async (leaseTypeCode: string, buttonText: string) => { setup({ props: { lease: { @@ -156,7 +156,7 @@ describe('LeaseDetailView component', () => { claims: [], }); - expect(screen.queryByText(buttonTitle)).toBeNull(); + expect(screen.queryByText(buttonText)).toBeNull(); }, ); @@ -178,15 +178,15 @@ describe('LeaseDetailView component', () => { }, }); - expect(screen.queryByText(/Generate H1005/i)).toBeNull(); + expect(screen.queryByText(/Generate H-1005/i)).toBeNull(); }); it.each([ - [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H1005(a)'], - [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H1005'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H-1005(a)'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H-1005'], ])( 'only renders generation button for specific lease types - %s', - async (leaseTypeCode: string, buttonTitle: string) => { + async (leaseTypeCode: string, buttonText: string) => { setup({ props: { lease: { @@ -204,13 +204,13 @@ describe('LeaseDetailView component', () => { }, }); - expect(await screen.findByTitle(buttonTitle)).toBeInTheDocument(); + expect(await screen.findByText(buttonText)).toBeInTheDocument(); }, ); it.each([ - [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H1005(a)'], - [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H1005'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LOOBCTFA, 'Generate H-1005(a)'], + [ApiGen_CodeTypes_LeaseLicenceTypes.LIPPUBHWY, 'Generate H-1005'], ])( 'calls onGenerate when generation button is clicked - %s', async (leaseTypeCode: string, buttonTitle: string) => { @@ -231,7 +231,7 @@ describe('LeaseDetailView component', () => { }, }); - const generateButton = await screen.findByTitle(buttonTitle); + const generateButton = await screen.findByText(buttonTitle); expect(generateButton).toBeInTheDocument(); await act(async () => userEvent.click(generateButton)); diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/LeaseDetailsView.test.tsx.snap b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/LeaseDetailsView.test.tsx.snap index 88e0c555eb..092cb7b767 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/LeaseDetailsView.test.tsx.snap +++ b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/LeaseDetailsView.test.tsx.snap @@ -292,6 +292,7 @@ exports[`LeaseDetailView component > renders minimally as expected 1`] = ` >
diff --git a/source/frontend/src/features/mapSideBar/acquisition/common/GenerateForm/GenerateFormView.tsx b/source/frontend/src/features/mapSideBar/acquisition/common/GenerateForm/GenerateFormView.tsx index fc9248f849..75906f58cc 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/common/GenerateForm/GenerateFormView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/common/GenerateForm/GenerateFormView.tsx @@ -50,7 +50,7 @@ const GenerateFormView: React.FunctionComponent< onGenerateClick(entry.formType)} - title="Generate" + title="Download File" > {entry.text} diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.test.tsx index 23af780d01..e409d92f71 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.test.tsx @@ -1,10 +1,12 @@ +import { Claims } from '@/constants'; import { mockAgreementsResponse } from '@/mocks/agreements.mock'; import { mockLookups } from '@/mocks/index.mock'; import { lookupCodesSlice } from '@/store/slices/lookupCodes'; -import { render, RenderOptions } from '@/utils/test-utils'; +import { act, render, RenderOptions, screen, userEvent } from '@/utils/test-utils'; -import AgreementView, { IAgreementViewProps } from './AgreementView'; import AcquisitionFileStatusUpdateSolver from '../../fileDetails/detail/AcquisitionFileStatusUpdateSolver'; +import AgreementView, { IAgreementViewProps } from './AgreementView'; +import { ApiGen_CodeTypes_AcquisitionStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionStatusTypes'; // mock auth library @@ -43,6 +45,7 @@ describe('AgreementView component', () => { beforeEach(() => { mockViewProps.agreements = mockAgreementsResponse(); + mockViewProps.statusUpdateSolver = new AcquisitionFileStatusUpdateSolver(); }); afterEach(() => { @@ -54,8 +57,39 @@ describe('AgreementView component', () => { expect(asFragment()).toMatchSnapshot(); }); - it('renders the agreement type ', () => { + it('renders the agreement type', () => { const { getByText } = setup(); expect(getByText(/License Of Occupation/i)).toBeVisible(); }); + + it('calls onGenerate when generation button is clicked', async () => { + const { getAllByTitle } = setup(); + + const generateButtons = getAllByTitle(/Download File/i); + expect(generateButtons).toHaveLength(2); + await act(async () => userEvent.click(generateButtons[0])); + + expect(mockViewProps.onGenerate).toHaveBeenCalled(); + }); + + it('displays confirmation modal when Delete Agreement button is clicked', async () => { + mockViewProps.statusUpdateSolver = new AcquisitionFileStatusUpdateSolver({ + id: ApiGen_CodeTypes_AcquisitionStatusTypes.ACTIVE, + description: '', + displayOrder: 1, + isDisabled: false, + }); + + const { getAllByTitle } = setup({ + claims: [Claims.ACQUISITION_EDIT], + }); + + const removeButtons = getAllByTitle(/Delete Agreement/i); + expect(removeButtons).toHaveLength(2); + await act(async () => userEvent.click(removeButtons[0])); + + expect( + screen.getByText(/You have selected to delete this Agreement/i, { exact: false }), + ).toBeVisible(); + }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.tsx index cfe33029f8..2e16e2b9bb 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/AgreementView.tsx @@ -1,4 +1,4 @@ -import { FaMailBulk, FaPlus, FaTrash } from 'react-icons/fa'; +import { FaFileContract, FaPlus, FaTrash } from 'react-icons/fa'; import { useHistory, useRouteMatch } from 'react-router-dom'; import styled from 'styled-components'; @@ -69,12 +69,13 @@ export const AgreementView: React.FunctionComponent = ({ {exists(agreement.agreementType) && ( { onGenerate(agreement); }} > - - Generate + + {`Generate ${getAgreementFormName(agreement.agreementType.id)}`} {!statusUpdateSolver.canEditOrDeleteAgreement( @@ -200,6 +201,21 @@ export const AgreementView: React.FunctionComponent = ({ export default AgreementView; +function getAgreementFormName(agreementType: string | null): string { + switch (agreementType) { + case ApiGen_CodeTypes_AgreementTypes.H179A: + return 'H-179A'; + case ApiGen_CodeTypes_AgreementTypes.H179P: + return 'H-179P'; + case ApiGen_CodeTypes_AgreementTypes.H179T: + return 'H-179T'; + case ApiGen_CodeTypes_AgreementTypes.H0074: + return 'H-0074'; + default: + return ''; + } +} + export const StyledButtonContainer = styled.div` display: flex; flex-direction: row; diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/__snapshots__/AgreementView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/__snapshots__/AgreementView.test.tsx.snap index 631ccb72f1..1184be4b0b 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/__snapshots__/AgreementView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/agreement/detail/__snapshots__/AgreementView.test.tsx.snap @@ -392,6 +392,7 @@ exports[`AgreementView component > renders as expected 1`] = ` > renders as expected 1`] = ` > { }); it('validates form values before generating', async () => { - const { getByText } = await setup(); - await act(async () => userEvent.click(getByText('Generate'))); + const { getByText, getByTitle } = await setup(); + await act(async () => userEvent.click(getByTitle(/Download File/i))); expect(getByText('Expropriation authority is required')).toBeInTheDocument(); expect(getByText('At lease one impacted property is required')).toBeInTheDocument(); @@ -83,10 +83,10 @@ describe('Expropriation Form 1', () => { await act(async () => userEvent.paste(getNatureOfInterest(), 'foo')); await act(async () => userEvent.paste(getPurpose(), 'bar')); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).not.toBeCalled(); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).not.toHaveBeenCalled(); }); it(`clears the form when Cancel button is clicked`, async () => { @@ -122,9 +122,9 @@ describe('Expropriation Form 1', () => { await act(async () => userEvent.paste(getNatureOfInterest(), 'foo')); await act(async () => userEvent.paste(getPurpose(), 'bar')); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).toBeCalledWith(error); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).toHaveBeenCalledWith(error); }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/ExpropriationForm1.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/ExpropriationForm1.tsx index fb597c7cd1..c1fd6f27df 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/ExpropriationForm1.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/ExpropriationForm1.tsx @@ -1,6 +1,7 @@ import { Formik, FormikHelpers, FormikProps } from 'formik'; import { Fragment } from 'react'; import { Col, Row } from 'react-bootstrap'; +import { FaFileContract } from 'react-icons/fa'; import styled from 'styled-components'; import { Button } from '@/components/common/buttons'; @@ -101,7 +102,10 @@ export const ExpropriationForm1: React.FC = ({ - + diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/__snapshots__/ExpropriationForm1.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/__snapshots__/ExpropriationForm1.test.tsx.snap index 70dd8872eb..9ad25523cf 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/__snapshots__/ExpropriationForm1.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form1/__snapshots__/ExpropriationForm1.test.tsx.snap @@ -831,12 +831,27 @@ exports[`Expropriation Form 1 > matches snapshot 1`] = ` >
diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.test.tsx index 8a45adffb0..b8acb8b15c 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.test.tsx @@ -60,8 +60,8 @@ describe('Expropriation Form 1', () => { }); it('validates form values before generating', async () => { - const { getByText } = await setup(); - await act(async () => userEvent.click(getByText('Generate'))); + const { getByText, getByTitle } = await setup(); + await act(async () => userEvent.click(getByTitle(/Download File/i))); expect(getByText('Expropriation authority is required')).toBeInTheDocument(); expect(getByText('At lease one impacted property is required')).toBeInTheDocument(); @@ -77,10 +77,10 @@ describe('Expropriation Form 1', () => { // fill other form fields await act(async () => userEvent.click(getByTestId('selectrow-1'))); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).not.toBeCalled(); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).not.toHaveBeenCalled(); }); it(`clears the form when Cancel button is clicked`, async () => { @@ -105,9 +105,9 @@ describe('Expropriation Form 1', () => { // fill other form fields await act(async () => userEvent.click(getByTestId('selectrow-1'))); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).toBeCalledWith(error); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).toHaveBeenCalledWith(error); }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.tsx index b0d9d690c0..9b88065596 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/ExpropriationForm5.tsx @@ -1,6 +1,7 @@ import { Formik, FormikHelpers, FormikProps } from 'formik'; import React from 'react'; import { Col, Row } from 'react-bootstrap'; +import { FaFileContract } from 'react-icons/fa'; import styled from 'styled-components'; import { Button } from '@/components/common/buttons'; @@ -94,7 +95,10 @@ export const ExpropriationForm5: React.FC = ({ - + diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/__snapshots__/ExpropriationForm5.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/__snapshots__/ExpropriationForm5.test.tsx.snap index de73a2f81c..60e64c5842 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/__snapshots__/ExpropriationForm5.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form5/__snapshots__/ExpropriationForm5.test.tsx.snap @@ -753,12 +753,27 @@ exports[`Expropriation Form 1 > matches snapshot 1`] = ` >
diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/ExpropriationForm8Details.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/ExpropriationForm8Details.tsx index 940e2fc569..4d9d338000 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/ExpropriationForm8Details.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/ExpropriationForm8Details.tsx @@ -1,5 +1,5 @@ import { Col, Row } from 'react-bootstrap'; -import { FaExternalLinkAlt, FaMoneyCheck, FaTrash } from 'react-icons/fa'; +import { FaExternalLinkAlt, FaFileContract, FaTrash } from 'react-icons/fa'; import { useHistory, useRouteMatch } from 'react-router-dom'; import styled from 'styled-components'; @@ -51,11 +51,12 @@ export const ExpropriationForm8Details: React.FunctionComponent<
onGenerate(form8.id as number, acquisitionFileNumber)} > - - Generate + + Generate Form 8 {keycloak.hasClaim(Claims.ACQUISITION_EDIT) && ( diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/__snapshots__/ExpropriationForm8Details.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/__snapshots__/ExpropriationForm8Details.test.tsx.snap index a2b4d33637..02a2a8930d 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/__snapshots__/ExpropriationForm8Details.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form8/details/__snapshots__/ExpropriationForm8Details.test.tsx.snap @@ -340,6 +340,7 @@ exports[`Form 8 Detail View component > renders as expected 1`] = ` diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.test.tsx index e73016a842..4a7ff6aa1c 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.test.tsx @@ -62,8 +62,8 @@ describe('Expropriation Form 1', () => { }); it('validates form values before generating', async () => { - const { getByText } = await setup(); - await act(async () => userEvent.click(getByText('Generate'))); + const { getByText, getByTitle } = await setup(); + await act(async () => userEvent.click(getByTitle(/Download File/i))); expect(getByText('Expropriation authority is required')).toBeInTheDocument(); expect(getByText('At lease one impacted property is required')).toBeInTheDocument(); @@ -81,10 +81,10 @@ describe('Expropriation Form 1', () => { await act(async () => userEvent.click(getByTestId('selectrow-1'))); await act(async () => userEvent.paste(getRegisteredPlanNumbers(), 'testing')); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).not.toBeCalled(); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).not.toHaveBeenCalled(); }); it(`clears the form when Cancel button is clicked`, async () => { @@ -116,9 +116,9 @@ describe('Expropriation Form 1', () => { await act(async () => userEvent.click(getByTestId('selectrow-1'))); await act(async () => userEvent.paste(getRegisteredPlanNumbers(), 'testing')); - await act(async () => userEvent.click(getByText('Generate'))); + await act(async () => userEvent.click(getByTitle(/Download File/i))); - expect(onGenerate).toBeCalled(); - expect(onError).toBeCalledWith(error); + expect(onGenerate).toHaveBeenCalled(); + expect(onError).toHaveBeenCalledWith(error); }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.tsx index 7c86de1d67..6ff2b334d1 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/ExpropriationForm9.tsx @@ -1,6 +1,7 @@ import { Formik, FormikHelpers, FormikProps } from 'formik'; import React from 'react'; import { Col, Row } from 'react-bootstrap'; +import { FaFileContract } from 'react-icons/fa'; import styled from 'styled-components'; import { Button } from '@/components/common/buttons'; @@ -98,7 +99,10 @@ export const ExpropriationForm9: React.FC = ({ - + diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/__snapshots__/ExpropriationForm9.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/__snapshots__/ExpropriationForm9.test.tsx.snap index 64a2690433..7ef7e89233 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/__snapshots__/ExpropriationForm9.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/form9/__snapshots__/ExpropriationForm9.test.tsx.snap @@ -792,12 +792,27 @@ exports[`Expropriation Form 1 > matches snapshot 1`] = ` > diff --git a/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.test.tsx b/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.test.tsx index 22665b9b56..8a754a40d6 100644 --- a/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.test.tsx +++ b/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.test.tsx @@ -9,17 +9,18 @@ import { getMockApiDefaultCompensation, getMockCompensationPropertiesReq, } from '@/mocks/compensations.mock'; +import { ApiGen_CodeTypes_AcquisitionStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionStatusTypes'; +import { ApiGen_CodeTypes_FileTypes } from '@/models/api/generated/ApiGen_CodeTypes_FileTypes'; import { ApiGen_Concepts_CompensationRequisition } from '@/models/api/generated/ApiGen_Concepts_CompensationRequisition'; import { toTypeCodeNullable } from '@/utils/formUtils'; -import { act, render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; +import { act, render, RenderOptions, userEvent, waitForEffects } from '@/utils/test-utils'; import CompensationRequisitionDetailView, { CompensationRequisitionDetailViewProps, } from './CompensationRequisitionDetailView'; -import { ApiGen_CodeTypes_AcquisitionStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionStatusTypes'; -import { ApiGen_CodeTypes_FileTypes } from '@/models/api/generated/ApiGen_CodeTypes_FileTypes'; const setEditMode = vi.fn(); +const onGenerate = vi.fn(); const history = createMemoryHistory(); @@ -39,7 +40,7 @@ describe('Compensation Detail View Component', () => { loading={renderOptions.props?.loading ?? false} setEditMode={setEditMode} clientConstant={renderOptions.props?.clientConstant ?? '034'} - onGenerate={vi.fn()} + onGenerate={onGenerate} compensationContactPerson={undefined} compensationContactOrganization={undefined} />, @@ -50,6 +51,8 @@ describe('Compensation Detail View Component', () => { }, ); + await waitForEffects(); + return { ...component, }; @@ -61,8 +64,7 @@ describe('Compensation Detail View Component', () => { it('renders as expected', async () => { const { asFragment } = await setup({}); - const fragment = await waitFor(() => asFragment()); - expect(fragment).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); it('Displays the Compensation Requisition Header Information with Draft Status', async () => { @@ -194,7 +196,7 @@ describe('Compensation Detail View Component', () => { }); it('displays the acquisition files properties selected', async () => { - const { findByText, findByTestId } = await setup({ + const { findByText } = await setup({ claims: [Claims.COMPENSATION_REQUISITION_EDIT], props: { compensation: getMockApiCompensationWithProperty(), @@ -250,4 +252,13 @@ describe('Compensation Detail View Component', () => { expect(queryByTestId('file-product')).toHaveTextContent('00048'); }); + + it('calls onGenerate when generation button is clicked', async () => { + const { getByTitle } = await setup({}); + + const generateButton = getByTitle(/Download File/i); + await act(async () => userEvent.click(generateButton)); + + expect(onGenerate).toHaveBeenCalled(); + }); }); diff --git a/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.tsx b/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.tsx index b093e47cc7..ffc4b1f8f5 100644 --- a/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.tsx +++ b/source/frontend/src/features/mapSideBar/compensation/detail/CompensationRequisitionDetailView.tsx @@ -1,7 +1,6 @@ -import { useEffect, useState } from 'react'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Col, Row } from 'react-bootstrap'; -import { FaExternalLinkAlt, FaMoneyCheck } from 'react-icons/fa'; +import { FaExternalLinkAlt, FaFileContract } from 'react-icons/fa'; import { Link } from 'react-router-dom'; import styled from 'styled-components'; @@ -253,12 +252,13 @@ export const CompensationRequisitionDetailView: React.FunctionComponent< /> )} { onGenerate(fileType, compensation); }} > - - Generate H120 + + Generate H-120 diff --git a/source/frontend/src/features/mapSideBar/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap b/source/frontend/src/features/mapSideBar/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap index 9f20af92f5..c75e9ce073 100644 --- a/source/frontend/src/features/mapSideBar/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap @@ -496,6 +496,7 @@ exports[`Compensation Detail View Component > renders as expected 1`] = `