Skip to content

Commit

Permalink
[ftr] wrap remote in browser service (elastic#26394)
Browse files Browse the repository at this point in the history
* [pageObjects/common] remove unused runScript method

* [pageObjects/common] remove almost unused doesCssSelectorExist method

* [pageObjects/graph] convert to use find/testSubjects services

* [pageObjects/discover] refactor out remote service

* [pageObjects/pointSeries] refactor out remote service

* [pageObjects/monitoring] refactor out remote service

* [ftr] refactor uses of remote to use browser or find

* [ftr/services/remote] wrap remote with browser service

* [pageObjects/security] refactor out uses of remote

* [ftr/services/browser] isolate element calls to find

* [ftr] rename remote service to __leadfoot__

* [ftr/leadfoot] cleanup some renames in find, keep names in other tests
  • Loading branch information
Spencer committed Nov 29, 2018
1 parent d46eaf9 commit 50be0d8
Show file tree
Hide file tree
Showing 76 changed files with 753 additions and 731 deletions.
4 changes: 2 additions & 2 deletions test/functional/apps/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

export default function ({ getService, loadTestFile }) {
const remote = getService('remote');
const browser = getService('browser');

describe('console app', function () {
this.tags('ciGroup1');

before(async function () {
await remote.setWindowSize(1300, 1100);
await browser.setWindowSize(1300, 1100);
});

loadTestFile(require.resolve('./_console'));
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

export default function ({ getService, getPageObjects, loadTestFile }) {
const remote = getService('remote');
const browser = getService('browser');
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common']);
const kibanaServer = getService('kibanaServer');
Expand All @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects, loadTestFile }) {
this.tags('ciGroup1');

before(async function () {
await remote.setWindowSize(1200, 800);
await browser.setWindowSize(1200, 800);
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.load('visualize');
await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC', 'defaultIndex': 'logstash-*',
Expand Down
10 changes: 5 additions & 5 deletions test/functional/apps/dashboard/_bwc_shared_urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import expect from 'expect.js';
export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'header']);
const dashboardExpect = getService('dashboardExpect');
const remote = getService('remote');
const browser = getService('browser');
const log = getService('log');
const queryBar = getService('queryBar');

Expand Down Expand Up @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }) {
before(async function () {
await PageObjects.dashboard.initTests();

const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#'));
});

Expand All @@ -61,7 +61,7 @@ export default function ({ getService, getPageObjects }) {
it('loads an unsaved dashboard', async function () {
const url = `${kibanaBaseUrl}#/dashboard?${urlQuery}`;
log.debug(`Navigating to ${url}`);
await remote.get(url, true);
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();

const query = await queryBar.getQueryString();
Expand All @@ -77,7 +77,7 @@ export default function ({ getService, getPageObjects }) {

const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl();
const url = `${kibanaBaseUrl}#/dashboard/${id}`;
await remote.get(url, true);
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();

const query = await queryBar.getQueryString();
Expand All @@ -93,7 +93,7 @@ export default function ({ getService, getPageObjects }) {
const updatedQuery = urlQuery.replace(/F9D9F9/g, '000000');
const url = `${kibanaBaseUrl}#/dashboard/${id}?${updatedQuery}`;

await remote.get(url, true);
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();

await dashboardExpect.selectedLegendColorCount('#000000', 5);
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/_create_and_add_embeddables.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']);
const remote = getService('remote');
const browser = getService('browser');
const dashboardAddPanel = getService('dashboardAddPanel');

describe('create and add embeddables', async () => {
Expand All @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }) {

it('saves the saved visualization url to the app link', async () => {
await PageObjects.header.clickVisualize();
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
expect(currentUrl).to.contain(VisualizeConstants.EDIT_PATH);
});

Expand Down
11 changes: 5 additions & 6 deletions test/functional/apps/dashboard/_dashboard_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const remote = getService('remote');
const browser = getService('browser');
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard']);

Expand All @@ -38,11 +38,10 @@ export default function ({ getService, getPageObjects }) {
const panelTitleBeforeMove = await dashboardPanelActions.getPanelHeading(lastVisTitle);
const position1 = await panelTitleBeforeMove.getPosition();

remote
.moveMouseTo(panelTitleBeforeMove)
.pressMouseButton()
.moveMouseTo(null, -20, -450)
.releaseMouseButton();
await browser.moveMouseTo(panelTitleBeforeMove);
await browser.pressMouseButton();
await browser.moveMouseTo(null, -20, -450);
await browser.releaseMouseButton();

const panelTitleAfterMove = await dashboardPanelActions.getPanelHeading(lastVisTitle);
const position2 = await panelTitleAfterMove.getPosition();
Expand Down
22 changes: 11 additions & 11 deletions test/functional/apps/dashboard/_dashboard_listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'header', 'common']);
const remote = getService('remote');
const browser = getService('browser');

describe('dashboard listing page', function describeIndexTests() {
const dashboardName = 'Dashboard Listing Test';
Expand Down Expand Up @@ -126,35 +126,35 @@ export default function ({ getService, getPageObjects }) {

describe('search by title', function () {
it('loads a dashboard if title matches', async function () {
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&title=Two%20Words';
// Only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage();
expect(onDashboardLandingPage).to.equal(false);
});

it('title match is case insensitive', async function () {
await PageObjects.dashboard.gotoDashboardLandingPage();
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&title=two%20words';
// Only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage();
expect(onDashboardLandingPage).to.equal(false);
});

it('stays on listing page if title matches no dashboards', async function () {
await PageObjects.dashboard.gotoDashboardLandingPage();
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&title=nodashboardsnamedme';
// Only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

await PageObjects.header.waitUntilLoadingHasFinished();
const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage();
Expand All @@ -170,11 +170,11 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.saveDashboard('two words', { needsConfirm: true });
await PageObjects.dashboard.gotoDashboardLandingPage();
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&title=two%20words';
// Only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

await PageObjects.header.waitUntilLoadingHasFinished();
const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage();
Expand All @@ -190,12 +190,12 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.saveDashboard('i am !@#$%^&*()_+~`,.<>{}[]; so special');
await PageObjects.dashboard.gotoDashboardLandingPage();
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
// Need to encode that one.
const newUrl = currentUrl + '&title=i%20am%20%21%40%23%24%25%5E%26%2A%28%29_%2B~%60%2C.%3C%3E%7B%7D%5B%5D%3B%20so%20special';
// Only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

await PageObjects.header.waitUntilLoadingHasFinished();
const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage();
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/_dashboard_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ import expect from 'expect.js';
export default function ({ getService, getPageObjects, updateBaselines }) {
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'common']);
const screenshot = getService('screenshots');
const remote = getService('remote');
const browser = getService('browser');
const dashboardPanelActions = getService('dashboardPanelActions');
const dashboardAddPanel = getService('dashboardAddPanel');

describe('dashboard snapshots', function describeIndexTests() {
before(async function () {
// We use a really small window to minimize differences across os's and browsers.
await remote.setWindowSize(1000, 500);
await browser.setWindowSize(1000, 500);
});

after(async function () {
await remote.setWindowSize(1300, 900);
await browser.setWindowSize(1300, 900);
const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl();
await PageObjects.dashboard.deleteDashboard('area', id);
});
Expand Down
22 changes: 11 additions & 11 deletions test/functional/apps/dashboard/_dashboard_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'visualize', 'header', 'discover']);
const testSubjects = getService('testSubjects');
const remote = getService('remote');
const browser = getService('browser');
const queryBar = getService('queryBar');
const retry = getService('retry');
const dashboardPanelActions = getService('dashboardPanelActions');
Expand Down Expand Up @@ -166,21 +166,21 @@ export default function ({ getService, getPageObjects }) {

const currentQuery = await queryBar.getQueryString();
expect(currentQuery).to.equal('');
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace('query:%27%27', 'query:%27hi%27');
// Don't add the timestamp to the url or it will cause a hard refresh and we want to test a
// soft refresh.
await remote.get(newUrl.toString(), false);
await browser.get(newUrl.toString(), false);
const newQuery = await queryBar.getQueryString();
expect(newQuery).to.equal('hi');
});

it('for panel size parameters', async function () {
await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME);
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const currentPanelDimensions = await PageObjects.dashboard.getPanelDimensions();
const newUrl = currentUrl.replace(`w:${DEFAULT_PANEL_WIDTH}`, `w:${DEFAULT_PANEL_WIDTH * 2}`);
await remote.get(newUrl.toString(), false);
await browser.get(newUrl.toString(), false);
await retry.try(async () => {
const newPanelDimensions = await PageObjects.dashboard.getPanelDimensions();
if (newPanelDimensions.length < 0) {
Expand All @@ -196,9 +196,9 @@ export default function ({ getService, getPageObjects }) {
});

it('when removing a panel', async function () {
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace(/panels:\!\(.*\),query/, 'panels:!(),query');
await remote.get(newUrl.toString(), false);
await browser.get(newUrl.toString(), false);

await retry.try(async () => {
const newPanelCount = await PageObjects.dashboard.getPanelCount();
Expand All @@ -211,9 +211,9 @@ export default function ({ getService, getPageObjects }) {
await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME);
await PageObjects.visualize.openLegendOptionColors('80,000');
await PageObjects.visualize.selectNewLegendColorChoice('#F9D9F9');
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace('F9D9F9', 'FFFFFF');
await remote.get(newUrl.toString(), false);
await browser.get(newUrl.toString(), false);
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async () => {
Expand All @@ -238,9 +238,9 @@ export default function ({ getService, getPageObjects }) {
});

it('resets a pie slice color to the original when removed', async function () {
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace('vis:(colors:(%2780,000%27:%23FFFFFF))', '');
await remote.get(newUrl.toString(), false);
await browser.get(newUrl.toString(), false);
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/_dashboard_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const toTime = '2015-09-23 18:31:44.000';

export default function ({ getPageObjects, getService }) {
const PageObjects = getPageObjects(['dashboard', 'header']);
const remote = getService('remote');
const browser = getService('browser');

describe('dashboard time', () => {
before(async function () {
Expand Down Expand Up @@ -94,14 +94,14 @@ export default function ({ getPageObjects, getService }) {
// However, if the URL also contains time in the global state, then the global state
// time should take precedence.
it('should be overwritten by global state', async function () {
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#'));
const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl();

await PageObjects.dashboard.gotoDashboardLandingPage();

const urlWithGlobalTime = `${kibanaBaseUrl}#/dashboard/${id}?_g=(time:(from:now-1h,mode:quick,to:now))`;
await remote.get(urlWithGlobalTime, false);
await browser.get(urlWithGlobalTime, false);
const prettyPrint = await PageObjects.header.getPrettyDuration();
expect(prettyPrint).to.equal('Last 1 hour');
});
Expand Down
12 changes: 6 additions & 6 deletions test/functional/apps/dashboard/_embed_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import expect from 'expect.js';
export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const PageObjects = getPageObjects(['dashboard', 'common']);
const remote = getService('remote');
const browser = getService('browser');

describe('embed mode', async () => {
before(async () => {
Expand All @@ -33,11 +33,11 @@ export default function ({ getService, getPageObjects }) {
let isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);

const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&embed=true';
// Embed parameter only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);

await retry.try(async () => {
isChromeVisible = await PageObjects.common.isChromeVisible();
Expand All @@ -46,14 +46,14 @@ export default function ({ getService, getPageObjects }) {
});

after(async function () {
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace('&embed=true', '');
// First use the timestamp to cause a hard refresh so the new embed parameter works correctly.
let useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);
// Then get rid of the timestamp so the rest of the tests work with state and app switching.
useTimeStamp = false;
await remote.get(newUrl.toString(), useTimeStamp);
await browser.get(newUrl.toString(), useTimeStamp);
});
});
}
Expand Down
10 changes: 5 additions & 5 deletions test/functional/apps/dashboard/_embeddable_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const find = getService('find');
const remote = getService('remote');
const browser = getService('browser');
const dashboardExpect = getService('dashboardExpect');
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'discover']);
Expand Down Expand Up @@ -91,9 +91,9 @@ export default function ({ getService, getPageObjects }) {

after(async () => {
// Get rid of the timestamp added in this test, as well any global or app state.
const currentUrl = await remote.getCurrentUrl();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl.replace(/\?.*$/, '');
await remote.get(newUrl, false);
await browser.get(newUrl, false);
});

it('adding visualizations', async () => {
Expand Down Expand Up @@ -132,8 +132,8 @@ export default function ({ getService, getPageObjects }) {
});

it('data rendered correctly when dashboard is hard refreshed', async () => {
const currentUrl = await remote.getCurrentUrl();
await remote.get(currentUrl, true);
const currentUrl = await browser.getCurrentUrl();
await browser.get(currentUrl, true);

await expectAllDataRenders();
});
Expand Down
Loading

0 comments on commit 50be0d8

Please sign in to comment.