-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress for observability serverless (#160674)
Created a separated PR in order setup a basic setup for cypress and test #160620 for serverless. Basic setup to run cypress for serverless-oblt #### How to run it from `x-pack/test_serverless/functional/test_suites/observability/cypress` ``` yarn cypress:serverless:open ``` ![image](https://github.com/elastic/kibana/assets/3369346/8ba7dd80-a9a4-4777-898b-4d9f39bee118)
- Loading branch information
Showing
13 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
x-pack/test_serverless/functional/test_suites/observability/cypress/.eslintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"plugins": ["cypress"], | ||
"extends": [ | ||
"plugin:cypress/recommended" | ||
], | ||
"env": { | ||
"cypress/globals": true | ||
}, | ||
"rules": { | ||
"cypress/no-force": "warn", | ||
"import/no-extraneous-dependencies": "off" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
x-pack/test_serverless/functional/test_suites/observability/cypress/config_headless.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
import { ObservabilityHeadlessTestRunner } from './runner'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const svlConfig = await readConfigFile(require.resolve('./oblt_config.base.ts')); | ||
|
||
return { | ||
...svlConfig.getAll(), | ||
testRunner: ObservabilityHeadlessTestRunner, | ||
}; | ||
} |
19 changes: 19 additions & 0 deletions
19
x-pack/test_serverless/functional/test_suites/observability/cypress/config_runner.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
import { ObservabilityTestRunner } from './runner'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const svlConfig = await readConfigFile(require.resolve('./oblt_config.base.ts')); | ||
|
||
return { | ||
...svlConfig.getAll(), | ||
testRunner: ObservabilityTestRunner, | ||
}; | ||
} |
33 changes: 33 additions & 0 deletions
33
x-pack/test_serverless/functional/test_suites/observability/cypress/cypress.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { defineCypressConfig } from '@kbn/cypress-config'; | ||
|
||
export default defineCypressConfig({ | ||
fileServerFolder: './cypress', | ||
fixturesFolder: './cypress/fixtures', | ||
screenshotsFolder: './cypress/screenshots', | ||
videosFolder: './cypress/videos', | ||
requestTimeout: 10000, | ||
responseTimeout: 40000, | ||
defaultCommandTimeout: 30000, | ||
execTimeout: 120000, | ||
pageLoadTimeout: 120000, | ||
viewportHeight: 1800, | ||
viewportWidth: 1440, | ||
video: false, | ||
videoUploadOnPasses: false, | ||
screenshotOnRunFailure: false, | ||
retries: { | ||
runMode: 1, | ||
}, | ||
e2e: { | ||
baseUrl: 'http://localhost:5620', | ||
supportFile: './support/e2e.ts', | ||
specPattern: './e2e/**/*.cy.ts', | ||
}, | ||
}); |
104 changes: 104 additions & 0 deletions
104
x-pack/test_serverless/functional/test_suites/observability/cypress/e2e/navigation.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
describe('Serverless', () => { | ||
it('Should login', () => { | ||
cy.loginAsElasticUser(); | ||
}); | ||
|
||
it('contains the side navigation for observabilitity serverless', () => { | ||
cy.loginAsElasticUser(); | ||
cy.contains('Discover'); | ||
cy.contains('Dashboards'); | ||
cy.contains('Alerts'); | ||
cy.contains('AIOps'); | ||
cy.contains('Applications'); | ||
cy.contains('Cases'); | ||
cy.contains('Visualizations'); | ||
cy.contains('Add data'); | ||
}); | ||
|
||
it('navigates to discover-dashboard-viz links', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('Discover').click(); | ||
cy.url().should('include', '/app/discover'); | ||
|
||
cy.contains('Dashboards').click(); | ||
cy.url().should('include', '/app/dashboards'); | ||
|
||
cy.contains('Visualizations').click(); | ||
cy.url().should('include', '/app/visualize'); | ||
}); | ||
|
||
it('navigates to alerts links', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('Alerts').click(); | ||
cy.url().should('include', '/observability/alerts'); | ||
|
||
cy.contains('Cases').click(); | ||
cy.url().should('include', '/observability/cases'); | ||
|
||
cy.contains('SLOs').click(); | ||
cy.url().should('include', '/observability/slos'); | ||
}); | ||
|
||
it('navigates to apm links', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('Applications').click(); | ||
cy.contains('Services').click(); | ||
cy.url().should('include', '/apm/services'); | ||
|
||
cy.contains('Traces').click(); | ||
cy.url().should('include', '/apm/traces'); | ||
|
||
cy.contains('Dependencies').click(); | ||
cy.url().should('include', '/apm/dependencies/inventory'); | ||
}); | ||
|
||
it('navigates to get started links', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('Add data').click(); | ||
cy.url().should('include', '/app/observabilityOnboarding'); | ||
}); | ||
|
||
it('navigates to AIOps links', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('AIOps').click(); | ||
cy.contains('Anomaly detection').click(); | ||
cy.url().should('include', '/app/ml/jobs'); | ||
|
||
cy.contains('Spike analysis').click(); | ||
cy.url().should('include', 'app/ml/aiops/explain_log_rate_spikes_index_select'); | ||
|
||
cy.contains('Change Point Detection').click(); | ||
cy.url().should('include', 'app/ml/aiops/change_point_detection_index_select'); | ||
|
||
cy.contains('Job notifications').click(); | ||
cy.url().should('include', 'app/ml/notifications'); | ||
}); | ||
|
||
it('navigates to project settings', () => { | ||
cy.loginAsElasticUser(); | ||
|
||
cy.contains('Project settings').click(); | ||
cy.contains('Management').click(); | ||
cy.url().should('include', '/app/management'); | ||
|
||
cy.contains('Integrations').click(); | ||
cy.url().should('include', '/app/integrations/browse'); | ||
|
||
cy.contains('Fleet').click(); | ||
cy.url().should('include', '/app/fleet/agents'); | ||
}); | ||
}); | ||
|
||
export {}; |
34 changes: 34 additions & 0 deletions
34
x-pack/test_serverless/functional/test_suites/observability/cypress/oblt_config.base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const svlSharedConfig = await readConfigFile( | ||
require.resolve('../../../../shared/config.base.ts') | ||
); | ||
|
||
return { | ||
...svlSharedConfig.getAll(), | ||
esTestCluster: { | ||
...svlSharedConfig.get('esTestCluster'), | ||
serverArgs: [ | ||
...svlSharedConfig.get('esTestCluster.serverArgs'), | ||
'xpack.security.enabled=true', | ||
], | ||
}, | ||
kbnTestServer: { | ||
...svlSharedConfig.get('kbnTestServer'), | ||
serverArgs: [ | ||
...svlSharedConfig.get('kbnTestServer.serverArgs'), | ||
'--csp.strict=false', | ||
'--csp.warnLegacyBrowsers=false', | ||
'--serverless=oblt', | ||
], | ||
}, | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
x-pack/test_serverless/functional/test_suites/observability/cypress/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"author": "Elastic", | ||
"name": "@kbn/serverless-observability", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "Elastic License 2.0", | ||
"scripts": { | ||
"cypress:open": "../../../../../../node_modules/.bin/cypress open --config-file ./cypress.config.ts", | ||
"cypress:run": "../../../../../../node_modules/.bin/cypress run --browser chrome --config-file ./cypress.config.ts", | ||
"cypress:serverless:open": "node ../../../../../../scripts/functional_tests --config ./config_runner.ts", | ||
"cypress:serverless:run": "node ../../../../../../scripts/functional_tests --config ./config_server.ts" | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
x-pack/test_serverless/functional/test_suites/observability/cypress/runner.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
import { withProcRunner } from '@kbn/dev-proc-runner'; | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export type { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export async function ObservabilityCypressTestRunner( | ||
{ getService }: FtrProviderContext, | ||
command: string | ||
) { | ||
const log = getService('log'); | ||
|
||
await withProcRunner(log, async (procs) => { | ||
await procs.run('cypress', { | ||
cmd: 'yarn', | ||
args: [command], | ||
cwd: resolve(__dirname), | ||
env: { | ||
...process.env, | ||
}, | ||
wait: true, | ||
}); | ||
}); | ||
} | ||
|
||
export async function ObservabilityTestRunner(context: FtrProviderContext) { | ||
return ObservabilityCypressTestRunner(context, 'cypress:open'); | ||
} | ||
|
||
export async function ObservabilityHeadlessTestRunner(context: FtrProviderContext) { | ||
return ObservabilityCypressTestRunner(context, 'cypress:run'); | ||
} |
21 changes: 21 additions & 0 deletions
21
x-pack/test_serverless/functional/test_suites/observability/cypress/support/commands.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import 'cypress-real-events/support'; | ||
import 'cypress-axe'; | ||
|
||
Cypress.Commands.add('loginAsElasticUser', () => { | ||
cy.visit('/', { | ||
auth: { | ||
username: 'elastic', | ||
password: 'changeme', | ||
}, | ||
}); | ||
}); | ||
|
||
Cypress.Commands.add('getByTestSubj', (selector: string) => { | ||
return cy.get(`[data-test-subj="${selector}"]`); | ||
}); |
12 changes: 12 additions & 0 deletions
12
x-pack/test_serverless/functional/test_suites/observability/cypress/support/e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
Cypress.on('uncaught:exception', (err, runnable) => { | ||
return false; | ||
}); | ||
|
||
import './commands'; |
13 changes: 13 additions & 0 deletions
13
x-pack/test_serverless/functional/test_suites/observability/cypress/support/types.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
declare namespace Cypress { | ||
interface Chainable { | ||
loginAsElasticUser(): Cypress.Chainable<Cypress.Response<any>>; | ||
getByTestSubj(selector: string): Chainable<JQuery<Element>>; | ||
} | ||
} |