From 93f6403be94bc65f95d46e6b21e63a3b5c0552ed Mon Sep 17 00:00:00 2001 From: Dawid Poliszak Date: Thu, 14 Nov 2024 05:37:11 +0100 Subject: [PATCH] fix flaky spaces test (#13) --- e2e-tests/cypress/e2e/Spaces.cy.ts | 10 +++++--- .../support/helpers/KbnApiAdvancedClient.ts | 11 ++++++++ .../cypress/support/helpers/KbnApiClient.ts | 25 +++++++++++++++++++ .../cypress/support/page-objects/DevTools.ts | 5 +--- environments/eck-ror/kind-cluster/ror/kbn.yml | 2 +- environments/elk-ror/images/kbn/Dockerfile | 2 +- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/e2e-tests/cypress/e2e/Spaces.cy.ts b/e2e-tests/cypress/e2e/Spaces.cy.ts index b644a4b..c065802 100644 --- a/e2e-tests/cypress/e2e/Spaces.cy.ts +++ b/e2e-tests/cypress/e2e/Spaces.cy.ts @@ -2,8 +2,8 @@ import * as semver from 'semver'; import { Login } from '../support/page-objects/Login'; import { Loader } from '../support/page-objects/Loader'; import { KibanaNavigation } from '../support/page-objects/KibanaNavigation'; -import { Spaces } from '../support/page-objects/Spaces'; -import { getKibanaVersion } from '../support/helpers'; +import { getKibanaVersion, userCredentials } from '../support/helpers'; +import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; describe('Spaces', () => { beforeEach(() => { @@ -16,6 +16,10 @@ describe('Spaces', () => { Loader.loading(); }); + afterEach(() => { + kbnApiAdvancedClient.deleteAllSpaces(userCredentials); + }); + it('should successfully set feature visibility for default space', () => { cy.log('Navigate to default space management'); cy.get('[data-test-subj=spacesNavSelector]').click(); @@ -81,7 +85,5 @@ describe('Spaces', () => { KibanaNavigation.openHomepage(); KibanaNavigation.openKibanaNavigation(); KibanaNavigation.checkIfNotExists('Analytics'); - - Spaces.removeSpace('Test'); }); }); diff --git a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts index c5cad3d..7e75045 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts @@ -20,6 +20,17 @@ export class KbnApiAdvancedClient extends KbnApiClient { }); }); } + + public deleteAllSpaces(credentials: string): void { + cy.log(`Delete all spaces`); + this.getAllSpaces(credentials).then(spaces => { + spaces + .filter(space => space.id !== 'default') + .forEach(space => { + this.deleteSpace(space.id, credentials); + }); + }); + } } export const kbnApiAdvancedClient = new KbnApiAdvancedClient(); diff --git a/e2e-tests/cypress/support/helpers/KbnApiClient.ts b/e2e-tests/cypress/support/helpers/KbnApiClient.ts index e8ed98f..fe62145 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiClient.ts @@ -47,6 +47,22 @@ export class KbnApiClient { currentGroupHeader: group }); } + + public deleteSpace(spaceName: string, credentials: string, group?: string): void { + cy.kbnDelete({ + endpoint: `api/spaces/space/${spaceName}`, + credentials, + currentGroupHeader: group + }); + } + + public getAllSpaces(credentials: string, group?: string): Cypress.Chainable { + return cy.kbnGet({ + endpoint: `api/spaces/space`, + credentials, + currentGroupHeader: group + }); + } } export const kbnApiClient = new KbnApiClient(); @@ -67,3 +83,12 @@ interface SavedObject { export interface GetObject { saved_objects: SavedObject[]; } + +interface Space { + id: string; + name: string; + initials: string; + color: string; + disabledFeatures: string[]; + imageUrl: string; +} \ No newline at end of file diff --git a/e2e-tests/cypress/support/page-objects/DevTools.ts b/e2e-tests/cypress/support/page-objects/DevTools.ts index f619b34..cfb689a 100644 --- a/e2e-tests/cypress/support/page-objects/DevTools.ts +++ b/e2e-tests/cypress/support/page-objects/DevTools.ts @@ -7,10 +7,7 @@ export class DevTools { cy.log('Open Dev tools'); KibanaNavigation.openKibanaNavigation(); cy.contains('Dev Tools').click(); - cy.findByRole('button', { name: /Dismiss/ }); - cy.findByRole('dialog') - .findByRole('button', { name: /Dismiss/ }) - .click(); + cy.get('[data-test-subj="help-close-button"]').click(); } static sendRequest(text: string) { diff --git a/environments/eck-ror/kind-cluster/ror/kbn.yml b/environments/eck-ror/kind-cluster/ror/kbn.yml index f9727b3..2d6683a 100644 --- a/environments/eck-ror/kind-cluster/ror/kbn.yml +++ b/environments/eck-ror/kind-cluster/ror/kbn.yml @@ -31,5 +31,5 @@ spec: env: - name: ROR_ACTIVATION_KEY value: "${ROR_ACTIVATION_KEY}" - - name: I_UNDERSTAND_IMPLICATION_OF_KBN_PATCHING + - name: I_UNDERSTAND_AND_ACCEPT_KBN_PATCHING value: "yes" diff --git a/environments/elk-ror/images/kbn/Dockerfile b/environments/elk-ror/images/kbn/Dockerfile index 897affe..d2b35c7 100644 --- a/environments/elk-ror/images/kbn/Dockerfile +++ b/environments/elk-ror/images/kbn/Dockerfile @@ -24,7 +24,7 @@ RUN \ exit 1; \ fi && \ INVOKE_ROR_TOOLS="$NODE_PATH /usr/share/kibana/plugins/readonlyrestkbn/ror-tools.js" && \ - $INVOKE_ROR_TOOLS patch && \ + $INVOKE_ROR_TOOLS patch --I_UNDERSTAND_AND_ACCEPT_KBN_PATCHING=yes && \ chown -R kibana:kibana /usr/share/kibana/config USER kibana