Skip to content

Commit

Permalink
Restore webdriver-based functional test runner driver (elastic#31446)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer authored and dmlemeshko committed Mar 6, 2019
1 parent 96197f7 commit dd10494
Show file tree
Hide file tree
Showing 38 changed files with 1,133 additions and 1,065 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module.exports = {
*/
{
files: [
'test/functional/services/lib/leadfoot_element_wrapper/scroll_into_view_if_necessary.js',
'test/functional/services/lib/web_element_wrapper/scroll_into_view_if_necessary.js',
'**/browser_exec_scripts/**/*',
],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@
"karma-junit-reporter": "1.2.0",
"karma-mocha": "1.3.0",
"karma-safari-launcher": "1.0.0",
"leadfoot": "1.7.5",
"license-checker": "^16.0.0",
"listr": "^0.14.1",
"load-grunt-config": "0.19.2",
Expand All @@ -394,6 +393,7 @@
"proxyquire": "1.7.11",
"regenerate": "^1.4.0",
"sass-lint": "^1.12.1",
"selenium-webdriver": "^4.0.0-alpha.1",
"simple-git": "1.37.0",
"sinon": "^5.0.7",
"strip-ansi": "^3.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
'<rootDir>/src/setup_node_env',
'<rootDir>/packages',
'<rootDir>/src/test_utils',
'<rootDir>/test/functional/services/remote',
],
collectCoverageFrom: [
'packages/kbn-ui-framework/src/components/**/*.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ProviderCollection {
instance = createAsyncInstance(type, name, instance);
}

if (name !== '__leadfoot__' && name !== 'log' && name !== 'config' && instance && typeof instance === 'object') {
if (name !== '__webdriver__' && name !== 'log' && name !== 'config' && instance && typeof instance === 'object') {
instance = createVerboseInstance(
this._log,
type === 'PageObject' ? `PageObjects.${name}` : name,
Expand Down
5 changes: 2 additions & 3 deletions test/functional/apps/dashboard/_dashboard_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export default function ({ getService, getPageObjects }) {
const lastVisTitle = 'Rendering Test: datatable';
const panelTitleBeforeMove = await dashboardPanelActions.getPanelHeading(lastVisTitle);
const position1 = await panelTitleBeforeMove.getPosition();

await browser.dragAndDrop(
{ element: panelTitleBeforeMove },
{ element: null, xOffset: -20, yOffset: -450 }
{ location: panelTitleBeforeMove },
{ location: { x: -20, y: -450 } }
);

const panelTitleAfterMove = await dashboardPanelActions.getPanelHeading(lastVisTitle);
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/_dashboard_save.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ({ getPageObjects }) {

await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName);
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName, { waitDialogIsClosed: false });
await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true });
});

Expand All @@ -55,7 +55,7 @@ export default function ({ getPageObjects }) {
it('Saves on confirm duplicate title warning', async function () {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName);
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName, { waitDialogIsClosed: false });

await PageObjects.dashboard.clickSave();

Expand Down Expand Up @@ -96,7 +96,7 @@ export default function ({ getPageObjects }) {

it('Warns when case is different', async function () {
await PageObjects.dashboard.switchToEditMode();
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName.toUpperCase());
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName.toUpperCase(), { waitDialogIsClosed: false });

await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true });

Expand Down
14 changes: 8 additions & 6 deletions test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
* verify that the save was successful
*
* @param dashName {String}
* @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, needsConfirm: false}}
* @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, needsConfirm: false, waitDialogIsClosed: boolean }}
*/
async saveDashboard(dashName, saveOptions = {}) {
async saveDashboard(dashName, saveOptions = { waitDialogIsClosed: true }) {
await this.enterDashboardTitleAndClickSave(dashName, saveOptions);

if (saveOptions.needsConfirm) {
Expand Down Expand Up @@ -352,12 +352,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
/**
*
* @param dashboardTitle {String}
* @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean}}
* @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, waitDialogIsClosed: boolean}}
*/
async enterDashboardTitleAndClickSave(dashboardTitle, saveOptions = {}) {
async enterDashboardTitleAndClickSave(dashboardTitle, saveOptions = { waitDialogIsClosed: true }) {
await testSubjects.click('dashboardSaveMenuItem');

await PageObjects.header.waitUntilLoadingHasFinished();
const modalDialog = await testSubjects.find('savedObjectSaveModal');

log.debug('entering new title');
await testSubjects.setValue('savedObjectTitle', dashboardTitle);
Expand All @@ -371,6 +370,9 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
}

await this.clickSave();
if (saveOptions.waitDialogIsClosed) {
await testSubjects.waitForDeleted(modalDialog);
}
}

async selectDashboard(dashName) {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/page_objects/discover_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
async brushHistogram(from, to) {
const bars = await find.allByCssSelector('.series.histogram rect');
await browser.dragAndDrop(
{ element: bars[from], xOffset: 0, yOffset: -5 },
{ element: bars[to], xOffset: 0, yOffset: -5 }
{ location: bars[from], offset: { x: 0, y: -5 } },
{ location: bars[to], offset: { x: 0, y: -5 } }
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
log.debug(`setIndexPatternField(${indexPatternName})`);
const field = await this.getIndexPatternField();
await field.clearValue();
await field.type(indexPatternName);
await field.type(indexPatternName, { charByChar: true });
const currentName = await field.getAttribute('value');
log.debug(`setIndexPatternField set to ${currentName}`);
expect(currentName).to.eql(`${indexPatternName}${expectWildcard ? '*' : ''}`);
Expand Down
6 changes: 4 additions & 2 deletions test/functional/page_objects/share_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

export function SharePageProvider({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['visualize', 'common']);
const log = getService('log');

Expand All @@ -43,8 +44,9 @@ export function SharePageProvider({ getService, getPageObjects }) {
// and then re-open the menu
await this.clickShareTopNavButton();
}

return testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
const menuPanel = await find.byCssSelector('div.euiContextMenuPanel');
testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
await testSubjects.waitForDeleted(menuPanel);
}

async getSharedUrl() {
Expand Down
14 changes: 14 additions & 0 deletions test/functional/page_objects/time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
return dateString.substring(0, 23);
}

async getTimePickerPanel() {
return await find.byCssSelector('div.euiPopover__panel-isOpen');
}

async waitPanelIsGone(panelElement) {
await find.waitForElementStale(panelElement);
}

/**
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
Expand All @@ -49,11 +57,14 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {

// set to time
await testSubjects.click('superDatePickerendDatePopoverButton');
let panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', toTime);

// set from time
await testSubjects.click('superDatePickerstartDatePopoverButton');
await this.waitPanelIsGone(panel);
panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', fromTime);

Expand All @@ -68,6 +79,7 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await testSubjects.click('querySubmitButton');
}

await this.waitPanelIsGone(panel);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

Expand Down Expand Up @@ -145,11 +157,13 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {

// get to time
await testSubjects.click('superDatePickerendDatePopoverButton');
const panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
const end = await testSubjects.getAttribute('superDatePickerAbsoluteDateInput', 'value');

// get from time
await testSubjects.click('superDatePickerstartDatePopoverButton');
await this.waitPanelIsGone(panel);
await testSubjects.click('superDatePickerAbsoluteTab');
const start = await testSubjects.getAttribute('superDatePickerAbsoluteDateInput', 'value');

Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
await input.pressKeys([browser.keys.CONTROL, 'a']); // Select all for everything else
}
await input.pressKeys(browser.keys.NULL); // Release modifier keys
await input.pressKeys(browser.keys.BACKSPACE); // Delete all content
await input.pressKeys(browser.keys.BACK_SPACE); // Delete all content
}

public async getMarkdownText() {
Expand Down
12 changes: 5 additions & 7 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,11 @@ export function VisualizePageProvider({ getService, getPageObjects }) {

async ensureSavePanelOpen() {
log.debug('ensureSavePanelOpen');
let isOpen = await testSubjects.exists('savedObjectSaveModal');
await retry.try(async () => {
while (!isOpen) {
await testSubjects.click('visualizeSaveButton');
isOpen = await testSubjects.exists('savedObjectSaveModal');
}
});
await PageObjects.header.waitUntilLoadingHasFinished();
const isOpen = await testSubjects.exists('savedObjectSaveModal', { timeout: 5000 });
if (!isOpen) {
await testSubjects.click('visualizeSaveButton');
}
}

async saveVisualization(vizName, { saveAsNew = false } = {}) {
Expand Down
Loading

0 comments on commit dd10494

Please sign in to comment.