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,47 +64,103 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.common.sleep(1000);
await PageObjects.share.clickShareTopNavButton();
});
describe('permalink', function () {
it('should allow for copying the snapshot URL', async function () {
const expectedUrl =
baseUrl +
'/app/kibana?_t=1453775307251#' +
'/discover?_g=(refreshInterval:(pause:!t,value:0),time' +
':(from:\'2015-09-19T06:31:44.000Z\',to:\'2015-09' +
'-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-' +
'*\',interval:auto,query:(language:kuery,query:\'\')' +
',sort:!(!(\'@timestamp\',desc)))';
const actualUrl = await PageObjects.share.getSharedUrl();
// strip the timestamp out of each URL
expect(actualUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')).to.be(
expectedUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')
);
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 });
});
it('should allow for copying the snapshot URL as a short URL', async function () {
const re = new RegExp(baseUrl + '/goto/[0-9a-f]{32}$');
await PageObjects.share.checkShortenUrl();
await retry.try(async () => {
after(async function () {
await teardown();
});
describe('permalink', function () {
it('should allow for copying the snapshot URL', async function () {
const expectedUrl =
baseUrl +
'/app/kibana?_t=1453775307251#' +
'/discover?_g=(refreshInterval:(pause:!t,value:0),time' +
':(from:\'2015-09-19T06:31:44.000Z\',to:\'2015-09' +
'-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-' +
'*\',interval:auto,query:(language:kuery,query:\'\')' +
',sort:!(!(\'@timestamp\',desc)))';
const actualUrl = await PageObjects.share.getSharedUrl();
expect(actualUrl).to.match(re);
// strip the timestamp out of each URL
expect(actualUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')).to.be(
expectedUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')
);
});
it('should allow for copying the snapshot URL as a short URL', async function () {
const re = new RegExp(baseUrl + '/goto/[0-9a-f]{32}$');
await PageObjects.share.checkShortenUrl();
await retry.try(async () => {
const actualUrl = await PageObjects.share.getSharedUrl();
expect(actualUrl).to.match(re);
});
});
it('should allow for copying the saved object URL', async function () {
const expectedUrl =
baseUrl +
'/app/kibana#' +
'/discover/ab12e3c0-f231-11e6-9486-733b1ac9221a' +
'?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A0)' +
'%2Ctime%3A(from%3A\'2015-09-19T06%3A31%3A44.000Z\'%2C' +
'to%3A\'2015-09-23T18%3A31%3A44.000Z\'))';
await PageObjects.discover.loadSavedSearch('A Saved Search');
await PageObjects.share.clickShareTopNavButton();
await PageObjects.share.exportAsSavedObject();
const actualUrl = await PageObjects.share.getSharedUrl();
expect(actualUrl).to.be(expectedUrl);
});
});
});
it('should allow for copying the saved object URL', async function () {
const expectedUrl =
baseUrl +
'/app/kibana#' +
'/discover/ab12e3c0-f231-11e6-9486-733b1ac9221a' +
'?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A0)' +
'%2Ctime%3A(from%3A\'2015-09-19T06%3A31%3A44.000Z\'%2C' +
'to%3A\'2015-09-23T18%3A31%3A44.000Z\'))';
await PageObjects.discover.loadSavedSearch('A Saved Search');
await PageObjects.share.clickShareTopNavButton();
await PageObjects.share.exportAsSavedObject();
const actualUrl = await PageObjects.share.getSharedUrl();
expect(actualUrl).to.be(expectedUrl);
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.