Skip to content
Closed
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
2 changes: 1 addition & 1 deletion dashboard/src/views/Administrator/Audits/AuditResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const AuditResults = ({ componentProps, row }: any) => {
button2Handler={undefined}
maxWidth="lg"
>
<AuditsTab auditResultGuid={currentPurgeResultObj} />
<AuditsTab auditResultGuid={currentPurgeResultObj} loading={false} />
</CustomModal>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ jest.mock('@utils/Muiutils', () => ({

jest.mock('@views/DetailPage/EntityDetailTabs/AuditsTab', () => ({
__esModule: true,
default: ({ auditResultGuid }: any) => (
<div data-testid="audits-tab">AuditsTab - {auditResultGuid}</div>
default: ({ auditResultGuid, loading }: any) => (
<div data-testid="audits-tab" data-loading={loading}>AuditsTab - {auditResultGuid}</div>
)
}));

Expand Down Expand Up @@ -425,6 +425,7 @@ describe('AuditResults Component', () => {

expect(screen.getByTestId('modal-title')).toHaveTextContent('Purged Entity Details: guid-1');
expect(screen.getByTestId('audits-tab')).toBeInTheDocument();
expect(screen.getByTestId('audits-tab')).toHaveAttribute('data-loading', 'false');
});

it('should open auto purge modal with correct title', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const AttributeProperties = ({
</Stack>
</AccordionSummary>
<AccordionDetails>
{loading == undefined || loading || isEmpty(entityData) ? (
{loading === true || (!auditDetails && isEmpty(entityData)) ? (
<>
<SkeletonLoader count={3} animation="wave" />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ describe('AttributeProperties', () => {
expect(screen.getByTestId('skeleton-loader')).toBeInTheDocument();
});

it('should render loading skeleton when loading is undefined', () => {
it('should render properties when loading is undefined and entityData is available', () => {
render(
<TestWrapper>
<AttributeProperties
Expand All @@ -337,7 +337,7 @@ describe('AttributeProperties', () => {
</TestWrapper>
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Audit mode + undefined loading + empty Redux entityData (core bug path)

it('should not render skeleton in auditDetails mode when loading is undefined', () => {
mockUseSelector.mockImplementation((selector: any) =>
selector({ entity: { entityData: {} } })
);
render(



);
expect(screen.queryByTestId('skeleton-loader')).not.toBeInTheDocument();
expect(screen.getByText('Technical Properties')).toBeInTheDocument();
});

  1. Audit mode + explicit loading still shows skeleton (negative case)

it('should render skeleton in auditDetails mode when loading is true', () => {
render(



);
expect(screen.getByTestId('skeleton-loader')).toBeInTheDocument();
});

  1. AuditResults should assert loading={false} is passed

The current mock only checks auditResultGuid:

AuditResults.test.tsx
Lines 113-117
jest.mock('@views/DetailPage/EntityDetailTabs/AuditsTab', () => ({
__esModule: true,
default: ({ auditResultGuid }: any) => (

AuditsTab - {auditResultGuid}

)
}));
Extend the mock to expose data-loading={loading} and assert it in the purge modal test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I have added the requested test cases in AttributeProperties.test.tsx for both the core bug path and negative loading case, and extended the <AuditsTab /> mock in AuditResults.test.tsx to assert the loading={false} attribute.

expect(screen.getByTestId('skeleton-loader')).toBeInTheDocument();
expect(screen.queryByTestId('skeleton-loader')).not.toBeInTheDocument();
});

it('should render loading skeleton when entityData is empty', () => {
Expand All @@ -364,6 +364,40 @@ describe('AttributeProperties', () => {
expect(screen.getByTestId('skeleton-loader')).toBeInTheDocument();
});

it('should not render skeleton in auditDetails mode when loading is undefined', () => {
mockUseSelector.mockImplementation((selector: any) =>
selector({ entity: { entityData: {} } })
);
render(
<TestWrapper>
<AttributeProperties
entity={defaultMockEntity}
referredEntities={defaultMockReferredEntities}
loading={undefined}
auditDetails={true}
propertiesName="Technical"
/>
</TestWrapper>
);
expect(screen.queryByTestId('skeleton-loader')).not.toBeInTheDocument();
expect(screen.getByText('Technical Properties')).toBeInTheDocument();
});

it('should render skeleton in auditDetails mode when loading is true', () => {
render(
<TestWrapper>
<AttributeProperties
entity={defaultMockEntity}
referredEntities={defaultMockReferredEntities}
loading={true}
auditDetails={true}
propertiesName="Technical"
/>
</TestWrapper>
);
expect(screen.getByTestId('skeleton-loader')).toBeInTheDocument();
});

it('should render "No Record Found" when properties are empty', () => {
const emptyEntity = {
typeName: 'DataSet',
Expand Down
Loading