Skip to content

Commit

Permalink
psp-7962 correct missing no rows message introduced by operation sect… (
Browse files Browse the repository at this point in the history
#3894)

* psp-7962 correct missing no rows message introduced by operation section subtable.

* snapshot update.

* test corrections.

---------

Co-authored-by: Alejandro Sanchez <[email protected]>
  • Loading branch information
devinleighsmith and asanchezr authored Mar 25, 2024
1 parent 183813b commit 70348e3
Show file tree
Hide file tree
Showing 4 changed files with 1,018 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { lookupCodesSlice } from '@/store/slices/lookupCodes';
import { createMemoryHistory } from 'history';
import { mockLookups } from '@/mocks/lookups.mock';
import { render, RenderOptions } from '@/utils/test-utils';
import { EpochIsoDateTime } from '@/models/api/UtcIsoDateTime';
import { getEmptyProperty } from '@/models/defaultInitializers';
import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property';
import { ApiGen_CodeTypes_PropertyOperationTypes } from '@/models/api/generated/ApiGen_CodeTypes_PropertyOperationTypes';
import {
IOperationSectionViewProps,
OperationSectionView,
} from './propertyOperation/OperationSectionView';
import { OperationSet } from './propertyOperation/OperationContainer';
import { getMockApiProperties } from '@/mocks/properties.mock';

const history = createMemoryHistory();
const store = { [lookupCodesSlice.name]: { lookupCodes: mockLookups } };

describe('Operation section view', () => {
const setup = (
renderOptions: RenderOptions & { props?: Partial<IOperationSectionViewProps> } = {},
) => {
const props = renderOptions.props;
const component = render(
<OperationSectionView
subdivisionOperations={props?.subdivisionOperations ?? []}
consolidationOperations={props?.consolidationOperations ?? []}
loading={props?.loading ?? false}
/>,
{
...renderOptions,
useMockAuthentication: true,
claims: renderOptions?.claims,
history: history,
store: store,
},
);

return { ...component };
};

it('matches snapshot', () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];
const { asFragment } = setup({ props: { subdivisionOperations, consolidationOperations } });
expect(asFragment()).toMatchSnapshot();
});

it('Displays the empty subdivisions message', async () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [],
destinationProperties: [],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];

const { getByText, container } = setup({
props: { subdivisionOperations, consolidationOperations },
});

expect(getByText('This property is not part of a subdivision')).toBeVisible();
});

it('Displays the empty consolidations message', async () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [],
destinationProperties: [],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];

const { getByText, container } = setup({
props: { subdivisionOperations, consolidationOperations },
});

expect(getByText('This property is not part of a consolidation')).toBeVisible();
});
});
Loading

0 comments on commit 70348e3

Please sign in to comment.