Add test for implicitly fixed #45150 (#50284)

#45150 appeared in 7.3 and disappeared in 7.4
This commit is contained in:
Anton Dosov 2019-11-14 13:08:50 +01:00 committed by GitHub
parent 6a6fc51bf8
commit b5a0d4b03d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 105 additions and 36 deletions

View file

@ -25,11 +25,12 @@ export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover', 'share', 'timePicker']);
const browser = getService('browser');
describe('shared links', function describeIndexTests() {
let baseUrl;
before(async function () {
async function setup({ storeStateInSessionStorage }) {
baseUrl = PageObjects.common.getHostPort();
log.debug('baseUrl = ' + baseUrl);
// browsers don't show the ':port' if it's 80 or 443 so we have to
@ -47,9 +48,12 @@ export default function ({ getService, getPageObjects }) {
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
await esArchiver.loadIfNeeded('logstash_functional');
await kibanaServer.uiSettings.replace({
'state:storeInSessionStorage': storeStateInSessionStorage
});
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
@ -60,6 +64,22 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.common.sleep(1000);
await PageObjects.share.clickShareTopNavButton();
return async () => {
await kibanaServer.uiSettings.replace({
'state:storeInSessionStorage': undefined
});
};
}
describe('shared links with state in query', async () => {
let teardown;
before(async function () {
teardown = await setup({ storeStateInSessionStorage: false });
});
after(async function () {
await teardown();
});
describe('permalink', function () {
@ -104,4 +124,44 @@ export default function ({ getService, getPageObjects }) {
});
});
});
describe('shared links with state in sessionStorage', async () => {
let teardown;
before(async function () {
teardown = await setup({ storeStateInSessionStorage: true });
});
after(async function () {
await teardown();
});
describe('permalink', function () {
it('should allow for copying the snapshot URL as a short URL and should open it', async function () {
const re = new RegExp(baseUrl + '/goto/[0-9a-f]{32}$');
await PageObjects.share.checkShortenUrl();
let actualUrl;
await retry.try(async () => {
actualUrl = await PageObjects.share.getSharedUrl();
expect(actualUrl).to.match(re);
});
const actualTime = await PageObjects.timePicker.getTimeConfig();
await browser.clearSessionStorage();
await browser.get(actualUrl, false);
await retry.waitFor(
'shortUrl resolves and opens',
async () => {
const resolvedUrl = await browser.getCurrentUrl();
expect(resolvedUrl).to.match(/discover/);
const resolvedTime = await PageObjects.timePicker.getTimeConfig();
expect(resolvedTime.start).to.equal(actualTime.start);
expect(resolvedTime.end).to.equal(actualTime.end);
return true;
}
);
});
});
});
});
}

View file

@ -429,6 +429,15 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
);
}
/**
* Clears session storage for the focused window/frame.
*
* @return {Promise<void>}
*/
public async clearSessionStorage(): Promise<void> {
await driver.executeScript('return window.sessionStorage.clear();');
}
/**
* Closes the currently focused window. In most environments, after the window has been
* closed, it is necessary to explicitly switch to whatever window is now focused.