forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Set up basic scaffolding for Cypress tests in Kib…
…ana (elastic#108560) * Set up tsconfigs - Required if we're going to have several different Cypress suites (one for each plugin/product essentially) in order for global cy.() commands and it()/describe() to register as expected @see https://docs.cypress.io/guides/tooling/typescript-support#Clashing-types-with-Jest * Set up shared commands and routes NOTE: Unlike ent-search, shared/ will *not* have its own set of tests - rather, shared/cypress is a resource/set of helpers for other test suites to extend/import/etc. * Create basic Enterprise Search Overview E2E tests - For happy path testing, we _likely_ shouldn't need more than these tests going forward - If we ever want to add an error connecting test however, this is likely where it should go (or alternatively, use Kibana's FTR with Enterprise Search host set but not spun up) * Set up App Search Cypress test scaffolding - placeholder/hello world test only * Set up Workplace Search Cypress test scaffolding - placeholder/hello world test only * Add helper script and update README * Add config setup & documentation for potentially running Cypress against Kibana functional server * PR feedback: Fix typescript project names Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
2363c27
commit 5bca890
Showing
19 changed files
with
405 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
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,18 @@ | ||
#! /bin/bash | ||
|
||
# Use either `cypress run` or `cypress open` - defaults to run | ||
MODE="${1:-run}" | ||
|
||
# Choose which product folder to use, e.g. `yarn cypress open as` | ||
PRODUCT="${2}" | ||
# Provide helpful shorthands | ||
if [ "$PRODUCT" == "as" ]; then PRODUCT='app_search'; fi | ||
if [ "$PRODUCT" == "ws" ]; then PRODUCT='workplace_search'; fi | ||
if [ "$PRODUCT" == "overview" ]; then PRODUCT='enterprise_search'; fi | ||
|
||
# Pass all remaining arguments (e.g., ...rest) from the 3rd arg onwards | ||
# as an open-ended string. Appends onto to the end the Cypress command | ||
# @see https://docs.cypress.io/guides/guides/command-line.html#Options | ||
ARGS="${*:3}" | ||
|
||
../../../node_modules/.bin/cypress "$MODE" --project "public/applications/$PRODUCT" --browser chrome $ARGS |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/enterprise_search/public/applications/app_search/cypress.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,20 @@ | ||
{ | ||
"supportFile": "./cypress/support/commands.ts", | ||
"pluginsFile": false, | ||
"retries": { | ||
"runMode": 2 | ||
}, | ||
"baseUrl": "http://localhost:5601", | ||
"env": { | ||
"username": "elastic", | ||
"password": "changeme" | ||
}, | ||
"screenshotsFolder": "../../../target/cypress/screenshots", | ||
"videosFolder": "../../../target/cypress/videos", | ||
"defaultCommandTimeout": 120000, | ||
"execTimeout": 120000, | ||
"pageLoadTimeout": 180000, | ||
"viewportWidth": 1600, | ||
"viewportHeight": 1200, | ||
"video": false | ||
} |
18 changes: 18 additions & 0 deletions
18
...gins/enterprise_search/public/applications/app_search/cypress/integration/engines.spec.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,18 @@ | ||
/* | ||
* 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 { login } from '../support/commands'; | ||
|
||
context('Engines', () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
it('renders', () => { | ||
cy.contains('Engines'); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/enterprise_search/public/applications/app_search/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,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 { login as baseLogin } from '../../../shared/cypress/commands'; | ||
import { appSearchPath } from '../../../shared/cypress/routes'; | ||
|
||
interface Login { | ||
path?: string; | ||
username?: string; | ||
password?: string; | ||
} | ||
export const login = ({ path = '/', ...args }: Login = {}) => { | ||
baseLogin({ ...args }); | ||
cy.visit(`${appSearchPath}${path}`); | ||
}; |
6 changes: 6 additions & 0 deletions
6
x-pack/plugins/enterprise_search/public/applications/app_search/cypress/tsconfig.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,6 @@ | ||
{ | ||
"extends": "../../shared/cypress/tsconfig.json", | ||
"references": [{ "path": "../../shared/cypress/tsconfig.json" }], | ||
"compilerOptions": { "outDir": "../../../../target/cypress/types/app_search" }, | ||
"include": ["./**/*"] | ||
} |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/enterprise_search/public/applications/enterprise_search/cypress.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,21 @@ | ||
{ | ||
"supportFile": false, | ||
"pluginsFile": false, | ||
"retries": { | ||
"runMode": 2 | ||
}, | ||
"baseUrl": "http://localhost:5601", | ||
"env": { | ||
"username": "elastic", | ||
"password": "changeme" | ||
}, | ||
"fixturesFolder": false, | ||
"screenshotsFolder": "../../../target/cypress/screenshots", | ||
"videosFolder": "../../../target/cypress/videos", | ||
"defaultCommandTimeout": 120000, | ||
"execTimeout": 120000, | ||
"pageLoadTimeout": 180000, | ||
"viewportWidth": 1600, | ||
"viewportHeight": 1200, | ||
"video": false | ||
} |
42 changes: 42 additions & 0 deletions
42
...erprise_search/public/applications/enterprise_search/cypress/integration/overview.spec.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,42 @@ | ||
/* | ||
* 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 { login } from '../../../shared/cypress/commands'; | ||
import { overviewPath } from '../../../shared/cypress/routes'; | ||
|
||
context('Enterprise Search Overview', () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
it('should contain product cards', () => { | ||
cy.visit(overviewPath); | ||
cy.contains('Welcome to Elastic Enterprise Search'); | ||
|
||
cy.get('[data-test-subj="appSearchProductCard"]') | ||
.contains('Open App Search') | ||
.should('have.attr', 'href') | ||
.and('match', /app_search/); | ||
|
||
cy.get('[data-test-subj="workplaceSearchProductCard"]') | ||
.contains('Open Workplace Search') | ||
.should('have.attr', 'href') | ||
.and('match', /workplace_search/); | ||
}); | ||
|
||
it('should have a setup guide', () => { | ||
// @see https://github.com/quasarframework/quasar/issues/2233#issuecomment-492975745 | ||
// This only appears to occur for setup guides - I haven't (yet?) run into it on other pages | ||
cy.on('uncaught:exception', (err) => { | ||
if (err.message.includes('> ResizeObserver loop limit exceeded')) return false; | ||
}); | ||
|
||
cy.visit(`${overviewPath}/setup_guide`); | ||
cy.contains('Setup Guide'); | ||
cy.contains('Add your Enterprise Search host URL to your Kibana configuration'); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
x-pack/plugins/enterprise_search/public/applications/enterprise_search/cypress/tsconfig.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,6 @@ | ||
{ | ||
"extends": "../../shared/cypress/tsconfig.json", | ||
"references": [{ "path": "../../shared/cypress/tsconfig.json" }], | ||
"compilerOptions": { "outDir": "../../../../target/cypress/types/enterprise_search" }, | ||
"include": ["./**/*"] | ||
} |
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/enterprise_search/public/applications/shared/cypress/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,35 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Shared non-product-specific commands | ||
*/ | ||
|
||
/* | ||
* Log in a user via XHR | ||
* @see https://docs.cypress.io/guides/getting-started/testing-your-app#Logging-in | ||
*/ | ||
interface Login { | ||
username?: string; | ||
password?: string; | ||
} | ||
export const login = ({ | ||
username = Cypress.env('username'), | ||
password = Cypress.env('password'), | ||
}: Login = {}) => { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/internal/security/login', | ||
headers: { 'kbn-xsrf': 'cypress' }, | ||
body: { | ||
providerType: 'basic', | ||
providerName: 'basic', | ||
currentURL: '/', | ||
params: { username, password }, | ||
}, | ||
}); | ||
}; |
10 changes: 10 additions & 0 deletions
10
x-pack/plugins/enterprise_search/public/applications/shared/cypress/routes.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,10 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const overviewPath = '/app/enterprise_search/overview'; | ||
export const appSearchPath = '/app/enterprise_search/app_search'; | ||
export const workplaceSearchPath = '/app/enterprise_search/workplace_search'; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/enterprise_search/public/applications/shared/cypress/tsconfig.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,8 @@ | ||
{ | ||
"extends": "../../../../../../../tsconfig.base.json", | ||
"include": ["./**/*"], | ||
"compilerOptions": { | ||
"outDir": "../../../../target/cypress/types/shared", | ||
"types": ["cypress", "node"] | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress.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,20 @@ | ||
{ | ||
"supportFile": "./cypress/support/commands.ts", | ||
"pluginsFile": false, | ||
"retries": { | ||
"runMode": 2 | ||
}, | ||
"baseUrl": "http://localhost:5601", | ||
"env": { | ||
"username": "elastic", | ||
"password": "changeme" | ||
}, | ||
"screenshotsFolder": "../../../target/cypress/screenshots", | ||
"videosFolder": "../../../target/cypress/videos", | ||
"defaultCommandTimeout": 120000, | ||
"execTimeout": 120000, | ||
"pageLoadTimeout": 180000, | ||
"viewportWidth": 1600, | ||
"viewportHeight": 1200, | ||
"video": false | ||
} |
18 changes: 18 additions & 0 deletions
18
...terprise_search/public/applications/workplace_search/cypress/integration/overview.spec.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,18 @@ | ||
/* | ||
* 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 { login } from '../support/commands'; | ||
|
||
context('Overview', () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
it('renders', () => { | ||
cy.contains('Workplace Search'); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
...lugins/enterprise_search/public/applications/workplace_search/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,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 { login as baseLogin } from '../../../shared/cypress/commands'; | ||
import { workplaceSearchPath } from '../../../shared/cypress/routes'; | ||
|
||
interface Login { | ||
path?: string; | ||
username?: string; | ||
password?: string; | ||
} | ||
export const login = ({ path = '/', ...args }: Login = {}) => { | ||
baseLogin({ ...args }); | ||
cy.visit(`${workplaceSearchPath}${path}`); | ||
}; |
6 changes: 6 additions & 0 deletions
6
x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress/tsconfig.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,6 @@ | ||
{ | ||
"extends": "../../shared/cypress/tsconfig.json", | ||
"references": [{ "path": "../../shared/cypress/tsconfig.json" }], | ||
"compilerOptions": { "outDir": "../../../../target/cypress/types/workplace_search" }, | ||
"include": ["./**/*"] | ||
} |
Oops, something went wrong.