Skip to content

Commit

Permalink
PMM-13348 Update StatusLink unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Sep 13, 2024
1 parent ebddfbf commit 830fe56
Showing 1 changed file with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('StatusLink', () => {
expect(screen.getByText('OK')).toBeInTheDocument();
expect(screen.queryByText('Failed')).not.toBeInTheDocument();
});

it('should show "Failed" if some agent is not connected', () => {
const agents: DbAgent[] = [
{
Expand All @@ -60,6 +61,7 @@ describe('StatusLink', () => {
expect(screen.queryByText('OK')).not.toBeInTheDocument();
expect(screen.getByText('Failed')).toBeInTheDocument();
});

it('should show "Failed" if some agent is not starting or running', () => {
const agents: DbAgent[] = [
{
Expand All @@ -70,9 +72,27 @@ describe('StatusLink', () => {
agentId: 'agent2',
status: ServiceAgentStatus.STOPPING,
},
];
const agentsStatus = getAgentsMonitoringStatus(agents);
render(
<Router history={locationService.getHistory()}>
<StatusLink agentsStatus={agentsStatus} type="services" strippedId="service_id_1" />
</Router>
);
expect(screen.queryByText('OK')).not.toBeInTheDocument();
expect(screen.queryByText('N/A')).not.toBeInTheDocument();
expect(screen.getByText('Failed')).toBeInTheDocument();
});

it('should show "N/A" if there are unknown agents', () => {
const agents: DbAgent[] = [
{
agentId: 'agent3',
isConnected: true,
agentId: 'agent1',
status: ServiceAgentStatus.RUNNING,
},
{
agentId: 'agent2',
status: ServiceAgentStatus.UNKNOWN,
},
];
const agentsStatus = getAgentsMonitoringStatus(agents);
Expand All @@ -82,6 +102,29 @@ describe('StatusLink', () => {
</Router>
);
expect(screen.queryByText('OK')).not.toBeInTheDocument();
expect(screen.getByText('Failed')).toBeInTheDocument();
expect(screen.queryByText('Failed')).not.toBeInTheDocument();
expect(screen.getByText('N/A')).toBeInTheDocument();
});

it('should show "N/A" if there are invalid agents', () => {
const agents: DbAgent[] = [
{
agentId: 'agent1',
status: ServiceAgentStatus.RUNNING,
},
{
agentId: 'agent2',
status: ServiceAgentStatus.INVALID,
},
];
const agentsStatus = getAgentsMonitoringStatus(agents);
render(
<Router history={locationService.getHistory()}>
<StatusLink agentsStatus={agentsStatus} type="services" strippedId="service_id_1" />
</Router>
);
expect(screen.queryByText('OK')).not.toBeInTheDocument();
expect(screen.queryByText('Failed')).not.toBeInTheDocument();
expect(screen.getByText('N/A')).toBeInTheDocument();
});
});

0 comments on commit 830fe56

Please sign in to comment.