Skip to content

Commit

Permalink
cherry-pick from elastic#59152
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 21, 2020
1 parent 6c5cfc3 commit e18c9ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
6 changes: 5 additions & 1 deletion x-pack/legacy/plugins/apm/e2e/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"mochaFile": "./cypress/test-results/[hash]-e2e-tests.xml",
"toConsole": false
},
"testFiles": "**/*.{feature,features}"
"testFiles": "**/*.{feature,features}",
"env": {
"elasticsearch_username": "admin",
"elasticsearch_password": "changeme"
}
}
33 changes: 7 additions & 26 deletions x-pack/legacy/plugins/apm/e2e/cypress/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,17 @@ const RANGE_FROM = '2019-09-04T18:00:00.000Z';
const RANGE_TO = '2019-09-05T06:00:00.000Z';
const BASE_URL = Cypress.config().baseUrl;

/**
* Credentials in the `kibana.dev.yml` config file will be used to authenticate with Kibana
*/
const KIBANA_DEV_YML_PATH = '../../../../../config/kibana.dev.yml';

/** The default time in ms to wait for a Cypress command to complete */
export const DEFAULT_TIMEOUT = 30 * 1000;

export function loginAndWaitForPage(url: string) {
// read the login details from `kibana.dev.yml`
cy.readFile(KIBANA_DEV_YML_PATH).then(kibanaDevYml => {
const config = safeLoad(kibanaDevYml);
const username = config['elasticsearch.username'];
const password = config['elasticsearch.password'];

const hasCredentials = username && password;

cy.log(
`Authenticating via config credentials from "${KIBANA_DEV_YML_PATH}". username: ${username}, password: ${password}`
);

const options = hasCredentials
? {
auth: { username, password }
}
: {};

const fullUrl = `${BASE_URL}${url}?rangeFrom=${RANGE_FROM}&rangeTo=${RANGE_TO}`;
cy.visit(fullUrl, options);
});
const username = Cypress.env('elasticsearch_username');
const password = Cypress.env('elasticsearch_password');

cy.log(`Authenticating via ${username} / ${password}`);

const fullUrl = `${BASE_URL}${url}?rangeFrom=${RANGE_FROM}&rangeTo=${RANGE_TO}`;
cy.visit(fullUrl, { auth: { username, password } });

cy.viewport('macbook-15');

Expand Down

0 comments on commit e18c9ed

Please sign in to comment.