Skip to content

Commit

Permalink
[Upgrade] Fix tests for 8.3 snapshots (elastic#132374)
Browse files Browse the repository at this point in the history
* Update canvas url check and widen maps pixel diff

* Move maps screenshots to upgrade dir and update paths/names

* Hide map tooltip if exists

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
liza-mae and kibanamachine committed May 31, 2022
1 parent 9aa2654 commit ac5d003
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 14 deletions.
12 changes: 7 additions & 5 deletions x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.header.waitUntilLoadingHasFinished();
});
it('renders elements on workpad ' + name + ' page ' + page, async () => {
const currentUrl = await browser.getCurrentUrl();
const [, hash] = currentUrl.split('#/');
if (hash.length === 0) {
const browserUrl = await browser.getCurrentUrl();
const currentUrl = new URL(browserUrl);
const pathname = currentUrl.pathname;
const hash = currentUrl.hash;
if (hash.length === 0 && pathname.replace(/\/$/, '') === basePath + '/app/canvas') {
throw new Error('Did not launch canvas sample data for ' + name);
}
if (name === 'ecommerce') {
if (!currentUrl.includes('page/' + page)) {
await browser.get(currentUrl.replace(/\/[^\/]*$/, '/' + page), false);
if (!browserUrl.includes('page/' + page)) {
await browser.get(browserUrl.replace(/\/[^\/]*$/, '/' + page), false);
await PageObjects.header.waitUntilLoadingHasFinished();
}
}
Expand Down
12 changes: 6 additions & 6 deletions x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ export default function ({
});
it('should load layers', async () => {
const percentDifference = await screenshot.compareAgainstBaseline(
'ecommerce_map',
'upgrade_ecommerce_map',
updateBaselines
);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.031);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.05);
});
});
describe('space: ' + space + ', name: flights', () => {
Expand All @@ -147,10 +147,10 @@ export default function ({
});
it('should load saved object and display layers', async () => {
const percentDifference = await screenshot.compareAgainstBaseline(
'flights_map',
'upgrade_flights_map',
updateBaselines
);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.031);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.05);
});
});
describe('space: ' + space + ', name: web logs', () => {
Expand All @@ -172,10 +172,10 @@ export default function ({
});
it('should load saved object and display layers', async () => {
const percentDifference = await screenshot.compareAgainstBaseline(
'web_logs_map',
'upgrade_web_logs_map',
updateBaselines
);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.031);
expect(percentDifference.toFixed(3)).to.be.lessThan(0.05);
});
});
});
Expand Down
6 changes: 6 additions & 0 deletions x-pack/test/upgrade/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { resolve } from 'path';

import { FtrConfigProviderContext } from '@kbn/test';
import { pageObjects } from '../functional/page_objects';
import { ReportingAPIProvider } from './services/reporting_upgrade_services';
Expand Down Expand Up @@ -36,6 +38,10 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
mapsHelper: MapsHelper,
},

screenshots: {
directory: resolve(__dirname, 'screenshots'),
},

junit: {
reportName: 'Kibana Core Tests',
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions x-pack/test/upgrade/services/maps_upgrade_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@
import { FtrProviderContext } from '../ftr_provider_context';

export function MapsHelper({ getPageObjects, getService }: FtrProviderContext) {
const PageObjects = getPageObjects(['maps']);
const PageObjects = getPageObjects(['maps', 'common']);
const testSubjects = getService('testSubjects');
const log = getService('log');

return {
async toggleLayerVisibility(layerName: string) {
log.debug('Inside toggleLayerVisibility');
await PageObjects.maps.openLayerTocActionsPanel(layerName);
await testSubjects.click('layerVisibilityToggleButton');
await PageObjects.common.sleep(3000);
const isTooltipOpen = await testSubjects.exists(`layerTocTooltip`, { timeout: 5000 });
if (isTooltipOpen) {
await testSubjects.click(`layerTocTooltip`);
await PageObjects.common.sleep(1000);
}
},

// In v8.0, the default base map switched from bright to desaturated.
// https://github.com/elastic/kibana/pull/116179
// Maps created before this change will have a base map called "Road map"
Expand All @@ -26,10 +39,10 @@ export function MapsHelper({ getPageObjects, getService }: FtrProviderContext) {
throw new Error('Layer road map not found');
}
if (isRoadMapDesaturated) {
await PageObjects.maps.toggleLayerVisibility('Road map - desaturated');
await this.toggleLayerVisibility('Road map - desaturated');
}
if (isRoadMap) {
await PageObjects.maps.toggleLayerVisibility('Road map');
await this.toggleLayerVisibility('Road map');
}
},

Expand Down

0 comments on commit ac5d003

Please sign in to comment.