Skip to content

Commit

Permalink
fix flaky response console release test
Browse files Browse the repository at this point in the history
The test was flaky as it depends on the previous `isolate` test to isolate the host. If it doesn't then the release test can not assert that the host is isolated to start with when doing to `release` test.

This makes the test independent from the previous isolate.
  • Loading branch information
ashokaditya committed Oct 31, 2023
1 parent ee52854 commit ed351c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createAgentPolicyTask, getEndpointIntegrationVersion } from '../../task
import {
checkEndpointListForOnlyIsolatedHosts,
checkEndpointListForOnlyUnIsolatedHosts,
isolateHostFromEndpointList,
} from '../../tasks/isolate';

import { login } from '../../tasks/login';
Expand Down Expand Up @@ -67,28 +68,29 @@ describe('Response console', { tags: ['@ess', '@serverless'] }, () => {
}
});

it('should isolate host from response console', () => {
const command = 'isolate';
it('should release host from response console', () => {
const command = 'release';
waitForEndpointListPageToBeLoaded(createdHost.hostname);
checkEndpointListForOnlyUnIsolatedHosts();
isolateHostFromEndpointList();
checkEndpointListForOnlyIsolatedHosts();
openResponseConsoleFromEndpointList();
performCommandInputChecks(command);
submitCommand();
waitForCommandToBeExecuted(command);
waitForEndpointListPageToBeLoaded(createdHost.hostname);
checkEndpointListForOnlyIsolatedHosts();
checkEndpointListForOnlyUnIsolatedHosts();
});

it('should release host from response console', () => {
const command = 'release';
it('should isolate host from response console', () => {
const command = 'isolate';
waitForEndpointListPageToBeLoaded(createdHost.hostname);
checkEndpointListForOnlyIsolatedHosts();
checkEndpointListForOnlyUnIsolatedHosts();
openResponseConsoleFromEndpointList();
performCommandInputChecks(command);
submitCommand();
waitForCommandToBeExecuted(command);
waitForEndpointListPageToBeLoaded(createdHost.hostname);
checkEndpointListForOnlyUnIsolatedHosts();
checkEndpointListForOnlyIsolatedHosts();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export const isolateHostWithComment = (comment: string, hostname: string): void
cy.getByTestSubj('host_isolation_comment').type(comment);
};

export const isolateHostFromEndpointList = (index: number = 0): void => {
// open action menu and click isolate
cy.getByTestSubj('endpointTableRowActions').eq(index).click();
cy.getByTestSubj('isolateLink').click();
// isolation form confirm
cy.getByTestSubj('hostIsolateConfirmButton').click();
// return to endpoint details
cy.getByTestSubj('hostIsolateSuccessCompleteButton').click();
// close details flyout
cy.getByTestSubj('euiFlyoutCloseButton').click();
};

export const releaseHostWithComment = (comment: string, hostname: string): void => {
cy.contains(`${hostname} is currently isolated.`);
cy.getByTestSubj('endpointHostIsolationForm');
Expand Down

0 comments on commit ed351c2

Please sign in to comment.