Skip to content

Commit

Permalink
update maps tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Apr 4, 2020
1 parent a984cbe commit 40b9dbd
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 38 deletions.
31 changes: 9 additions & 22 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig: {};
ensureCurrentUrl: boolean;
shouldLoginIfPrompted: boolean;
shouldAcceptAlert: boolean;
useActualUrl: boolean;
}

Expand Down Expand Up @@ -127,21 +126,17 @@ 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 () => {
if (useActualUrl) {
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
Expand All @@ -167,7 +162,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
useActualUrl = false,
} = {}
) {
Expand All @@ -180,7 +174,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}
Expand All @@ -200,7 +193,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
useActualUrl = true,
} = {}
) {
Expand All @@ -214,7 +206,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}
Expand All @@ -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,
});
}
Expand All @@ -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])) {
Expand All @@ -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();
Expand Down
9 changes: 3 additions & 6 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
);
}

Expand Down
1 change: 1 addition & 0 deletions test/functional/services/remote/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/apps/maps/add_layer_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/apps/maps/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions x-pack/test/functional/apps/maps/es_geo_grid_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__';

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/maps/joins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/apps/maps/layer_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/functional/apps/maps/sample_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/apps/maps/visualize_create_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 17 additions & 10 deletions x-pack/test/functional/page_objects/gis_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('_');
Expand Down Expand Up @@ -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();

Expand All @@ -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');
}

Expand Down Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit 40b9dbd

Please sign in to comment.