update functional tests to support Firefox (#34635) (#35214)

This commit is contained in:
Dmitry Lemeshko 2019-04-17 15:05:43 +02:00 committed by GitHub
parent 094cf670c9
commit d1e8ca057a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 76 additions and 66 deletions

View file

@ -100,7 +100,7 @@
class="euiTitle euiTitle--small"
></h2>
<div class="euiSpacer euiSpacer--m"></div>
<div class="euiLoadingSpinner euiLoadingSpinner--large"></div>
<div class="euiLoadingSpinner euiLoadingSpinner--large" data-test-subj="loadingSpinner"></div>
<div class="euiSpacer euiSpacer--m"></div>
<div ng-show="fetchStatus">{{fetchStatus.complete}} / {{fetchStatus.total}}</div>
</div>

View file

@ -80,6 +80,7 @@ export default function ({ getService, getPageObjects }) {
describe('filter pills', async function () {
before(async () => {
await filterBar.ensureFieldEditorModalIsClosed();
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();

View file

@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }) {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('dashboard with everything');
await PageObjects.dashboard.waitForRenderComplete();
});
it('should have data-shared-items-count set to the number of embeddables on the dashboard', async () => {
@ -68,7 +69,7 @@ export default function ({ getService, getPageObjects }) {
});
it('data-shared-item title is cleared with an empty panel title string', async () => {
await dashboardPanelActions.setCustomPanelTitle('h\b');
await dashboardPanelActions.setCustomPanelTitle('');
await retry.try(async () => {
const sharedData = await PageObjects.dashboard.getPanelSharedItemData();
const foundSharedItemTitle = !!sharedData.find(item => {

View file

@ -162,6 +162,7 @@ export default function ({ getService, getPageObjects }) {
it('should show correct initial chart interval of Auto', async function () {
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.waitUntilSearchingHasFinished();
const actualInterval = await PageObjects.discover.getChartInterval();
const expectedInterval = 'Auto';
@ -378,13 +379,14 @@ export default function ({ getService, getPageObjects }) {
}
});
describe('query #2, which has an empty time range', function () {
describe('query #2, which has an empty time range', async () => {
const fromTime = '1999-06-11 09:22:11.000';
const toTime = '1999-06-12 11:21:04.000';
before(() => {
before(async () => {
log.debug('setAbsoluteRangeForAnotherQuery');
return PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.waitUntilSearchingHasFinished();
});
it('should show "no results"', async () => {
@ -398,7 +400,7 @@ export default function ({ getService, getPageObjects }) {
});
});
describe('filter editor', function () {
describe('filter editor', async function () {
it('should add a phrases filter', async function () {
await filterBar.addFilter('extension.raw', 'is one of', 'jpg');
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);

View file

@ -24,7 +24,6 @@ export default function ({ getService, getPageObjects }) {
const inspector = getService('inspector');
const retry = getService('retry');
const filterBar = getService('filterBar');
const renderable = getService('renderable');
const PageObjects = getPageObjects(['common', 'visualize', 'header', 'timePicker']);
const fromTime = '2015-09-19 06:31:44.000';
@ -124,7 +123,6 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.selectField('@timestamp');
await PageObjects.visualize.setInterval('Daily');
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const data = await PageObjects.visualize.getTableVisData();
log.debug(data.split('\n'));
expect(data.trim().split('\n')).to.be.eql([
@ -144,7 +142,6 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.selectField('@timestamp');
await PageObjects.visualize.setInterval('Daily');
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const data = await PageObjects.visualize.getTableVisData();
expect(data.trim().split('\n')).to.be.eql([
'2015-09-20', '4,757',
@ -155,8 +152,7 @@ export default function ({ getService, getPageObjects }) {
it('should correctly filter for applied time filter on the main timefield', async () => {
await filterBar.addFilter('@timestamp', 'is between', '2015-09-19', '2015-09-21');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
const data = await PageObjects.visualize.getTableVisData();
expect(data.trim().split('\n')).to.be.eql([
'2015-09-20', '4,757',
@ -165,8 +161,7 @@ export default function ({ getService, getPageObjects }) {
it('should correctly filter for pinned filters', async () => {
await filterBar.toggleFilterPinned('@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
const data = await PageObjects.visualize.getTableVisData();
expect(data.trim().split('\n')).to.be.eql([
'2015-09-20', '4,757',
@ -232,7 +227,7 @@ export default function ({ getService, getPageObjects }) {
it('should apply correct filter', async () => {
await PageObjects.visualize.filterOnTableCell(1, 3);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
const data = await PageObjects.visualize.getTableVisContent();
expect(data).to.be.eql([
[ 'png', '1,373' ],

View file

@ -129,6 +129,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.addCustomRange(600, 700);
await PageObjects.visualize.clickAddRange();
await PageObjects.visualize.addCustomRange(700, 800);
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.clickGo();
const legends = await PageObjects.visualize.getLegendEntries();
const expectedLegends = [

View file

@ -64,11 +64,13 @@ export default function ({ getService, getPageObjects }) {
beforeEach(async function () {
await inspector.open();
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
});
afterEach(async function () {
await inspector.close();
await filterBar.removeFilter('machine.os.raw');
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
});
it('should allow filtering for values', async function () {

View file

@ -61,8 +61,8 @@ export default function ({ getService, getPageObjects }) {
await pointSeriesVis.toggleCollapsibleTitle('Average machine.ram');
log.debug('Average memory value axis - ValueAxis-2');
await pointSeriesVis.setSeriesAxis(1, 'ValueAxis-2');
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.clickGo();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
});
describe('secondary value axis', function () {

View file

@ -236,9 +236,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.clickBucket('Split Series');
await PageObjects.visualize.selectAggregation('Terms');
await PageObjects.visualize.selectField('response.raw');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.sleep(1003);
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
@ -251,7 +249,6 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.toggleOpenEditor(1, 'false');
await PageObjects.visualize.selectCustomSortMetric(3, 'Min', 'bytes');
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const expectedEntries = ['404', '200', '503'];
const legendEntries = await PageObjects.visualize.getLegendEntries();
@ -278,18 +275,15 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.clickBucket('Split Series');
await PageObjects.visualize.selectAggregation('Terms');
await PageObjects.visualize.selectField('response.raw');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.toggleOpenEditor(3, 'false');
await PageObjects.visualize.clickAddBucket();
await PageObjects.visualize.clickBucket('Split Series');
await PageObjects.visualize.selectAggregation('Terms');
await PageObjects.visualize.selectField('machine.os');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.sleep(1003);
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const expectedEntries = [
'200 - win 8', '200 - win xp', '200 - ios', '200 - osx', '200 - win 7',
@ -303,7 +297,6 @@ export default function ({ getService, getPageObjects }) {
it('should show correct series when disabling first agg', async function () {
await PageObjects.visualize.toggleDisabledAgg(3);
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const expectedEntries = [ 'win 8', 'win xp', 'ios', 'osx', 'win 7' ];
const legendEntries = await PageObjects.visualize.getLegendEntries();
@ -318,12 +311,8 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.toggleOpenEditor(2, 'false');
await PageObjects.visualize.toggleOpenEditor(1);
await PageObjects.visualize.selectAggregation('Derivative', 'metrics');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.sleep(1003);
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();
const expectedEntries = [
'Derivative of Count'

View file

@ -28,6 +28,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['header', 'common']);
const browser = getService('browser');
const globalNav = getService('globalNav');
const config = getService('config');
const defaultFindTimeout = config.get('timeouts.find');
class DiscoverPage {
async getQueryField() {
@ -60,6 +62,11 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
});
}
async waitUntilSearchingHasFinished() {
const spinner = await testSubjects.find('loadingSpinner');
await find.waitForElementHidden(spinner, defaultFindTimeout * 10);
}
async getColumnHeaders() {
const headerElements = await testSubjects.findAll('docTableHeaderField');
return await Promise.all(headerElements.map(async (el) => await el.getVisibleText()));

View file

@ -473,7 +473,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
const datePatternField = await find.byCssSelector(
'input[data-test-subj="dateEditorPattern"]'
);
// Both clearValue & clearValueWithKeyboard does not work here
// clearValue does not work here
// Send Backspace event for each char in value string to clear field
await datePatternField.clearValueWithKeyboard({ charByChar: true });
await datePatternField.type(datePattern);
@ -550,7 +550,13 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
log.debug(`Clicking importObjects`);
await testSubjects.click('importObjects');
log.debug(`Setting the path on the file input`);
await find.setValue('.euiFilePicker__input', path);
if (browser.isW3CEnabled) {
const input = await find.byCssSelector('.euiFilePicker__input');
await input.type(path);
} else {
await find.setValue('.euiFilePicker__input', path);
}
if (!overwriteAll) {
log.debug(`Toggling overwriteAll`);
await testSubjects.click('importSavedObjectsOverwriteToggle');

View file

@ -503,12 +503,8 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
async setInterval(newValue) {
log.debug(`Visualize.setInterval(${newValue})`);
const input = await find.byCssSelector('select[ng-model="agg.params.interval"]');
await input.type(newValue);
// The interval element will only interpret space as "select this" if there
// was a long enough gap from the typing above to the space click. Hence the
// need for the sleep.
await PageObjects.common.sleep(500);
await input.pressKeys(browser.keys.SPACE);
const option = await input.findByCssSelector(`option[label="${newValue}"]`);
await option.click();
}
async setCustomInterval(newValue) {
@ -822,18 +818,15 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
const chartTypes = await retry.try(
async () => await find
.allByCssSelector(`.visWrapper__chart circle[data-label="${dataLabel}"][fill-opacity="1"]`, defaultFindTimeout * 2));
// 5). for each chart element, find the green circle, then the cy position
async function getChartType(chart) {
// 4). for each chart element, find the green circle, then the cy position
const chartData = await Promise.all(chartTypes.map(async chart => {
const cy = await chart.getAttribute('cy');
// the point_series_options test has data in the billions range and
// getting 11 digits of precision with these calculations is very hard
return Math.round(((yAxisHeight - cy) * yAxisRatio).toPrecision(6));
}
}));
// 4). pass the chartTypes to the getChartType function
const getChartTypesPromises = chartTypes.map(getChartType);
return await Promise.all(getChartTypesPromises);
return chartData;
}
// this is ALMOST identical to DiscoverPage.getBarChartData

View file

@ -32,6 +32,11 @@ export async function BrowserProvider({ getService }) {
*/
keys = Key;
/**
* Is WebDriver instance W3C compatible
*/
isW3CEnabled = (driver.executor_.w3c === true);
/**
* Retrieves the a rect describing the current top-level window's size and position.
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_Window.html
@ -182,7 +187,7 @@ export async function BrowserProvider({ getService }) {
* @return {Promise<void>}
*/
async pressKeys(...args) {
const actions = driver.actions({ bridge: true });
const actions = this.isW3CEnabled ? driver.actions() : driver.actions({ bridge: true });
const chord = this.keys.chord(...args);
await actions.sendKeys(chord).perform();
}
@ -230,10 +235,10 @@ export async function BrowserProvider({ getService }) {
* @return {Promise<LogEntry[]>}
*/
async getLogsFor(...args) {
//The logs endpoint has not been defined in W3C Spec browsers other than Chrome don't have access to this endpoint.
//See: https://github.com/w3c/webdriver/issues/406
//See: https://w3c.github.io/webdriver/#endpoints
if (driver.executor_.w3c === true) {
// The logs endpoint has not been defined in W3C Spec browsers other than Chrome don't have access to this endpoint.
// See: https://github.com/w3c/webdriver/issues/406
// See: https://w3c.github.io/webdriver/#endpoints
if (this.isW3CEnabled) {
return [];
} else {
return await driver.manage().logs().get(...args);

View file

@ -22,6 +22,7 @@ export function ComboBoxProvider({ getService }) {
const find = getService('find');
const log = getService('log');
const retry = getService('retry');
const browser = getService('browser');
// wrapper around EuiComboBox interactions
class ComboBox {
@ -126,8 +127,8 @@ export function ComboBoxProvider({ getService }) {
async closeOptionsList(comboBoxElement) {
const isOptionsListOpen = await testSubjects.exists('comboBoxOptionsList');
if (isOptionsListOpen) {
const toggleBtn = await comboBoxElement.findByCssSelector('[data-test-subj="comboBoxToggleListButton"]');
await toggleBtn.click();
const input = await comboBoxElement.findByTagName('input');
await input.pressKeys(browser.keys.ESCAPE);
}
}

View file

@ -135,7 +135,17 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) {
panelOptions = await this.getPanelHeading(originalTitle);
}
await this.customizePanel(panelOptions);
await testSubjects.setValue('customDashboardPanelTitleInput', customTitle);
if (customTitle.length === 0) {
if (browser.isW3CEnabled) {
const input = await testSubjects.find('customDashboardPanelTitleInput');
await input.clearValueWithKeyboard();
} else {
// to clean in Chrome we trigger a change: put letter and delete it
await testSubjects.setValue('customDashboardPanelTitleInput', 'h\b');
}
} else {
await testSubjects.setValue('customDashboardPanelTitleInput', customTitle);
}
await this.toggleContextMenu(panelOptions);
}

View file

@ -331,6 +331,11 @@ export async function FindProvider({ getService }) {
log.debug(`Find.waitForElementStale with timeout=${timeout}`);
await driver.wait(until.stalenessOf(element._webElement), timeout);
}
async waitForElementHidden(element, timeout = defaultFindTimeout) {
log.debug(`Find.waitForElementHidden with timeout=${timeout}`);
await driver.wait(until.elementIsNotVisible(element._webElement), timeout);
}
}
return new Find();

View file

@ -162,16 +162,13 @@ export class WebElementWrapper {
* @param {string|string[]} keys
* @return {Promise<void>}
*/
async pressKeys(...args) {
let chord;
//leadfoot compatibility
if (Array.isArray(args[0])) {
chord = this._Keys.chord(...args[0]);
async pressKeys(keys) {
if (Array.isArray(keys)) {
const chord = this._Keys.chord(keys);
await this._webElement.sendKeys(chord);
} else {
chord = this._Keys.chord(...args);
await this._webElement.sendKeys(keys);
}
await this._webElement.sendKeys(chord);
}
/**
@ -186,11 +183,6 @@ export class WebElementWrapper {
* @param {string} name
*/
async getAttribute(name) {
const rectAttributes = ['height', 'width', 'x', 'y'];
if (rectAttributes.includes(name)) {
const rect = await this.getSize();
return rect[name];
}
return await this._webElement.getAttribute(name);
}