Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Nov 29, 2024
1 parent 1196c6d commit 94e8605
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ jest.mock('../../helper_hooks', () => ({
useHasSecurityCapability: () => mockUseHasSecurityCapability(),
}));

const mockUseEntityEngineStatus = jest.fn();
const mockUseEntityStoreStatus = jest.fn();
jest.mock('../components/entity_store/hooks/use_entity_store', () => ({
useEntityStoreStatus: () => mockUseEntityEngineStatus(),
...jest.requireActual('../components/entity_store/hooks/use_entity_store'),
useEntityStoreStatus: () => mockUseEntityStoreStatus(),
}));

const mockUseEntityEnginePrivileges = jest.fn();
Expand All @@ -52,8 +53,10 @@ describe('EntityStoreManagementPage', () => {
data: { has_all_required: true },
});

mockUseEntityEngineStatus.mockReturnValue({
status: 'running',
mockUseEntityStoreStatus.mockReturnValue({
data: {
status: 'running',
},
errors: [],
});

Expand All @@ -79,9 +82,11 @@ describe('EntityStoreManagementPage', () => {
expect(screen.getByText('Entity Store')).toBeInTheDocument();
});

it('disables the switch when status is loading', () => {
mockUseEntityEngineStatus.mockReturnValue({
status: 'loading',
it('disables the switch when status is installing', () => {
mockUseEntityStoreStatus.mockReturnValue({
data: {
status: 'installing',
},
errors: [],
});

Expand Down Expand Up @@ -142,8 +147,10 @@ describe('EntityStoreManagementPage', () => {
});

it('switches to the Status tab when clicked', () => {
mockUseEntityEngineStatus.mockReturnValue({
status: 'running',
mockUseEntityStoreStatus.mockReturnValue({
data: {
status: 'running',
},
errors: [],
});

Expand All @@ -161,8 +168,10 @@ describe('EntityStoreManagementPage', () => {
});

it('does not render the Status tab when entity store is not installed', () => {
mockUseEntityEngineStatus.mockReturnValue({
status: 'not_installed',
mockUseEntityStoreStatus.mockReturnValue({
data: {
status: 'not_installed',
},
errors: [],
});

Expand All @@ -178,8 +187,10 @@ describe('EntityStoreManagementPage', () => {
});

it('does not render the Status tab when privileges are missing', () => {
mockUseEntityEngineStatus.mockReturnValue({
status: 'running',
mockUseEntityStoreStatus.mockReturnValue({
data: {
status: 'running',
},
errors: [],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ const FileUploadSection: React.FC<{
hasAssetCriticalityWritePermissions,
}) => {
if (!hasEntityAnalyticsCapability || assetCriticalityPrivilegesError?.body.status_code === 403) {
return <AssetCriticalityIssueCallout />;
return (
<AssetCriticalityIssueCallout errorMessage={assetCriticalityPrivilegesError?.body.message} />
);
}
if (!hasAssetCriticalityWritePermissions) {
return <InsufficientAssetCriticalityPrivilegesCallout />;
Expand Down

0 comments on commit 94e8605

Please sign in to comment.