adjust tests to pass on Firefox (#35597)

* adjust tests to pass on Firefox

* update feature controls tests to pass on Firefox

* use xpath to search for index pattern
This commit is contained in:
Dmitry Lemeshko 2019-05-03 20:12:15 +02:00 committed by GitHub
parent 2df3880ac7
commit f5bbe82023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 40 additions and 46 deletions

View file

@ -44,10 +44,11 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.clickNewSearch();
await PageObjects.visualize.saveVisualizationExpectSuccess('visualization from add new link');
return retry.try(async () => {
await retry.try(async () => {
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(originalPanelCount + 1);
});
await PageObjects.dashboard.waitForRenderComplete();
});
it('saves the saved visualization url to the app link', async () => {

View file

@ -76,12 +76,9 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.clickClone();
await PageObjects.dashboard.confirmClone();
await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true });
await PageObjects.dashboard.confirmClone();
// This is important since saving a new dashboard will cause a refresh of the page. We have to
// wait till it finishes reloading or it might reload the url after simulating the
// dashboard landing page click.
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
const countOfDashboards =
await PageObjects.dashboard.getDashboardCountWithName(dashboardName + ' Copy');

View file

@ -361,7 +361,11 @@ export function CommonPageProvider({ getService, getPageObjects }) {
}
async getBodyText() {
const el = await find.byCssSelector('body>pre');
if (await find.existsByCssSelector('a[id=rawdata-tab]')) {
// Firefox has 3 tabs and requires navigation to see Raw output
await find.clickByCssSelector('a[id=rawdata-tab]');
}
const el = await find.byCssSelector('body pre');
return await el.getVisibleText();
}
}

View file

@ -281,7 +281,8 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
}
async clickIndexPatternLogstash() {
await find.clickByPartialLinkText('logstash-*');
const indexLink = await find.byXPath(`//a[descendant::*[text()='logstash-*']]`);
await indexLink.click();
}
async createIndexPattern(indexPatternName, timefield = '@timestamp') {

View file

@ -385,13 +385,12 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
}
async getGaugeValue() {
const elements = await find.allByCssSelector('[data-test-subj="visualizationLoader"] .chart svg');
const elements = await find.allByCssSelector('[data-test-subj="visualizationLoader"] .chart svg text');
const values = await Promise.all(elements.map(async element => {
const text = await element.getVisibleText();
return text.split('\n');
return text;
}));
// .flat() replacement
return values.reduce((acc, val) => [...acc, ...val], []);
return values.filter(item => item.length > 0);
}
async clickMetricEditor() {
@ -678,10 +677,10 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
const lastRow = await table.findByCssSelector('tr:last-child');
const fromCell = await lastRow.findByCssSelector('td:first-child input');
await fromCell.clearValue();
await fromCell.type(`${from}`);
await fromCell.type(`${from}`, { charByChar: true });
const toCell = await lastRow.findByCssSelector('td:nth-child(2) input');
await toCell.clearValue();
await toCell.type(`${to}`);
await toCell.type(`${to}`, { charByChar: true });
}
async clickYAxisOptions(axisId) {

View file

@ -67,6 +67,14 @@ export async function FindProvider({ getService }: FtrProviderContext) {
return wrap(await driver.wait(until.elementLocated(By.css(selector)), timeout));
}
public async byXPath(
selector: string,
timeout: number = defaultFindTimeout
): Promise<WebElementWrapper> {
log.debug(`Find.byXPath('${selector}') with timeout=${timeout}`);
return wrap(await driver.wait(until.elementLocated(By.xpath(selector)), timeout));
}
public async byClassName(
selector: string,
timeout: number = defaultFindTimeout

View file

@ -93,7 +93,7 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
log.debug(`TestSubjects.doubleClick(${selector})`);
const element = await this.find(selector, timeout);
await element.moveMouseTo();
await browser.doubleClick();
await browser.doubleClick(element);
});
}

View file

@ -11,7 +11,6 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const esArchiver = getService('esArchiver');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'canvas', 'security', 'spaceSelector']);
const find = getService('find');
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');
@ -222,15 +221,12 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
await security.user.delete('no_canvas_privileges_user');
});
const getMessageText = async () =>
await (await find.byCssSelector('body>pre')).getVisibleText();
it(`returns a 404`, async () => {
await PageObjects.common.navigateToActualUrl('canvas', '', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,
@ -245,7 +241,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -12,7 +12,6 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const esArchiver = getService('esArchiver');
const spacesService: SpacesService = getService('spaces');
const PageObjects = getPageObjects(['common', 'canvas', 'security', 'spaceSelector']);
const find = getService('find');
const appsMenu = getService('appsMenu');
describe('spaces feature controls', () => {
@ -80,9 +79,6 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
});
describe('space with Canvas disabled', () => {
const getMessageText = async () =>
await (await find.byCssSelector('body>pre')).getVisibleText();
before(async () => {
// we need to load the following in every situation as deleting
// a space deletes all of the associated saved objects
@ -116,7 +112,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,
@ -136,7 +132,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
shouldLoginIfPrompted: false,
}
);
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -13,11 +13,8 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const PageObjects = getPageObjects(['common', 'settings', 'security', 'maps']);
const appsMenu = getService('appsMenu');
const testSubjects = getService('testSubjects');
const find = getService('find');
const globalNav = getService('globalNav');
const getMessageText = async () => await (await find.byCssSelector('body>pre')).getVisibleText();
describe('security feature controls', () => {
before(async () => {
await esArchiver.loadIfNeeded('maps/data');
@ -207,7 +204,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -13,9 +13,6 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const spacesService: SpacesService = getService('spaces');
const PageObjects = getPageObjects(['common', 'maps', 'security']);
const appsMenu = getService('appsMenu');
const find = getService('find');
const getMessageText = async () => await (await find.byCssSelector('body>pre')).getVisibleText();
describe('spaces feature controls', () => {
before(async () => {
@ -90,7 +87,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -11,7 +11,6 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const esArchiver = getService('esArchiver');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'timelion', 'header', 'security', 'spaceSelector']);
const find = getService('find');
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');
@ -170,15 +169,12 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
await security.user.delete('no_timelion_privileges_user');
});
const getMessageText = async () =>
await (await find.byCssSelector('body>pre')).getVisibleText();
it(`returns a 404`, async () => {
await PageObjects.common.navigateToActualUrl('timelion', '', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -12,11 +12,8 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const esArchiver = getService('esArchiver');
const spacesService: SpacesService = getService('spaces');
const PageObjects = getPageObjects(['common', 'timelion', 'security', 'spaceSelector']);
const find = getService('find');
const appsMenu = getService('appsMenu');
const getMessageText = async () => await (await find.byCssSelector('body>pre')).getVisibleText();
describe('timelion', () => {
before(async () => {
await esArchiver.loadIfNeeded('logstash_functional');
@ -89,7 +86,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,
@ -106,7 +103,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,
@ -123,7 +120,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
shouldLoginIfPrompted: false,
});
const messageText = await getMessageText();
const messageText = await PageObjects.common.getBodyText();
expect(messageText).to.eql(
JSON.stringify({
statusCode: 404,

View file

@ -28,6 +28,7 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
const expectSpaceSelector = options.expectSpaceSelector || false;
const expectSuccess = options.expectSuccess;
const expectForbidden = options.expectForbidden || false;
const rawDataTabLocator = 'a[id=rawdata-tab]';
await PageObjects.common.navigateToApp('login');
await testSubjects.setValue('loginUsername', username);
@ -39,6 +40,10 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
await retry.try(() => testSubjects.find('kibanaSpaceSelector'));
log.debug(`Finished login process, landed on space selector. currentUrl = ${await browser.getCurrentUrl()}`);
} else if (expectForbidden) {
if (await find.existsByCssSelector(rawDataTabLocator)) {
// Firefox has 3 tabs and requires navigation to see Raw output
await find.clickByCssSelector(rawDataTabLocator);
}
await retry.try(async () => {
await PageObjects.error.expectForbidden();
});