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

PSP-7493 lease insurance UI cleanup #4024

Merged
merged 6 commits into from
May 17, 2024
Merged
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 @@ -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 = {
Expand Down Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,7 +18,7 @@ interface PolicyView {
insuranceType?: string;
}

const Policy: React.FunctionComponent<React.PropsWithChildren<PolicyProps>> = ({ insurance }) => {
const Policy: React.FunctionComponent<PolicyProps> = ({ insurance }) => {
const policy: PolicyView = {
insuranceInPlace:
insurance.isInsuranceInPlace == null
Expand All @@ -34,6 +34,11 @@ const Policy: React.FunctionComponent<React.PropsWithChildren<PolicyProps>> = ({
};
return (
<Section header={policy.insuranceType}>
{exists(insurance.insuranceType?.id) && insurance.insuranceType?.id === 'OTHER' && (
<SectionField label="Other insurance type" labelWidth="3">
{policy.otherInsuranceType}
</SectionField>
)}
<SectionField label="Insurance in place" labelWidth="3">
{policy.insuranceInPlace}
</SectionField>
Expand Down
Loading
Loading