Fix failing cloud test that encodes portions of the URL (#47600) (#47790)

* Improve generation of Kibana base path

* Review adaptions + convert to Typescript
This commit is contained in:
Matthias Wilhelm 2019-10-10 09:49:18 +02:00 committed by GitHub
parent c961095685
commit 4f3945447a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,9 +18,10 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }) {
// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'header', 'home', 'timePicker']);
const appsMenu = getService('appsMenu');
@ -29,8 +30,28 @@ export default function ({ getService, getPageObjects }) {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
describe('Kibana browser back navigation should work', function describeIndexTests() {
const getHost = () => {
if (process.env.TEST_KIBANA_HOSTNAME) {
return process.env.TEST_KIBANA_HOSTNAME;
} else if (process.env.TEST_KIBANA_HOST) {
return process.env.TEST_KIBANA_HOST;
} else {
return 'localhost';
}
};
const getBasePath = () => {
if (process.env.TEST_KIBANA_URL) {
const myURL = new URL(process.env.TEST_KIBANA_URL);
return `${myURL.protocol}//${myURL.host}`;
}
const protocol = process.env.TEST_KIBANA_PROTOCOL || 'http';
const host = getHost();
const port = process.env.TEST_KIBANA_PORT || '5620';
return `${protocol}://${host}:${port}`;
};
describe('Kibana browser back navigation should work', function describeIndexTests() {
before(async () => {
await esArchiver.loadIfNeeded('makelogs');
await browser.refresh();
@ -38,7 +59,7 @@ export default function ({ getService, getPageObjects }) {
});
// FLAKY: https://github.com/elastic/kibana/issues/33468
it.skip('detect navigate back issues', async ()=> {
it.skip('detect navigate back issues', async () => {
let currUrl;
// Detects bug described in issue #31238 - where back navigation would get stuck to URL encoding handling in Angular.
// Navigate to home app
@ -73,20 +94,19 @@ export default function ({ getService, getPageObjects }) {
});
it('encodes portions of the URL as necessary', async () => {
const host = process.env.TEST_KIBANA_HOST || 'localhost';
const port = process.env.TEST_KIBANA_PORT || '5620';
const basePath = `http://${host}:${port}`;
await PageObjects.common.navigateToApp('home');
const basePath = getBasePath();
await browser.get(`${basePath}/app/kibana#/home`, false);
await retry.waitFor('navigation to home app', async () => (
(await browser.getCurrentUrl()) === `${basePath}/app/kibana#/home?_g=()`
));
await retry.waitFor(
'navigation to home app',
async () => (await browser.getCurrentUrl()) === `${basePath}/app/kibana#/home?_g=()`
);
await browser.get(`${basePath}/app/kibana#/home?_g=()&a=b/c`, false);
await retry.waitFor('hash to be properly encoded', async () => (
(await browser.getCurrentUrl()) === `${basePath}/app/kibana#/home?_g=()&a=b%2Fc`
));
await retry.waitFor(
'hash to be properly encoded',
async () => (await browser.getCurrentUrl()) === `${basePath}/app/kibana#/home?_g=()&a=b%2Fc`
);
});
});
}