Skip to content

Commit

Permalink
Test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Mar 5, 2024
1 parent de98da2 commit df19717
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,26 @@ describe('MotiInventoryHeader component', () => {
},
isLoading: false,
});
// PID is shown
// land parcel type is shown
expect(result.getByText(testProperty?.propertyType?.description as string)).toBeVisible();
});

it(`shows "retired" indicator for retired properties`, async () => {
const testProperty: ApiGen_Concepts_Property = {
...getEmptyProperty(),
isRetired: true,
};
const result = setup({
composedProperty: {
...defaultComposedProperty,
pimsProperty: testProperty,
},
isLoading: false,
});
// "retire" indicator is shown
expect(result.getByText(/expired/i)).toBeVisible();
});

it('allows the active property to be zoomed in', async () => {
const testProperty: ApiGen_Concepts_Property = {} as any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts
import { getEmptyBaseAudit, getEmptyProperty } from '@/models/defaultInitializers';
import { lookupCodesSlice } from '@/store/slices/lookupCodes';
import { toTypeCodeNullable } from '@/utils/formUtils';
import { render, RenderOptions } from '@/utils/test-utils';
import { RenderOptions, render } from '@/utils/test-utils';

import { useApiProperties } from '@/hooks/pims-api/useApiProperties';
import { useApiPropertyOperation } from '@/hooks/pims-api/useApiPropertyOperation';
import { PropertyDetailsTabView } from './PropertyDetailsTabView';
import { toFormValues } from './PropertyDetailsTabView.helpers';
import { useApiPropertyOperation } from '@/hooks/pims-api/useApiPropertyOperation';
import { useApiProperties } from '@/hooks/pims-api/useApiProperties';

const history = createMemoryHistory();
const storeState = {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('PropertyDetailsTabView component', () => {
const component = render(<PropertyDetailsTabView property={formValues} loading={false} />, {
...rest,
store: storeState,
claims: [Claims.PROPERTY_EDIT],
claims: renderOptions?.claims ?? [],
history,
});

Expand Down Expand Up @@ -168,6 +168,32 @@ describe('PropertyDetailsTabView component', () => {
const { getByText } = setup({ property });
expect(getByText(/Property address not available/i)).toBeVisible();
});

it('should display the Edit button if the user has permissions', async () => {
const property: ApiGen_Concepts_Property = {
...mockPropertyInfo,
};
const { getByTitle } = setup({ property, claims: [Claims.PROPERTY_EDIT] });
expect(getByTitle(/Edit property details/)).toBeVisible();
});

it('should not display the Edit button if the user does not have permissions', async () => {
const property: ApiGen_Concepts_Property = {
...mockPropertyInfo,
};
const { queryByTitle } = await setup({ property, claims: [] });
expect(queryByTitle(/Edit property details/)).toBeNull();
});

it('should replace the Edit button with a tooltip for retired properties', async () => {
const property: ApiGen_Concepts_Property = {
...mockPropertyInfo,
isRetired: true,
};
const { queryByTitle, getByTestId } = await setup({ property, claims: [Claims.PROPERTY_EDIT] });
expect(queryByTitle(/Edit property details/)).toBeNull();
expect(getByTestId('tooltip-icon-1-summary-cannot-edit-tooltip')).toBeInTheDocument();
});
});

export const mockPropertyInfo: ApiGen_Concepts_Property = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,7 @@ exports[`PropertyDetailsTabView component renders as expected when provided vali
>
<div
class="c1 mr-3 my-1"
>
<button
class="btn btn-link"
data-testid="edit-button"
title="Edit property details"
type="button"
>
<svg
fill="currentColor"
height="2rem"
stroke="currentColor"
stroke-width="0"
viewBox="0 0 576 512"
width="2rem"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"
/>
</svg>
</button>
</div>
/>
<div
class="c2 form-section"
>
Expand Down

0 comments on commit df19717

Please sign in to comment.