update maps tests

This commit is contained in:
Dzmitry Lemechko 2020-04-04 16:20:24 +03:00
parent a984cbef71
commit 40b9dbdab8
15 changed files with 76 additions and 38 deletions

View file

@ -43,7 +43,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig: {};
ensureCurrentUrl: boolean;
shouldLoginIfPrompted: boolean;
shouldAcceptAlert: boolean;
useActualUrl: boolean;
}
@ -127,13 +126,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
}
private async navigate(navigateProps: NavigateProps) {
const {
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
} = navigateProps;
const { appConfig, ensureCurrentUrl, shouldLoginIfPrompted, useActualUrl } = navigateProps;
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
await retry.try(async () => {
@ -141,7 +134,9 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
log.debug(`navigateToActualUrl ${appUrl}`);
await browser.get(appUrl);
} else {
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
log.debug(`navigateToUrl ${appUrl}`);
await browser.get(appUrl);
// await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
}
const currentUrl = shouldLoginIfPrompted
@ -167,7 +162,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
useActualUrl = false,
} = {}
) {
@ -180,7 +174,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}
@ -200,7 +193,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
useActualUrl = true,
} = {}
) {
@ -214,7 +206,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}
@ -228,18 +219,12 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
async navigateToActualUrl(
appName: string,
hash?: string,
{
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
} = {}
{ basePath = '', ensureCurrentUrl = true, shouldLoginIfPrompted = true } = {}
) {
await this.navigateToUrl(appName, hash, {
basePath,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl: true,
});
}
@ -252,7 +237,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
async navigateToApp(
appName: string,
{ basePath = '', shouldLoginIfPrompted = true, shouldAcceptAlert = true, hash = '' } = {}
{ basePath = '', shouldLoginIfPrompted = true, hash = '' } = {}
) {
let appUrl: string;
if (config.has(['apps', appName])) {
@ -274,7 +259,9 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
await retry.tryForTime(defaultTryTimeout * 2, async () => {
let lastUrl = await retry.try(async () => {
// since we're using hash URLs, always reload first to force re-render
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
log.debug('navigate to: ' + appUrl);
await browser.get(appUrl);
// await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
await this.sleep(700);
log.debug('returned from get, calling refresh');
await browser.refresh();

View file

@ -130,23 +130,20 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
public async clickHistogramBar() {
const el = await elasticChart.getCanvas();
const x = browser.isW3CEnabled ? 0 : 200;
await browser
.getActions()
.move({ x, y: 20, origin: el._webElement })
.move({ x: 0, y: 20, origin: el._webElement })
.click()
.perform();
}
public async brushHistogram() {
const el = await elasticChart.getCanvas();
const x1 = browser.isW3CEnabled ? -300 : 200;
const x2 = browser.isW3CEnabled ? -100 : 400;
await browser.dragAndDrop(
{ location: el, offset: { x: x1, y: 20 } },
{ location: el, offset: { x: x2, y: 30 } }
{ location: el, offset: { x: -300, y: 20 } },
{ location: el, offset: { x: -100, y: 30 } }
);
}

View file

@ -110,6 +110,7 @@ async function attemptToCreateCommand(
w3c: true,
args: chromeOptions,
});
chromeCapabilities.set('unexpectedAlertBehaviour', 'accept');
chromeCapabilities.set('goog:loggingPrefs', { browser: 'ALL' });
const session = await new Builder()

View file

@ -47,6 +47,8 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
expect(await browser.getCurrentUrl()).to.eql(getKibanaUrl('/app/appleave1'));
});
it('allows navigation if user click confirm on the confirmation dialog', async () => {
const alert = await browser.getAlert();
await alert?.accept();
await PageObjects.common.navigateToApp('appleave1');
await appsMenu.clickLink('AppLeave 2');

View file

@ -20,6 +20,10 @@ export default function({ getService, getPageObjects }) {
await PageObjects.maps.selectVectorLayer(LAYER_NAME);
});
after(async () => {
await PageObjects.maps.gotoMapListingPage();
});
it('should show unsaved layer in layer TOC', async () => {
const vectorLayerExists = await PageObjects.maps.doesLayerExist(LAYER_NAME);
expect(vectorLayerExists).to.be(true);

View file

@ -15,6 +15,10 @@ export default function({ getService, getPageObjects }) {
await PageObjects.common.navigateToApp('discover');
});
afterEach(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should link geo_shape fields to Maps application', async () => {
await PageObjects.discover.selectIndexPattern('geo_shapes*');
await PageObjects.discover.clickFieldListItem('geometry');

View file

@ -15,6 +15,10 @@ export default function({ getPageObjects, getService }) {
await PageObjects.maps.loadSavedMap('document example');
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
async function getRequestTimestamp() {
await inspector.open();
await inspector.openInspectorRequestsView();

View file

@ -90,6 +90,10 @@ export default function({ getPageObjects, getService }) {
await PageObjects.maps.loadSavedMap('geo grid heatmap example');
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
const LAYER_ID = '3xlvm';
const HEATMAP_PROP_NAME = '__kbn_heatmap_weight__';
@ -140,6 +144,10 @@ export default function({ getPageObjects, getService }) {
await inspector.close();
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should contain geotile_grid aggregation elasticsearch request', async () => {
await inspector.open();
await inspector.openInspectorRequestsView();
@ -219,6 +227,10 @@ export default function({ getPageObjects, getService }) {
await inspector.close();
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should contain geotile_grid aggregation elasticsearch request', async () => {
await inspector.open();
await inspector.openInspectorRequestsView();

View file

@ -31,6 +31,10 @@ export default function({ getPageObjects }) {
await PageObjects.maps.closeOrCancelLayer();
});
after(async () => {
await PageObjects.maps.gotoMapListingPage();
});
it('should add GeoJSON file to map', async () => {
const layerLoadedInToc = await PageObjects.maps.doesLayerExist(IMPORT_FILE_PREVIEW_NAME);
expect(layerLoadedInToc).to.be(true);

View file

@ -49,6 +49,10 @@ export default function({ getService, getPageObjects }) {
await PageObjects.maps.waitForLayerAddPanelClosed();
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should not activate add layer button until indexing succeeds', async () => {
await indexPoint();

View file

@ -33,6 +33,7 @@ export default function({ getPageObjects, getService }) {
after(async () => {
await inspector.close();
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should re-fetch join with refresh timer', async () => {

View file

@ -14,6 +14,10 @@ export default function({ getPageObjects }) {
await PageObjects.maps.loadSavedMap('layer with errors');
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
describe('ESSearchSource with missing index pattern id', () => {
const MISSING_INDEX_ID = 'idThatDoesNotExitForESSearchSource';
const LAYER_NAME = MISSING_INDEX_ID;

View file

@ -45,6 +45,7 @@ export default function({ getPageObjects, getService, updateBaselines }) {
after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('ecommerce');
@ -72,6 +73,7 @@ export default function({ getPageObjects, getService, updateBaselines }) {
after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('flights');
@ -101,6 +103,7 @@ export default function({ getPageObjects, getService, updateBaselines }) {
after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('logs');

View file

@ -14,6 +14,10 @@ export default function({ getPageObjects }) {
await PageObjects.visualize.navigateToNewVisualization();
});
after(async () => {
await PageObjects.maps.gotoMapListingPage({ isOnUnsavedMap: true });
});
it('should show maps application in create menu', async () => {
const hasMapsApp = await PageObjects.visualize.hasMapsApp();
expect(hasMapsApp).to.equal(true);

View file

@ -16,6 +16,7 @@ export function GisPageProvider({ getService, getPageObjects }) {
const find = getService('find');
const queryBar = getService('queryBar');
const comboBox = getService('comboBox');
const browser = getService('browser');
function escapeLayerName(layerName) {
return layerName.split(' ').join('_');
@ -102,11 +103,11 @@ export function GisPageProvider({ getService, getPageObjects }) {
// use the search filter box to narrow the results down to a single
// entry, or at least to a single page of results
async loadSavedMap(name) {
async loadSavedMap(name, options = { isOnUnsavedMap: false }) {
log.debug(`Load Saved Map ${name}`);
await retry.try(async () => {
await this.searchForMapWithName(name);
await this.searchForMapWithName(name, options);
await this.selectMap(name);
await PageObjects.header.waitUntilLoadingHasFinished();
@ -128,10 +129,10 @@ export function GisPageProvider({ getService, getPageObjects }) {
await PageObjects.header.waitUntilLoadingHasFinished();
}
async openNewMap() {
async openNewMap(options = { isOnUnsavedMap: false }) {
log.debug(`Open new Map`);
await this.gotoMapListingPage();
await this.gotoMapListingPage(options);
await testSubjects.click('newMapLink');
}
@ -163,10 +164,10 @@ export function GisPageProvider({ getService, getPageObjects }) {
return exists;
}
async searchForMapWithName(name) {
async searchForMapWithName(name, options = { isOnUnsavedMap: false }) {
log.debug(`searchForMapWithName: ${name}`);
await this.gotoMapListingPage();
await this.gotoMapListingPage(options);
await retry.try(async () => {
const searchFilter = await testSubjects.find('searchFilter');
@ -192,20 +193,26 @@ export function GisPageProvider({ getService, getPageObjects }) {
return hits;
}
async gotoMapListingPage() {
async gotoMapListingPage(options = { isOnUnsavedMap: false }) {
log.debug('gotoMapListingPage');
const onPage = await this.onMapListingPage();
if (!onPage) {
await retry.try(async () => {
await PageObjects.common.navigateToUrl('maps', '/', { basePath: this.basePath });
if (options.isOnUnsavedMap === true) {
await testSubjects.click('~breadcrumb & ~first');
const alert = await browser.getAlert();
await alert.accept();
} else {
await PageObjects.common.navigateToUrl('maps', '/', { basePath: this.basePath });
}
const onMapListingPage = await this.onMapListingPage();
if (!onMapListingPage) throw new Error('Not on map listing page.');
});
}
}
async getMapCountWithName(name) {
await this.gotoMapListingPage();
async getMapCountWithName(name, options = { isOnUnsavedMap: false }) {
await this.gotoMapListingPage(options);
log.debug(`getMapCountWithName: ${name}`);
await this.searchForMapWithName(name);