Skip to content

Commit

Permalink
[data views] functional tests to typescript (#126977)
Browse files Browse the repository at this point in the history
js => ts
  • Loading branch information
mattkime authored Mar 7, 2022
1 parent 0adb328 commit 8b82657
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Side Public License, v 1.
*/

export default function ({ getService, getPageObjects }) {
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const es = getService('es');
Expand Down Expand Up @@ -38,7 +40,7 @@ export default function ({ getService, getPageObjects }) {
body: { actions: [{ add: { index: 'blogs', alias: 'alias1' } }] },
});

await PageObjects.settings.createIndexPattern('alias1', false);
await PageObjects.settings.createIndexPattern('alias1', null);
});

it('can delete an index pattern', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['settings']);
const es = getService('es');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const es = getService('es');
const retry = getService('retry');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const browser = getService('browser');
Expand Down Expand Up @@ -93,7 +94,6 @@ export default function ({ getService, getPageObjects }) {
expect(response.body.result).to.be('updated');
await PageObjects.settings.controlChangeSave();
await retry.try(async function () {
//await PageObjects.common.sleep(2000);
const message = await PageObjects.common.closeToast();
expect(message).to.contain('Unable');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const PageObjects = getPageObjects(['settings']);
Expand All @@ -23,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
});

beforeEach(async function () {
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.createIndexPattern('logstash-*');
});

afterEach(async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const log = getService('log');
Expand All @@ -23,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
});

beforeEach(async () => {
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.createIndexPattern('logstash-*');
// increase Popularity of geo.coordinates
log.debug('Starting openControlsByName (' + fieldName + ')');
await PageObjects.settings.openControlsByName(fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const PageObjects = getPageObjects(['settings', 'common']);
Expand All @@ -18,7 +19,7 @@ export default function ({ getService, getPageObjects }) {
// delete .kibana index and then wait for Kibana to re-create it
await kibanaServer.uiSettings.replace({});
await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.createIndexPattern('logstash-*');
});

after(async function () {
Expand All @@ -30,7 +31,7 @@ export default function ({ getService, getPageObjects }) {
heading: 'Name',
first: '@message',
last: 'xss.raw',
selector: async function () {
async selector() {
const tableRow = await PageObjects.settings.getTableRow(0, 0);
return await tableRow.getVisibleText();
},
Expand All @@ -39,7 +40,7 @@ export default function ({ getService, getPageObjects }) {
heading: 'Type',
first: '',
last: 'text',
selector: async function () {
async selector() {
const tableRow = await PageObjects.settings.getTableRow(0, 1);
return await tableRow.getVisibleText();
},
Expand All @@ -49,7 +50,6 @@ export default function ({ getService, getPageObjects }) {
columns.forEach(function (col) {
describe('sort by heading - ' + col.heading, function indexPatternCreation() {
it('should sort ascending', async function () {
console.log('col.heading', col.heading);
if (col.heading !== 'Name') {
await PageObjects.settings.sortBy(col.heading);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const browser = getService('browser');
const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'timePicker', 'header']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import expect from '@kbn/expect';
import path from 'path';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects']);

//in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization
//that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238)
// in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization
// that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238)

describe('mgmt saved objects', function describeIndexTests() {
before(async () => {
Expand All @@ -41,7 +42,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.savedObjects.waitTableIsLoaded();
await PageObjects.savedObjects.searchForObject('mysaved');

//instead of asserting on count- am asserting on the titles- which is more accurate than count.
// instead of asserting on count- am asserting on the titles- which is more accurate than count.
const objects = await PageObjects.savedObjects.getRowTitles();
expect(objects.includes('mysavedsearch')).to.be(true);
expect(objects.includes('mysavedviz')).to.be(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const log = getService('log');
const browser = getService('browser');
Expand Down Expand Up @@ -36,7 +37,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getFieldsTabCount(), 10);
await log.debug('add runtime field');
await PageObjects.settings.addRuntimeField(
fieldName,
Expand All @@ -51,7 +52,9 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.clickSaveField();

await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getFieldsTabCount())).to.be(startingCount + 1);
expect(parseInt(await PageObjects.settings.getFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
// it will automatically insert a a closing square brace ], etc.

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const log = getService('log');
const browser = getService('browser');
Expand Down Expand Up @@ -77,7 +78,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
const script = `1`;
Expand All @@ -90,7 +91,7 @@ export default function ({ getService, getPageObjects }) {
script
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
Expand All @@ -111,7 +112,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
const script = `if (doc['machine.ram'].size() == 0) return -1;
Expand All @@ -126,7 +127,7 @@ export default function ({ getService, getPageObjects }) {
script
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
Expand All @@ -150,7 +151,7 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort numeric scripted field
// add a test to sort numeric scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
// after the first click on the scripted field, it becomes secondary sort after time.
Expand Down Expand Up @@ -201,7 +202,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
Expand All @@ -213,7 +214,7 @@ export default function ({ getService, getPageObjects }) {
"if (doc['response.raw'].value == '200') { return 'good'} else { return 'bad'}"
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
Expand All @@ -237,7 +238,7 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort string scripted field
// add a test to sort string scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
Expand Down Expand Up @@ -287,7 +288,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
Expand All @@ -299,7 +300,7 @@ export default function ({ getService, getPageObjects }) {
"doc['response.raw'].value == '200'"
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
Expand Down Expand Up @@ -335,8 +336,8 @@ export default function ({ getService, getPageObjects }) {
await filterBar.removeAllFilters();
});

//add a test to sort boolean
//existing bug: https://github.com/elastic/kibana/issues/75519 hence the issue is skipped.
// add a test to sort boolean
// existing bug: https://github.com/elastic/kibana/issues/75519 hence the issue is skipped.
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
Expand Down Expand Up @@ -374,7 +375,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
Expand All @@ -386,7 +387,7 @@ export default function ({ getService, getPageObjects }) {
"doc['utc_time'].value.toEpochMilli() + (1000) * 60 * 60"
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10)).to.be(
startingCount + 1
);
});
Expand All @@ -410,8 +411,8 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort date scripted field
//https://github.com/elastic/kibana/issues/75711
// add a test to sort date scripted field
// https://github.com/elastic/kibana/issues/75711
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const log = getService('log');
Expand Down
Loading

0 comments on commit 8b82657

Please sign in to comment.