diff --git a/.gitignore b/.gitignore index 404bdda..6141961 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ elk-ror/elk-ror.log e2e-tests/node_modules plugins/* results/* -**/subst-ror \ No newline at end of file diff --git a/README.md b/README.md index e39d5af..7e4b102 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ Prerequisites: To bootstrap a Docker-based test environment (ES with latest ROR + KBN with latest ROR) and run Cypress E2E tests run: ```bash -$ ./run-8x.sh +./run-env-and-tests.sh 8.15.2 docker ``` ```bash -$ ./run-7x.sh +./run-env-and-tests.sh 7.17.24 docker ``` #### Tested environment & E2E tests separately @@ -26,12 +26,12 @@ You can bootstrap the test env and run tests separately (to not build the ES+KBN To run the env: ```bash -$ ./elk-ror/start.sh --es "8.10.0" --kbn "8.10.0" +./environments/elk-ror/start.sh --es "8.15.0" --kbn "8.15.2" ``` To run tests on the env: ```bash -$ ./e2e-tests/run.sh "8.10.0" +$ ./e2e-tests/run-tests.sh "8.15.2" ``` #### Cypress tests in interactive GUI diff --git a/e2e-tests/cypress.config.ts b/e2e-tests/cypress.config.ts index aaa8ab4..986a6be 100644 --- a/e2e-tests/cypress.config.ts +++ b/e2e-tests/cypress.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ kibanaVersion: 'KIBANA_VERSION_NOT_SET_YET', elasticsearchUrl: 'https://localhost:9200', enterpriseActivationKey: 'PROVIDE_YOUR_ACTIVATION_KEY', - kibanaUserCredentials: "kibana:kibana" + kibanaUserCredentials: 'kibana:kibana' }, video: true, screenshotOnRunFailure: true, diff --git a/e2e-tests/cypress/e2e/Activation-keys.cy.ts b/e2e-tests/cypress/e2e/Activation-keys.cy.ts index a1904cb..e72ada9 100644 --- a/e2e-tests/cypress/e2e/Activation-keys.cy.ts +++ b/e2e-tests/cypress/e2e/Activation-keys.cy.ts @@ -11,7 +11,7 @@ describe.skip('Activation key', () => { afterEach(() => { cy.kbnPost({ - endpoint: "api/ror/license?overwrite=true", + endpoint: 'api/ror/license?overwrite=true', credentials: userCredentials, payload: { license: `${Cypress.env().enterpriseActivationKey}` } }); diff --git a/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts b/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts index b9a14e5..e31f5ee 100644 --- a/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts +++ b/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts @@ -9,12 +9,12 @@ describe('Direct kibana request', () => { beforeEach(() => { clearDirectKibanaRequestState(); - rorApiClient.configureRorIndexMainSettings("defaultSettings.yaml") + rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml'); }); afterEach(() => { clearDirectKibanaRequestState(); - rorApiClient.configureRorIndexMainSettings("defaultSettings.yaml") + rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml'); }); it('should check direct kibana request', () => { @@ -23,7 +23,7 @@ describe('Direct kibana request', () => { cy.log('Import saved objects for user1'); cy.kbnImport({ - endpoint: "api/saved_objects/_import?overwrite=true", + endpoint: 'api/saved_objects/_import?overwrite=true', credentials: user1, fixtureFilename: 'file.ndjson' }); @@ -33,25 +33,23 @@ describe('Direct kibana request', () => { expect(result.saved_objects[0].id).equal('my-pattern'); expect(result.saved_objects[1].id).equal('my-dashboard'); expect(result.saved_objects).to.have.length(2); - }) + }); cy.log('Get imported saved objects for admin Administrators group'); - kbnApiAdvancedClient.getSavedObjects(admin) - .then(result => { - expect(result.saved_objects[0].id).equal('my-pattern'); - expect(result.saved_objects[1].id).equal('my-dashboard'); - expect(result.saved_objects).to.have.length(2); - }); + kbnApiAdvancedClient.getSavedObjects(admin).then(result => { + expect(result.saved_objects[0].id).equal('my-pattern'); + expect(result.saved_objects[1].id).equal('my-dashboard'); + expect(result.saved_objects).to.have.length(2); + }); cy.log('Get imported saved objects for user1 infosec group'); - kbnApiAdvancedClient.getSavedObjects(user1, "infosec_group") - .then(result => { - const actual = result.saved_objects.some( - saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard' - ); - // eslint-disable-next-line no-unused-expressions - expect(actual).to.be.false; - }); + kbnApiAdvancedClient.getSavedObjects(user1, 'infosec_group').then(result => { + const actual = result.saved_objects.some( + saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard' + ); + // eslint-disable-next-line no-unused-expressions + expect(actual).to.be.false; + }); }; const verifyDataViews = () => { @@ -69,14 +67,12 @@ describe('Direct kibana request', () => { ); cy.log('get all data_views for user1 infosec group'); - kbnApiAdvancedClient - .getDataViews(userCredentials, "infosec_group") - .then(result => { - const actual = result.data_view.some(saved_object => saved_object.id === 'logstash'); + kbnApiAdvancedClient.getDataViews(userCredentials, 'infosec_group').then(result => { + const actual = result.data_view.some(saved_object => saved_object.id === 'logstash'); - // eslint-disable-next-line no-unused-expressions - expect(actual).to.be.false; - }); + // eslint-disable-next-line no-unused-expressions + expect(actual).to.be.false; + }); }; verifySavedObjects(); diff --git a/e2e-tests/cypress/e2e/Reporting-index.cy.ts b/e2e-tests/cypress/e2e/Reporting-index.cy.ts index 5da1d0e..eab6a54 100644 --- a/e2e-tests/cypress/e2e/Reporting-index.cy.ts +++ b/e2e-tests/cypress/e2e/Reporting-index.cy.ts @@ -6,7 +6,7 @@ import { Settings } from '../support/page-objects/Settings'; describe.skip('Reporting index', () => { beforeEach(() => { - Settings.setSettingsData("reportingSettings.yaml"); + Settings.setSettingsData('reportingSettings.yaml'); cy.visit(Cypress.config().baseUrl); cy.on('url:changed', () => { sessionStorage.setItem('ror:ignoreTrialInfo', 'true'); @@ -17,7 +17,7 @@ describe.skip('Reporting index', () => { }); afterEach(() => { - Settings.setSettingsData("defaultSettings.yaml"); + Settings.setSettingsData('defaultSettings.yaml'); }); it('should correctly match index pattern when audit index_template contains .reporting', () => { @@ -28,4 +28,4 @@ describe.skip('Reporting index', () => { cy.contains('acl_history:').should('be.visible'); cy.contains(indexPattern).should('be.visible'); }); -}); \ No newline at end of file +}); diff --git a/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts b/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts index 948e54a..cad9cc7 100644 --- a/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts +++ b/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts @@ -10,11 +10,11 @@ describe('sanity check ro kibana access', () => { }); afterEach(() => { - Settings.setSettingsData("defaultSettings.yaml"); - kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group"); + Settings.setSettingsData('defaultSettings.yaml'); + kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group'); }); it('should verify that everything works', () => { - RoAndRoStrictKibanaAccessAssertions.runAssertions("roSettings.yaml"); + RoAndRoStrictKibanaAccessAssertions.runAssertions('roSettings.yaml'); }); }); diff --git a/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts b/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts index 9e1f63b..d11376c 100644 --- a/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts +++ b/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts @@ -10,11 +10,11 @@ describe('sanity check ro_strict kibana access', () => { }); afterEach(() => { - Settings.setSettingsData("defaultSettings.yaml"); - kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group"); + Settings.setSettingsData('defaultSettings.yaml'); + kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group'); }); it('should verify that everything works', () => { - RoAndRoStrictKibanaAccessAssertions.runAssertions("roStrictSettings.yaml"); + RoAndRoStrictKibanaAccessAssertions.runAssertions('roStrictSettings.yaml'); }); }); diff --git a/e2e-tests/cypress/e2e/Sanity-check.cy.ts b/e2e-tests/cypress/e2e/Sanity-check.cy.ts index 2a8d879..6cee287 100644 --- a/e2e-tests/cypress/e2e/Sanity-check.cy.ts +++ b/e2e-tests/cypress/e2e/Sanity-check.cy.ts @@ -12,14 +12,14 @@ import { SampleData } from '../support/helpers/SampleData'; describe('sanity check', () => { beforeEach(() => { - SampleData.createSampleData("sample_index", 1) + SampleData.createSampleData('sample_index', 1); Login.initialization(); }); afterEach(() => { - esApiAdvancedClient.deleteIndex("sample_index"); - kbnApiAdvancedClient.deleteSavedObjects("admin:dev"); - kbnApiAdvancedClient.deleteSavedObjects("admin:dev", "infosec_group") + esApiAdvancedClient.deleteIndex('sample_index'); + kbnApiAdvancedClient.deleteSavedObjects('admin:dev'); + kbnApiAdvancedClient.deleteSavedObjects('admin:dev', 'infosec_group'); esApiAdvancedClient.pruneAllReportingIndices(); }); diff --git a/e2e-tests/cypress/e2e/Saved-objects.cy.ts b/e2e-tests/cypress/e2e/Saved-objects.cy.ts index 2a098f0..ca0debb 100644 --- a/e2e-tests/cypress/e2e/Saved-objects.cy.ts +++ b/e2e-tests/cypress/e2e/Saved-objects.cy.ts @@ -11,7 +11,7 @@ describe('Saved objects', () => { }); afterEach(() => { - kbnApiAdvancedClient.deleteSavedObjects("admin:dev"); + kbnApiAdvancedClient.deleteSavedObjects('admin:dev'); }); it('should display saved objects list', () => { diff --git a/e2e-tests/cypress/plugins/index.ts b/e2e-tests/cypress/plugins/index.ts index 34b0609..3dbce53 100644 --- a/e2e-tests/cypress/plugins/index.ts +++ b/e2e-tests/cypress/plugins/index.ts @@ -9,7 +9,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) const agent: Agent = new Agent({ rejectUnauthorized: false, - secureProtocol: 'TLSv1_2_method', + secureProtocol: 'TLSv1_2_method' }); try { @@ -17,19 +17,19 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) method, headers: headers, body: body, - agent, + agent } as RequestInit); if (!response.ok) { - throw new Error(`HTTP error: ${method} ${url}: HTTP STATUS ${response.status}; Body: ${await response.text()}`) + throw new Error( + `HTTP error: ${method} ${url}: HTTP STATUS ${response.status}; Body: ${await response.text()}` + ); } const contentType = response.headers.get('content-type') || ''; - const data = contentType.includes('application/json') - ? await response.json() - : await response.text(); + const data = contentType.includes('application/json') ? await response.json() : await response.text(); - console.log(`Response: ${method} ${url}: HTTP STATUS ${response.status}; Body: ${data}`) // todo: do we need that? + console.log(`Response: ${method} ${url}: HTTP STATUS ${response.status}; Body: ${data}`); // todo: do we need that? return data; } catch (error) { console.error('HTTP Request failed:', { @@ -37,7 +37,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) url, method, headers, - body, + body }); throw error; } @@ -47,7 +47,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) const agent: Agent = new Agent({ rejectUnauthorized: false, - secureProtocol: 'TLSv1_2_method', + secureProtocol: 'TLSv1_2_method' }); const form = new FormData(); @@ -58,7 +58,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) const combinedHeaders: { [key: string]: string } = { ...headers, - ...form.getHeaders(), + ...form.getHeaders() }; try { @@ -74,9 +74,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) } const contentType = response.headers.get('content-type') || ''; - const data = contentType.includes('application/json') - ? await response.json() - : await response.text(); + const data = contentType.includes('application/json') ? await response.json() : await response.text(); console.log('HTTP Request successful. Response data:', data); // todo: do we need that? return data; @@ -89,7 +87,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) }); throw error; } - }, + } }); }; diff --git a/e2e-tests/cypress/support/commands.ts b/e2e-tests/cypress/support/commands.ts index 9452ca9..6d54deb 100644 --- a/e2e-tests/cypress/support/commands.ts +++ b/e2e-tests/cypress/support/commands.ts @@ -100,7 +100,7 @@ function httpCall( headers: { 'Content-Type': 'application/json', authorization: `Basic ${btoa(credentials)}`, - ...headers, + ...headers }, body: payload ? JSON.stringify(payload) : null }; @@ -119,7 +119,7 @@ function uploadFile( url, headers: { authorization: `Basic ${btoa(credentials)}`, - ...headers, + ...headers }, file: { fileName: fixtureFilename, diff --git a/e2e-tests/cypress/support/e2e.ts b/e2e-tests/cypress/support/e2e.ts index b399f1e..44e4cf1 100644 --- a/e2e-tests/cypress/support/e2e.ts +++ b/e2e-tests/cypress/support/e2e.ts @@ -24,18 +24,98 @@ declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { export interface Chainable { - kbnRequest({ method, endpoint, credentials, payload, currentGroupHeader }: { method: string, endpoint: string, credentials: string, payload?: Payload, currentGroupHeader?: string }): Chainable; - kbnGet({ endpoint, credentials, currentGroupHeader }: { endpoint: string, credentials: string, currentGroupHeader?: string }): Chainable; - kbnPost({ endpoint, credentials, payload, currentGroupHeader }: { endpoint: string, credentials: string, payload?: Payload, currentGroupHeader?: string }): Chainable; - kbnPut({ endpoint, credentials, payload }: { endpoint: string, credentials: string, payload?: Payload }): Chainable; - kbnImport({ endpoint, credentials, fixtureFilename }: { endpoint: string, credentials: string, fixtureFilename: string }): Chainable; - kbnDelete({ endpoint, credentials, currentGroupHeader }: { endpoint: string, credentials: string, currentGroupHeader?: string }): Chainable; + kbnRequest({ + method, + endpoint, + credentials, + payload, + currentGroupHeader + }: { + method: string; + endpoint: string; + credentials: string; + payload?: Payload; + currentGroupHeader?: string; + }): Chainable; + kbnGet({ + endpoint, + credentials, + currentGroupHeader + }: { + endpoint: string; + credentials: string; + currentGroupHeader?: string; + }): Chainable; + kbnPost({ + endpoint, + credentials, + payload, + currentGroupHeader + }: { + endpoint: string; + credentials: string; + payload?: Payload; + currentGroupHeader?: string; + }): Chainable; + kbnPut({ + endpoint, + credentials, + payload + }: { + endpoint: string; + credentials: string; + payload?: Payload; + }): Chainable; + kbnImport({ + endpoint, + credentials, + fixtureFilename + }: { + endpoint: string; + credentials: string; + fixtureFilename: string; + }): Chainable; + kbnDelete({ + endpoint, + credentials, + currentGroupHeader + }: { + endpoint: string; + credentials: string; + currentGroupHeader?: string; + }): Chainable; - esRequest({ method, endpoint, credentials, payload }: { method: string, endpoint: string, credentials: string, payload?: Payload }): Chainable; - esGet({ endpoint, credentials }: { endpoint: string, credentials: string }): Chainable; - esPost({ endpoint, credentials, payload }: { endpoint: string, credentials: string, payload?: Payload }): Chainable; - esPut({ endpoint, credentials, payload }: { endpoint: string, credentials: string, payload?: Payload }): Chainable; - esDelete({ endpoint, credentials }: { endpoint: string, credentials: string }): Chainable; + esRequest({ + method, + endpoint, + credentials, + payload + }: { + method: string; + endpoint: string; + credentials: string; + payload?: Payload; + }): Chainable; + esGet({ endpoint, credentials }: { endpoint: string; credentials: string }): Chainable; + esPost({ + endpoint, + credentials, + payload + }: { + endpoint: string; + credentials: string; + payload?: Payload; + }): Chainable; + esPut({ + endpoint, + credentials, + payload + }: { + endpoint: string; + credentials: string; + payload?: Payload; + }): Chainable; + esDelete({ endpoint, credentials }: { endpoint: string; credentials: string }): Chainable; } export interface Credentials { @@ -43,6 +123,6 @@ declare global { password: string; } - export type Payload = string | object + export type Payload = string | object; } } diff --git a/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts b/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts index 8d34f42..f398d83 100644 --- a/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts +++ b/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts @@ -1,7 +1,6 @@ import { EsApiClient } from './EsApiClient'; export class EsApiAdvancedClient extends EsApiClient { - public pruneAllReportingIndices(): void { cy.log('Pruning all reporting indices...'); this.indices().then(result => { @@ -14,7 +13,6 @@ export class EsApiAdvancedClient extends EsApiClient { }); cy.log('Pruning all reporting indices - DONE!'); } - } export const esApiAdvancedClient = new EsApiAdvancedClient(); diff --git a/e2e-tests/cypress/support/helpers/EsApiClient.ts b/e2e-tests/cypress/support/helpers/EsApiClient.ts index 41a7bf0..34d02eb 100644 --- a/e2e-tests/cypress/support/helpers/EsApiClient.ts +++ b/e2e-tests/cypress/support/helpers/EsApiClient.ts @@ -1,5 +1,4 @@ export class EsApiClient { - public deleteIndexDocsByQuery(index: string): void { cy.esPost({ endpoint: `${index}/_delete_by_query`, @@ -9,21 +8,21 @@ export class EsApiClient { match_all: {} } } - }) + }); } public refreshIndex(index: string): void { cy.esPost({ endpoint: `${index}/_refresh`, - credentials: Cypress.env().kibanaUserCredentials, - }) + credentials: Cypress.env().kibanaUserCredentials + }); } public deleteIndex(index: string): void { cy.esDelete({ endpoint: index, credentials: Cypress.env().kibanaUserCredentials - }) + }); } public addDocument(index: string, id: string, doc: object): void { @@ -31,15 +30,14 @@ export class EsApiClient { endpoint: `${index}/_doc/${id}`, credentials: Cypress.env().kibanaUserCredentials, payload: doc - }) + }); } public indices(): Cypress.Chainable { - return cy - .esGet({ - endpoint: "_cat/indices?format=json", - credentials: Cypress.env().kibanaUserCredentials - }) + return cy.esGet({ + endpoint: '_cat/indices?format=json', + credentials: Cypress.env().kibanaUserCredentials + }); } } @@ -47,4 +45,4 @@ export const esApiClient = new EsApiClient(); export interface GetIndices { index: string; -} \ No newline at end of file +} diff --git a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts index 435eff3..c5cad3d 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts @@ -1,7 +1,6 @@ import { KbnApiClient } from './KbnApiClient'; export class KbnApiAdvancedClient extends KbnApiClient { - public deleteSavedObjects(credentials: string, group?: string): void { cy.log(`Get all saved objects for the ${credentials}`); this.getSavedObjects(credentials, group).then(result => { @@ -10,7 +9,7 @@ export class KbnApiAdvancedClient extends KbnApiClient { this.deleteSavedObject(savedObject, credentials, group); }); }); - }; + } public deleteDataViews(credentials: string) { cy.log(`get all data_views for the ${credentials}`); @@ -20,8 +19,7 @@ export class KbnApiAdvancedClient extends KbnApiClient { this.deleteDataView(dataView.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 f25fa97..e8ed98f 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiClient.ts @@ -1,8 +1,7 @@ export class KbnApiClient { - public getDataViews(credentials: string, group?: string): Cypress.Chainable { return cy.kbnGet({ - endpoint: "api/data_views", + endpoint: 'api/data_views', credentials: credentials, currentGroupHeader: group }); @@ -10,7 +9,7 @@ export class KbnApiClient { public createDataView(dataView: object, credentials: string, group?: string): void { cy.kbnPost({ - endpoint: "api/data_views/data_view", + endpoint: 'api/data_views/data_view', credentials: credentials, currentGroupHeader: group, payload: dataView @@ -27,7 +26,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", + endpoint: 'api/saved_objects/_find?type=index-pattern&type=search&type=visualization&type=dashboard&type=config', credentials: credentials, currentGroupHeader: group }); @@ -67,4 +66,4 @@ interface SavedObject { export interface GetObject { saved_objects: SavedObject[]; -} \ No newline at end of file +} diff --git a/e2e-tests/cypress/support/helpers/RorApiClient.ts b/e2e-tests/cypress/support/helpers/RorApiClient.ts index 6da889f..d69a739 100644 --- a/e2e-tests/cypress/support/helpers/RorApiClient.ts +++ b/e2e-tests/cypress/support/helpers/RorApiClient.ts @@ -1,9 +1,8 @@ export class RorApiClient { - public configureRorIndexMainSettings(fixtureYamlFileName: string): Cypress.Chainable { - return cy.fixture(fixtureYamlFileName).then((yamlContent) => { + return cy.fixture(fixtureYamlFileName).then(yamlContent => { cy.esPost({ - endpoint: "_readonlyrest/admin/config", + endpoint: '_readonlyrest/admin/config', credentials: Cypress.env().kibanaUserCredentials, payload: { settings: `${yamlContent}` @@ -13,9 +12,9 @@ export class RorApiClient { } public configureRorIndexTestSettings(fixtureYamlFileName: string, ttlInSeconds: number): Cypress.Chainable { - return cy.fixture(fixtureYamlFileName).then((yamlContent) => { + return cy.fixture(fixtureYamlFileName).then(yamlContent => { cy.esPost({ - endpoint: "_readonlyrest/admin/config/test", + endpoint: '_readonlyrest/admin/config/test', credentials: Cypress.env().kibanaUserCredentials, payload: { settings: `${yamlContent}`, @@ -26,15 +25,14 @@ export class RorApiClient { } public configureRorAuthMockSettings(fixtureYamlFileName: string): Cypress.Chainable { - return cy.fixture(fixtureYamlFileName).then((yamlContent) => { + return cy.fixture(fixtureYamlFileName).then(yamlContent => { cy.esPost({ - endpoint: "_readonlyrest/admin/config/test/authmock", + endpoint: '_readonlyrest/admin/config/test/authmock', credentials: Cypress.env().kibanaUserCredentials, payload: yamlContent }); }); } - } -export const rorApiClient = new RorApiClient(); \ No newline at end of file +export const rorApiClient = new RorApiClient(); diff --git a/e2e-tests/cypress/support/helpers/SampleData.ts b/e2e-tests/cypress/support/helpers/SampleData.ts index 5122ea4..ed82733 100644 --- a/e2e-tests/cypress/support/helpers/SampleData.ts +++ b/e2e-tests/cypress/support/helpers/SampleData.ts @@ -1,19 +1,14 @@ -import { esApiClient } from "./EsApiClient" +import { esApiClient } from './EsApiClient'; export class SampleData { - static createSampleData = (index: string, docsCount: number) => { for (let i = 1; i <= docsCount; i++) { - esApiClient.addDocument( - index, - i.toString(), - { - name: 'Jane Smith', - age: 25, - occupation: 'Designer', - '@timestamp': new Date().toISOString() - } - ); + esApiClient.addDocument(index, i.toString(), { + name: 'Jane Smith', + age: 25, + occupation: 'Designer', + '@timestamp': new Date().toISOString() + }); } - } -} \ No newline at end of file + }; +} diff --git a/e2e-tests/cypress/support/helpers/index.ts b/e2e-tests/cypress/support/helpers/index.ts index 3f905ac..c51a253 100644 --- a/e2e-tests/cypress/support/helpers/index.ts +++ b/e2e-tests/cypress/support/helpers/index.ts @@ -17,4 +17,4 @@ export function isJsonString(str) { return true; } -export const userCredentials = `${Cypress.env().login}:${Cypress.env().password}` \ No newline at end of file +export const userCredentials = `${Cypress.env().login}:${Cypress.env().password}`; diff --git a/e2e-tests/cypress/support/page-objects/Editor.ts b/e2e-tests/cypress/support/page-objects/Editor.ts index 94519d5..c55345a 100644 --- a/e2e-tests/cypress/support/page-objects/Editor.ts +++ b/e2e-tests/cypress/support/page-objects/Editor.ts @@ -6,7 +6,8 @@ export class Editor { const selectAllKeys = Cypress.platform === 'darwin' ? '{cmd}a' : '{ctrl}a'; SecuritySettings.getIframeBody() .findByRole('code') - .find('textarea').eq(0) + .find('textarea') + .eq(0) .focus() .type(`${selectAllKeys}{backspace}`, { force: true }) .type(config, { force: true }); @@ -21,10 +22,11 @@ export class Editor { cy.get('@iframeBody') .findByRole('code') - .find('textarea').eq(0) + .find('textarea') + .eq(0) .focus() .type(closeSearchBoxIfExist, { force: true }) - .type(findKeys, { force: true }) + .type(findKeys, { force: true }); SecuritySettings.getIframeBody() .findByRole('button', { name: /toggle replace/i }) diff --git a/e2e-tests/cypress/support/page-objects/Impersonate.ts b/e2e-tests/cypress/support/page-objects/Impersonate.ts index 16e9335..1c5a958 100644 --- a/e2e-tests/cypress/support/page-objects/Impersonate.ts +++ b/e2e-tests/cypress/support/page-objects/Impersonate.ts @@ -182,7 +182,7 @@ export class Impersonate { static setTestSettingsData(): Cypress.Chainable { cy.log('Initialize Test ACL data'); - rorApiClient.configureRorIndexTestSettings("testSettings.yaml", 30 * 60) - return rorApiClient.configureRorAuthMockSettings("authMocks.json") + rorApiClient.configureRorIndexTestSettings('testSettings.yaml', 30 * 60); + return rorApiClient.configureRorAuthMockSettings('authMocks.json'); } } diff --git a/e2e-tests/cypress/support/page-objects/Loader.ts b/e2e-tests/cypress/support/page-objects/Loader.ts index fe542ce..741a800 100644 --- a/e2e-tests/cypress/support/page-objects/Loader.ts +++ b/e2e-tests/cypress/support/page-objects/Loader.ts @@ -14,6 +14,6 @@ export class Loader { cy.log('loading finish'); cy.contains('Loading Elastic', { timeout: 80000 }).should('not.exist'); cy.url().should('include', `${Cypress.config().baseUrl}${spacePrefix}${finishUrl}`); - cy.get('[data-test-subj=globalLoadingIndicator-hidden]').should('be.visible') + cy.get('[data-test-subj=globalLoadingIndicator-hidden]').should('be.visible'); } } diff --git a/e2e-tests/cypress/support/page-objects/Reporting.ts b/e2e-tests/cypress/support/page-objects/Reporting.ts index 77f63af..5aad3b3 100644 --- a/e2e-tests/cypress/support/page-objects/Reporting.ts +++ b/e2e-tests/cypress/support/page-objects/Reporting.ts @@ -14,22 +14,14 @@ export class Reporting { cy.log('verifySavedReport'); this.openReportingPage(openBy); cy.contains(reportName).should('be.visible'); - cy.get('[data-test-subj=reportJobListing]') - .get('.euiTableRow') - .should('have.length', reportsCount); + cy.get('[data-test-subj=reportJobListing]').get('.euiTableRow').should('have.length', reportsCount); } static verifyIfReportingPageAfterRefresh() { cy.log('Verify if reporting page open after refresh'); - cy.url().should( - 'include', - `${Cypress.config().baseUrl}/s/default/app/management/insightsAndAlerting/reporting` - ); + cy.url().should('include', `${Cypress.config().baseUrl}/s/default/app/management/insightsAndAlerting/reporting`); cy.reload(); - cy.url().should( - 'include', - `${Cypress.config().baseUrl}/s/default/app/management/insightsAndAlerting/reporting` - ); + cy.url().should('include', `${Cypress.config().baseUrl}/s/default/app/management/insightsAndAlerting/reporting`); } private static openReportingPage(openBy: OpenBy) { if (openBy === 'rorMenu') { diff --git a/e2e-tests/cypress/support/page-objects/RorMenu.ts b/e2e-tests/cypress/support/page-objects/RorMenu.ts index df42736..da94ee2 100644 --- a/e2e-tests/cypress/support/page-objects/RorMenu.ts +++ b/e2e-tests/cypress/support/page-objects/RorMenu.ts @@ -1,7 +1,6 @@ import { Loader } from './Loader'; export class RorMenu { - static openRorMenu() { cy.get('#rorMenuPopover').click(); } diff --git a/e2e-tests/cypress/support/page-objects/Settings.ts b/e2e-tests/cypress/support/page-objects/Settings.ts index a034643..efabbc8 100644 --- a/e2e-tests/cypress/support/page-objects/Settings.ts +++ b/e2e-tests/cypress/support/page-objects/Settings.ts @@ -88,7 +88,6 @@ export class Settings { static setSettingsData(fixtureYamlSettingsFileName: string) { cy.log('Set settings data from file ' + fixtureYamlSettingsFileName); - rorApiClient.configureRorIndexMainSettings(fixtureYamlSettingsFileName) + rorApiClient.configureRorIndexMainSettings(fixtureYamlSettingsFileName); } - }