diff --git a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Insurance.test.tsx b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Insurance.test.tsx index fd755dcbd7..ccdad32dd6 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Insurance.test.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Insurance.test.tsx @@ -6,9 +6,13 @@ import { TypeCodeUtils } from '@/interfaces/ITypeCode'; import { getMockInsurance } from '@/mocks/insurance.mock'; import { ApiGen_Concepts_Insurance } from '@/models/api/generated/ApiGen_Concepts_Insurance'; import { ILookupCode, lookupCodesSlice } from '@/store/slices/lookupCodes'; -import { render, RenderOptions, RenderResult } from '@/utils/test-utils'; +import { RenderOptions, RenderResult, render } from '@/utils/test-utils'; -import { mockInsuranceTypeCar, mockInsuranceTypeHome } from '../edit/EditInsuranceContainer.test'; +import { + mockInsuranceTypeCar, + mockInsuranceTypeHome, + mockInsuranceTypeOther, +} from '../edit/EditInsuranceContainer.test'; import InsuranceDetailsView from './Insurance'; const storeState = { @@ -55,15 +59,37 @@ describe('Lease Insurance', () => { expect(result.asFragment()).toMatchSnapshot(); }); - it('Insurance count is correct', () => { + it('displays a list of lease insurances', () => { const testInsurance: ApiGen_Concepts_Insurance = { ...getMockInsurance() }; testInsurance.insuranceType = TypeCodeUtils.createFromLookup(mockInsuranceTypeCar); const result = setup({ - insuranceList: [getMockInsurance()], + insuranceList: [testInsurance], insuranceTypes: [mockInsuranceTypeHome, mockInsuranceTypeCar], }); const titles = result.getAllByTestId('insurance-section'); expect(titles.length).toBe(2); }); + + it('displays information about lease insurance of type OTHER', () => { + const testInsurance: ApiGen_Concepts_Insurance = { ...getMockInsurance() }; + testInsurance.insuranceType = TypeCodeUtils.createFromLookup(mockInsuranceTypeOther); + testInsurance.otherInsuranceType = 'alternate insurance type'; + + const result = setup({ + insuranceList: [testInsurance], + insuranceTypes: [mockInsuranceTypeHome, mockInsuranceTypeCar, mockInsuranceTypeOther], + }); + expect(result.getByText('alternate insurance type')).toBeInTheDocument(); + }); + + it('displays default message when no lease insurances were found', () => { + const result = setup({ + insuranceList: [], + insuranceTypes: [mockInsuranceTypeHome, mockInsuranceTypeCar], + }); + expect( + result.getByText('There are no insurance policies indicated with this lease/license'), + ).toBeInTheDocument(); + }); }); diff --git a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Policy.tsx b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Policy.tsx index 03708b5b3e..4d278c6fcb 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Policy.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/Policy.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { Section } from '@/components/common/Section/Section'; import { SectionField } from '@/components/common/Section/SectionField'; import { ApiGen_Concepts_Insurance } from '@/models/api/generated/ApiGen_Concepts_Insurance'; -import { formatMoney, prettyFormatDate } from '@/utils'; +import { exists, formatMoney, prettyFormatDate } from '@/utils'; interface PolicyProps { insurance: ApiGen_Concepts_Insurance; @@ -18,7 +18,7 @@ interface PolicyView { insuranceType?: string; } -const Policy: React.FunctionComponent> = ({ insurance }) => { +const Policy: React.FunctionComponent = ({ insurance }) => { const policy: PolicyView = { insuranceInPlace: insurance.isInsuranceInPlace == null @@ -34,6 +34,11 @@ const Policy: React.FunctionComponent> = ({ }; return (
+ {exists(insurance.insuranceType?.id) && insurance.insuranceType?.id === 'OTHER' && ( + + {policy.otherInsuranceType} + + )} {policy.insuranceInPlace} diff --git a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/__snapshots__/Insurance.test.tsx.snap b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/__snapshots__/Insurance.test.tsx.snap index a22bf1a857..36ab7e9be5 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/insurance/details/__snapshots__/Insurance.test.tsx.snap +++ b/source/frontend/src/features/leases/detail/LeasePages/insurance/details/__snapshots__/Insurance.test.tsx.snap @@ -6,69 +6,36 @@ exports[`Edit Lease Insurance > renders as expected 1`] = ` class="Toastify" />
-

- Required coverage -

-
- Select the coverage types that are required for this lease or license. -
.c0 { - border-radius: 1rem; - width: 100%; padding-top: 1rem; - padding-left: 2.5rem; - padding-bottom: 1rem; } -
-
-
- - -
-
- - -
-
-
-

- Coverage details -

- .c3 .react-datepicker__calendar-icon { +.c2 { + font-weight: bold; + border-bottom: 0.2rem solid; + margin-bottom: 2rem; +} + +.c1 { + margin: 1.5rem; + padding: 1.5rem; + background-color: white; + text-align: left; + border-radius: 0.5rem; +} + +.c4.required::before { + content: '*'; + position: absolute; + top: 0.75rem; + left: 0rem; +} + +.c3 { + font-weight: bold; +} + +.c5 .react-datepicker__calendar-icon { width: 3rem; height: 3rem; margin-top: 0.5rem; @@ -76,175 +43,274 @@ exports[`Edit Lease Insurance > renders as expected 1`] = ` pointer-events: none; } -.c3 .react-datepicker__view-calendar-icon input { +.c5 .react-datepicker__view-calendar-icon input { padding: 0.6rem 1rem 0.5rem 0.6rem; } -.c3 .react-datepicker-wrapper { +.c5 .react-datepicker-wrapper { max-width: 16rem; } -.c4.c4.form-control.is-valid { +.c6.c6.form-control.is-valid { background-image: none; } -.c4.c4.form-control.is-invalid { +.c6.c6.form-control.is-invalid { border-color: #d8292f !important; } -.c0 { - border-radius: 1rem; - width: 100%; - padding: 2.5rem; -} - -.c2.required::before { - content: '*'; - position: absolute; - top: 0.75rem; - left: 0rem; -} - -.c1 { - font-weight: bold; -} - -
+

- Home Insurance -

-
- + Required Coverage +
+ +
- + + +
+
+
+
+

+
+
+ Home Insurance +
+
+

-
- - Limit ($): - +
+
- +
-
- - Policy expiry date: - +
+
+
+
- - -
-
- +
+ +
+
+
+
+
+ + + + +
+
+
+
+
+
+
+ +
-