From f348a07f5db7ba88cbeea676927fe00f31412855 Mon Sep 17 00:00:00 2001 From: Dawid Poliszak Date: Sun, 24 Nov 2024 07:30:57 +0100 Subject: [PATCH] Kibana 8.16.0 tests synchronization (#15) --- .github/workflows/trigger-e2e-tests.yml | 2 +- e2e-tests/cypress/e2e/Dev-tools.cy.ts | 2 +- e2e-tests/cypress/e2e/Spaces.cy.ts | 19 +++++++++++++++---- e2e-tests/cypress/e2e/User-settings.cy.ts | 8 +++++++- .../cypress/support/helpers/KbnApiClient.ts | 14 +++++++------- .../cypress/support/page-objects/DevTools.ts | 14 ++++++++++++-- .../support/page-objects/KibanaNavigation.ts | 8 ++++++-- .../RoAndRoStrictKibanaAccessAssertions.ts | 4 +++- .../cypress/support/page-objects/Spaces.ts | 16 +++++++++++++++- .../support/page-objects/TestSettings.ts | 5 ++--- 10 files changed, 69 insertions(+), 23 deletions(-) diff --git a/.github/workflows/trigger-e2e-tests.yml b/.github/workflows/trigger-e2e-tests.yml index 857b3ec..ca4a9d9 100644 --- a/.github/workflows/trigger-e2e-tests.yml +++ b/.github/workflows/trigger-e2e-tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - version: ["8.15.4", "7.17.25"] + version: ["8.16.0", "7.17.25"] env: [docker, eck] steps: - name: Checkout code diff --git a/e2e-tests/cypress/e2e/Dev-tools.cy.ts b/e2e-tests/cypress/e2e/Dev-tools.cy.ts index cbf9d94..1fc1d37 100644 --- a/e2e-tests/cypress/e2e/Dev-tools.cy.ts +++ b/e2e-tests/cypress/e2e/Dev-tools.cy.ts @@ -16,7 +16,7 @@ describe('Dev tools', () => { cy.log('should verify GET /_index_template successful with 403 status'); DevTools.sendRequest('GET /_index_template/'); - DevTools.verifyIf403Status(); + DevTools.verifyIf200Status(); cy.log('should verify POST .kibana/_search successful with 200 status'); DevTools.sendRequest('POST .kibana/_search'); diff --git a/e2e-tests/cypress/e2e/Spaces.cy.ts b/e2e-tests/cypress/e2e/Spaces.cy.ts index c065802..e922f4d 100644 --- a/e2e-tests/cypress/e2e/Spaces.cy.ts +++ b/e2e-tests/cypress/e2e/Spaces.cy.ts @@ -4,6 +4,9 @@ import { Loader } from '../support/page-objects/Loader'; import { KibanaNavigation } from '../support/page-objects/KibanaNavigation'; import { getKibanaVersion, userCredentials } from '../support/helpers'; import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; +import { Spaces } from '../support/page-objects/Spaces'; + +const SPACE_NAME = 'Test space'; describe('Spaces', () => { beforeEach(() => { @@ -27,7 +30,10 @@ describe('Spaces', () => { cy.contains('Default').click(); cy.log('Set feature visibility to hidden'); - if (semver.gte(getKibanaVersion(), '8.4.0')) { + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.get('[data-test-subj="manageSpaces"]').click(); + cy.get('[data-test-subj="default-hyperlink"]').click(); + } else if (semver.gte(getKibanaVersion(), '8.4.0')) { cy.get('[data-test-subj=Default-editSpace]').click(); } cy.get('#featureCategoryCheckbox_kibana').uncheck(); @@ -49,7 +55,10 @@ describe('Spaces', () => { cy.contains('Default').click(); cy.log('Clear all changes'); - if (semver.gte(getKibanaVersion(), '8.4.0')) { + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.get('[data-test-subj="manageSpaces"]').click(); + cy.get('[data-test-subj="default-hyperlink"]').click(); + } else if (semver.gte(getKibanaVersion(), '8.4.0')) { cy.get('[data-test-subj=Default-editSpace]').click(); } cy.get('#featureCategoryCheckbox_kibana').check(); @@ -65,10 +74,10 @@ describe('Spaces', () => { cy.get('[data-test-subj=spacesNavSelector]').click(); cy.get('[data-test-subj=manageSpaces]').click({ force: true }); cy.get('[data-test-subj=createSpace]').click(); - cy.get('[data-test-subj=addSpaceName]').type('Test space'); + cy.get('[data-test-subj=addSpaceName]').type(SPACE_NAME); cy.get('#featureCategoryCheckbox_kibana').uncheck(); cy.get('[data-test-subj=save-space-button]').click(); - cy.contains("Space 'Test space' was saved."); + cy.contains(`Space '${SPACE_NAME}' was saved.`); cy.log('Switch to newly created space'); cy.get('[data-test-subj=spacesNavSelector]').click(); @@ -85,5 +94,7 @@ describe('Spaces', () => { KibanaNavigation.openHomepage(); KibanaNavigation.openKibanaNavigation(); KibanaNavigation.checkIfNotExists('Analytics'); + + Spaces.removeSpace(SPACE_NAME); }); }); diff --git a/e2e-tests/cypress/e2e/User-settings.cy.ts b/e2e-tests/cypress/e2e/User-settings.cy.ts index d3246b5..0537af2 100644 --- a/e2e-tests/cypress/e2e/User-settings.cy.ts +++ b/e2e-tests/cypress/e2e/User-settings.cy.ts @@ -1,6 +1,8 @@ +import * as semver from 'semver'; import { Login } from '../support/page-objects/Login'; import { UserSettings } from '../support/page-objects/UserSettings'; import { SecuritySettings } from '../support/page-objects/SecuritySettings'; +import { getKibanaVersion } from '../support/helpers'; describe('User settings', () => { beforeEach(() => { @@ -12,7 +14,11 @@ describe('User settings', () => { cy.log('Change theme'); SecuritySettings.getIframeBody().find('[data-test-subj="dark"]').click({ force: true }); SecuritySettings.getIframeBody().find('button').contains('Reload page').click({ force: true }); - cy.intercept('**/*dark.css').as('darkMode'); + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.intercept('**/*legacy_dark_theme.min.css').as('darkMode'); + } else { + cy.intercept('**/*dark.css').as('darkMode'); + } cy.reload(); diff --git a/e2e-tests/cypress/support/helpers/KbnApiClient.ts b/e2e-tests/cypress/support/helpers/KbnApiClient.ts index fe62145..35206d5 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiClient.ts @@ -2,7 +2,7 @@ export class KbnApiClient { public getDataViews(credentials: string, group?: string): Cypress.Chainable { return cy.kbnGet({ endpoint: 'api/data_views', - credentials: credentials, + credentials, currentGroupHeader: group }); } @@ -10,7 +10,7 @@ export class KbnApiClient { public createDataView(dataView: object, credentials: string, group?: string): void { cy.kbnPost({ endpoint: 'api/data_views/data_view', - credentials: credentials, + credentials, currentGroupHeader: group, payload: dataView }); @@ -19,7 +19,7 @@ export class KbnApiClient { public deleteDataView(dataViewId: string, credentials: string, group?: string): void { cy.kbnDelete({ endpoint: `api/data_views/data_view/${dataViewId}`, - credentials: credentials, + credentials, currentGroupHeader: group }); } @@ -27,7 +27,7 @@ export class KbnApiClient { public getSavedObjects(credentials: string, group?: string): Cypress.Chainable { return cy.kbnGet({ endpoint: 'api/saved_objects/_find?type=index-pattern&type=search&type=visualization&type=dashboard&type=config', - credentials: credentials, + credentials, currentGroupHeader: group }); } @@ -35,7 +35,7 @@ export class KbnApiClient { public deleteSavedObject(savedObject: SavedObject, credentials: string, group?: string): void { cy.kbnDelete({ endpoint: `api/saved_objects/${savedObject.type}/${savedObject.id}`, - credentials: credentials, + credentials, currentGroupHeader: group }); } @@ -43,7 +43,7 @@ export class KbnApiClient { public deleteSampleData(sampleDatasetName: string, credentials: string, group?: string): void { cy.kbnDelete({ endpoint: `api/sample_data/${sampleDatasetName}`, - credentials: credentials, + credentials, currentGroupHeader: group }); } @@ -91,4 +91,4 @@ interface Space { 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 cfb689a..a59325a 100644 --- a/e2e-tests/cypress/support/page-objects/DevTools.ts +++ b/e2e-tests/cypress/support/page-objects/DevTools.ts @@ -7,12 +7,21 @@ export class DevTools { cy.log('Open Dev tools'); KibanaNavigation.openKibanaNavigation(); cy.contains('Dev Tools').click(); - cy.get('[data-test-subj="help-close-button"]').click(); + + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.get("[data-test-subj='consoleSkipTourButton']").click(); + } else { + cy.get('[data-test-subj="help-close-button"]').click(); + } } static sendRequest(text: string) { cy.log('Send request'); - if (semver.lte(getKibanaVersion(), '7.9.0')) { + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.get('[data-test-subj="clearConsoleInput"]').click(); + cy.get('[data-test-subj="consoleMonacoEditor"]').click().type(text); + cy.get('[data-test-subj="sendRequestButton"]').click(); + } else if (semver.lte(getKibanaVersion(), '7.9.0')) { // Select editor, delete, write cy.get('#ConAppEditor').click(); cy.get('#ConAppInputTextarea').clear({ force: true }); @@ -26,6 +35,7 @@ export class DevTools { cy.get('[data-test-subj=console-textarea]').type(text, { force: true }); cy.get('[data-test-subj=sendRequestButton]').click(); } + cy.contains('Request in progress'); } static verifyIf200Status() { diff --git a/e2e-tests/cypress/support/page-objects/KibanaNavigation.ts b/e2e-tests/cypress/support/page-objects/KibanaNavigation.ts index b5c2856..4dae742 100644 --- a/e2e-tests/cypress/support/page-objects/KibanaNavigation.ts +++ b/e2e-tests/cypress/support/page-objects/KibanaNavigation.ts @@ -26,12 +26,16 @@ export class KibanaNavigation { static checkIfNotVisible(page: string) { cy.log('checkIfNotVisible'); - cy.get('[data-test-subj=collapsibleNav]').contains(page).should('not.be.visible'); + cy.get('[data-test-subj=collapsibleNav]') + .contains(new RegExp(`^${page}$`)) + .should('not.be.visible'); } static checkIfNotExists(page: string) { cy.log('checkIfNotExists'); - cy.get('[data-test-subj=collapsibleNav]').contains(page).should('not.exist'); + cy.get('[data-test-subj=collapsibleNav]') + .contains(new RegExp(`^${page}$`)) + .should('not.exist'); } static checkIfRouteNotReachable(pathname: string, spacePrefix = '/s/default') { diff --git a/e2e-tests/cypress/support/page-objects/RoAndRoStrictKibanaAccessAssertions.ts b/e2e-tests/cypress/support/page-objects/RoAndRoStrictKibanaAccessAssertions.ts index 294e3e8..323d1bf 100644 --- a/e2e-tests/cypress/support/page-objects/RoAndRoStrictKibanaAccessAssertions.ts +++ b/e2e-tests/cypress/support/page-objects/RoAndRoStrictKibanaAccessAssertions.ts @@ -37,7 +37,9 @@ export class RoAndRoStrictKibanaAccessAssertions { cy.log('Verify Canvas features'); - if (semver.gte(getKibanaVersion(), '8.9.0')) { + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.intercept('/s/default/internal/canvas/fns').as('canvasResolve'); + } else if (semver.gte(getKibanaVersion(), '8.9.0')) { cy.intercept('/s/default/internal/canvas/fns?compress=true').as('canvasResolve'); } else if (semver.gte(getKibanaVersion(), '7.17.15')) { cy.intercept('/s/default/api/canvas/fns?compress=true').as('canvasResolve'); diff --git a/e2e-tests/cypress/support/page-objects/Spaces.ts b/e2e-tests/cypress/support/page-objects/Spaces.ts index 59c8190..1f67e5d 100644 --- a/e2e-tests/cypress/support/page-objects/Spaces.ts +++ b/e2e-tests/cypress/support/page-objects/Spaces.ts @@ -1,10 +1,24 @@ +import * as semver from 'semver'; +import { getKibanaVersion } from '../helpers'; + export class Spaces { static removeSpace(spaceName: string) { cy.log('Remove space'); + const spaceNameLowerCaseAndDash = spaceName.toLowerCase().replace(' ', '-'); cy.get('[data-test-subj=spacesNavSelector]').click(); cy.get('[data-test-subj=manageSpaces]').click({ force: true }); - cy.get(`[data-test-subj="${spaceName} space-deleteSpace"]`).click({ force: true }); + if (semver.gte(getKibanaVersion(), '8.16.0')) { + cy.get(`[id="${spaceNameLowerCaseAndDash}-actions"]`).click(); + cy.get(`[data-test-subj="${spaceNameLowerCaseAndDash}-deleteSpace"]`).click(); + } else { + cy.get(`[data-test-subj="${spaceName}-deleteSpace"]`).click(); + } + + cy.intercept(`s/${spaceNameLowerCaseAndDash}/api/spaces/space/${spaceNameLowerCaseAndDash}`).as('deleteSpace'); cy.get('[data-test-subj=confirmModalConfirmButton]').click({ force: true }); + cy.wait('@deleteSpace').then(({ response }) => { + expect([204]).to.include(response.statusCode); + }); } } diff --git a/e2e-tests/cypress/support/page-objects/TestSettings.ts b/e2e-tests/cypress/support/page-objects/TestSettings.ts index 308b5aa..0c789eb 100644 --- a/e2e-tests/cypress/support/page-objects/TestSettings.ts +++ b/e2e-tests/cypress/support/page-objects/TestSettings.ts @@ -30,7 +30,7 @@ export class TestSettings { } static loadCurrentSettings() { - cy.log('Load current settings settings'); + cy.log('Load current settings'); cy.intercept('GET', '/pkp/api/settings').as('loadCurrentSettings'); TestSettings.pressLoadCurrentSettingsButton(); cy.wait('@loadCurrentSettings').then(({ response }) => { @@ -160,8 +160,7 @@ export class TestSettings { cy.log('Set default data'); TestSettings.open(); TestSettings.changeTtlValue('50', 'Seconds'); - // TODO: Uncomment it when es plugin fix issue with settings - // TestSettings.loadCurrentSettings(); + TestSettings.loadCurrentSettings(); TestSettings.pressSaveTestSettingsButton(); } }