Skip to content

Commit

Permalink
Fix SUSE Manager errors label computation
Browse files Browse the repository at this point in the history
  • Loading branch information
dottorblaster committed Oct 24, 2024
1 parent f407423 commit cb5da8d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
12 changes: 10 additions & 2 deletions assets/js/pages/HostDetailsPage/HostDetailsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ const getSoftwareUpdatesErrorMessage = (errors) => {
detail === 'No system ID was found on SUSE Manager for this host.'
);

const connectionNotWorking = errors.some(
({ detail }) => detail === 'Something went wrong.'
);

if (hostNotFoundInSUMA) {
return 'Host not found in SUSE Manager';
}

if (errors.length) {
if (connectionNotWorking) {
return 'Connection to SUMA not working';
}

Expand All @@ -60,11 +64,15 @@ const getSoftwareUpdatesErrorTooltip = (errors) => {
detail === 'No system ID was found on SUSE Manager for this host.'
);

const connectionNotWorking = errors.some(
({ detail }) => detail === 'Something went wrong.'
);

if (hostNotFoundInSUMA) {
return 'Contact your SUSE Manager admin to ensure the host is managed by SUSE Manager';
}

if (errors.length) {
if (connectionNotWorking) {
return 'Please review SUSE Manager settings';
}

Expand Down
47 changes: 46 additions & 1 deletion assets/js/pages/HostDetailsPage/HostDetailsPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,51 @@ describe('HostDetailsPage', () => {
axiosMock.onGet(/\/api\/v1\/hosts.*/gm).reply(200, {});
});

it('Renders SUSE Manager unknown status', async () => {
const host = hostFactory.build();
const { id: hostID } = host;

const state = {
...defaultInitialState,
hostsList: {
hosts: [host],
},
lastExecutions: { data: null, loading: false, errors: null },
softwareUpdates: {
settingsConfigured: true,
softwareUpdates: {
[hostID]: {
loading: false,
errors: [{ detail: 'Generic error' }],
},
},
},
};

const [StatefulHostDetails] = withState(<HostDetailsPage />, state);

await act(async () =>
renderWithRouterMatch(StatefulHostDetails, {
path: 'hosts/:hostID',
route: `/hosts/${hostID}`,
})
);

const relevantPatchesElement = screen
.getByText(/Relevant Patches/)
.closest('div');
const upgradablePackagesElement = screen
.getByText(/Upgradable Packages/)
.closest('div');

expect(relevantPatchesElement).toHaveTextContent(
'Relevant Patches Unknown'
);
expect(upgradablePackagesElement).toHaveTextContent(
'Upgradable Packages Unknown'
);
});

it('Renders SUSE Manager error for host not found', async () => {
const user = userEvent.setup();

Expand Down Expand Up @@ -95,7 +140,7 @@ describe('HostDetailsPage', () => {
softwareUpdates: {
[hostID]: {
loading: false,
errors: [{ detail: 'Generic error' }],
errors: [{ detail: 'Something went wrong.' }],
},
},
},
Expand Down

0 comments on commit cb5da8d

Please sign in to comment.