[data views] functional tests to typescript (#126977)

js => ts
This commit is contained in:
Matthew Kime 2022-03-07 07:24:39 -06:00 committed by GitHub
parent 0adb328a9a
commit 8b82657d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 65 additions and 50 deletions

View file

@ -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');
@ -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 () => {

View file

@ -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');

View file

@ -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');

View file

@ -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');
@ -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');
});

View file

@ -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']);
@ -23,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
});
beforeEach(async function () {
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.createIndexPattern('logstash-*');
});
afterEach(async function () {

View file

@ -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');
@ -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);

View file

@ -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']);
@ -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 () {
@ -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();
},
@ -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();
},
@ -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);
}

View file

@ -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']);

View file

@ -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 () => {
@ -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);

View file

@ -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');
@ -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,
@ -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
);
});
});

View file

@ -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');
@ -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`;
@ -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
);
});
@ -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;
@ -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
);
});
@ -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.
@ -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(
@ -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
);
});
@ -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.
@ -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(
@ -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
);
});
@ -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.
@ -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(
@ -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
);
});
@ -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.

View file

@ -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');

View file

@ -7,13 +7,14 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const PageObjects = getPageObjects(['settings']);
const SCRIPTED_FIELD_NAME = 'myScriptedField';
const scriptResultToJson = (scriptResult) => {
const scriptResultToJson = (scriptResult: string) => {
try {
return JSON.parse(scriptResult);
} catch (e) {
@ -26,7 +27,7 @@ export default function ({ getService, getPageObjects }) {
await browser.setWindowSize(1200, 800);
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.createIndexPattern('logstash-*');
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
@ -67,7 +68,7 @@ export default function ({ getService, getPageObjects }) {
it('should display additional fields', async function () {
const scriptResults = await PageObjects.settings.executeScriptedField(
`doc['bytes'].value * 2`,
['bytes']
'bytes'
);
const [{ _id, bytes }] = scriptResultToJson(scriptResults);
expect(_id).to.be.a('string');

View file

@ -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 security = getService('security');
const PageObjects = getPageObjects(['common', 'home', 'settings']);
@ -19,7 +20,7 @@ export default function ({ getService, getPageObjects }) {
const EXPECTED_FIELD_COUNT = '10006';
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'test_testhuge_reader'], false);
await security.testUser.setRoles(['kibana_admin', 'test_testhuge_reader']);
await esArchiver.emptyKibanaIndex();
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/large_fields');
await PageObjects.settings.navigateTo();

View file

@ -563,7 +563,7 @@ export class SettingsPageObject extends FtrService {
name: string,
language: string,
type: string,
format: Record<string, any>,
format: Record<string, any> | null,
popularity: string,
script: string
) {
@ -803,7 +803,7 @@ export class SettingsPageObject extends FtrService {
await this.flyout.ensureClosed('scriptedFieldsHelpFlyout');
}
async executeScriptedField(script: string, additionalField: string) {
async executeScriptedField(script: string, additionalField?: string) {
this.log.debug('execute Scripted Fields help');
await this.closeScriptedFieldHelp(); // ensure script help is closed so script input is not blocked
await this.setScriptedFieldScript(script);
@ -814,7 +814,7 @@ export class SettingsPageObject extends FtrService {
await this.testSubjects.click('runScriptButton');
await this.testSubjects.waitForDeleted('.euiLoadingSpinner');
}
let scriptResults;
let scriptResults: string = '';
await this.retry.try(async () => {
scriptResults = await this.testSubjects.getVisibleText('scriptedFieldPreview');
});