Skip to content

Commit

Permalink
Make deregistration testing more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
rtorrero committed Jul 18, 2023
1 parent 476e18f commit 828a186
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions test/e2e/cypress/e2e/hosts_overview.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,61 @@ context('Hosts Overview', () => {
});

describe('Deregistration', () => {
const host = {
name: 'vmdrbddev01',
id: '240f96b1-8d26-53b7-9e99-ffb0f2e735bf',
};

describe('Clean-up buttons should be visible only when needed', () => {
const heartbeatTargets = agents();
const failingHost = heartbeatTargets.shift();
before(() => {
cy.task('startAgentHeartbeat', heartbeatTargets);
cy.visit('/hosts');
cy.url().should('include', '/hosts');
cy.task('startAgentHeartbeat', [host.id]);
});

it('should hide all Clean-up buttons when heartbeat starts except the first one', () => {
cy.get('tr:nth-child(1) > td:nth-child(9)').should(
'contain.text',
'Clean up'
);
it(`should not display a clean-up button for host ${host.name}`, () => {
cy.contains(host.name).within(() => {
cy.get('td:nth-child(9)').should('not.exist');
});
});

it('should show all other cleanup buttons', () => {
for (let i = 2; i < 11; i++) {
cy.get(
`:nth-child(${i}) > .w-48 > .bg-white > .text-jungle-green-500`
).should('not.exist');
cy.get(`tr:nth-child(${i})`).within(() => {
cy.get('[data-testid="cleanup-button"]').should('exist');
});
}
});

it(`should display the cleanup button for host ${host.name} once heartbeat is lost`, () => {
cy.task('stopAgentsHeartbeat');

cy.get('tr:nth-child(1) > .w-48 > [data-testid="cleanup-button"]', {
timeout: 15000,
}).should('exist');
});
});

describe('Clean-up button should deregister a host', () => {
before(() => {
cy.visit('/hosts');
cy.url().should('include', '/hosts');
cy.task('stopAgentsHeartbeat');
});

it('should allow to deregister a host after clean up confirmation', () => {
cy.get(
':nth-child(1) > .w-48 > .bg-white > .text-jungle-green-500'
).click();
cy.get('tr:nth-child(1) > .w-48 > [data-testid="cleanup-button"]', {
timeout: 15000,
}).click();

cy.get('.min-h-screen > .w-full').should(
'contain.text',
'This action will cause Trento to stop tracking all the components discovered by the agent in this host, including the host itself and any other component depending on it.'
);

cy.get('#cleanup-confirm').click();
cy.get(`#host-${failingHost}`).should('not.exist');
cy.get('[data-testid="cleanup-confirm"]').click();

cy.contains(host.name).should('not.exist');
});
});
});
Expand Down

0 comments on commit 828a186

Please sign in to comment.