Skip to content

Commit

Permalink
Revise test
Browse files Browse the repository at this point in the history
  • Loading branch information
criamico committed Sep 6, 2022
1 parent 9cb7686 commit 76c282a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { FLEET, navigateTo } from '../tasks/navigation';
import { cleanupAgentPolicies, cleanupEnrollmentTokens } from '../tasks/cleanup';
import { cleanupAgentPolicies } from '../tasks/cleanup';
import { ENROLLMENT_TOKENS_TAB, ENROLLMENT_TOKENS } from '../screens/fleet';

describe('Enrollment token page', () => {
Expand All @@ -29,7 +29,6 @@ describe('Enrollment token page', () => {

after(() => {
cleanupAgentPolicies();
cleanupEnrollmentTokens();
});

it('Create new Token', () => {
Expand All @@ -41,13 +40,13 @@ describe('Enrollment token page', () => {
cy.getBySel(ENROLLMENT_TOKENS.LIST_TABLE, { timeout: 15000 }).contains('Agent policy 1');
});

it('Delete Token', () => {
it('Delete Token - inactivates the token', () => {
cy.visit('app/fleet/enrollment-tokens');
cy.getBySel(ENROLLMENT_TOKENS.LIST_TABLE).find('tr').should('have.length', 2);
cy.getBySel(ENROLLMENT_TOKENS.TABLE_REVOKE_BTN).first().click();
cy.get('.euiPanel').contains('Are you sure you want to revoke');
cy.get('.euiButton').contains('Revoke enrollment token').click({ force: true });

cy.getBySel(ENROLLMENT_TOKENS.LIST_TABLE).find('tr').should('have.length', 2);
cy.getBySel(ENROLLMENT_TOKENS.TABLE_REVOKE_BTN).first().should('not.exist');
});
});
12 changes: 0 additions & 12 deletions x-pack/plugins/fleet/cypress/tasks/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,3 @@ export function deleteAgentDocs(ignoreUnavailable: boolean = false) {
ignoreUnavailable,
});
}

export function cleanupEnrollmentTokens() {
cy.request('/api/fleet/enrollment_api_keys').then((response: any) => {
response.body.items.forEach((item: any) => {
cy.request({
method: 'DELETE',
url: `/api/fleet/enrollment_api_keys/${item.id}`,
headers: { 'kbn-xsrf': 'kibana' },
});
});
});
}

0 comments on commit 76c282a

Please sign in to comment.