Skip to content

Commit

Permalink
Add param to cmn/mgmt/data_views/_edit_field.ts and make stateful t…
Browse files Browse the repository at this point in the history
…est match (elastic#194934)

## Summary

Resolves: elastic#194917
  • Loading branch information
wayneseymour authored Oct 7, 2024
1 parent 1ab1add commit 3a3f130
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
29 changes: 8 additions & 21 deletions test/functional/apps/management/data_views/_edit_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

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

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

describe('edit field', function () {
before(async function () {
Expand All @@ -33,29 +30,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should show preview for fields in _source', async function () {
await PageObjects.settings.filterField('extension');
await testSubjects.click('editFieldFormat');
await testSubjects.find('value');
let previewText = '';
await retry.waitForWithTimeout('get preview value', 1000, async () => {
previewText = await testSubjects.getVisibleText('value');
return previewText !== 'Value not set';
await PageObjects.settings.changeAndValidateFieldFormat({
name: 'extension',
fieldType: 'text',
expectedPreviewText: 'css',
});
expect(previewText).to.be('css');
await PageObjects.settings.closeIndexPatternFieldEditor();
});

it('should show preview for fields not in _source', async function () {
await PageObjects.settings.filterField('extension.raw');
await testSubjects.click('editFieldFormat');
await testSubjects.find('value');
let previewText = '';
await retry.waitForWithTimeout('get preview value', 1000, async () => {
previewText = await testSubjects.getVisibleText('value');
return previewText !== 'Value not set';
await PageObjects.settings.changeAndValidateFieldFormat({
name: 'extension.raw',
fieldType: 'keyword',
expectedPreviewText: 'css',
});
expect(previewText).to.be('css');
await PageObjects.settings.closeIndexPatternFieldEditor();
});
});
});
Expand Down
15 changes: 13 additions & 2 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,15 @@ export class SettingsPageObject extends FtrService {
);
}

async changeAndValidateFieldFormat(name: string, fieldType: string) {
async changeAndValidateFieldFormat({
name,
fieldType,
expectedPreviewText,
}: {
name: string;
fieldType: string;
expectedPreviewText: string;
}) {
await this.filterField(name);
await this.setFieldTypeFilter(fieldType);
await this.testSubjects.click('editFieldFormat');
Expand All @@ -1062,7 +1070,10 @@ export class SettingsPageObject extends FtrService {

await this.retry.tryForTime(5000, async () => {
const previewText = await this.testSubjects.getVisibleText('fieldPreviewItem > value');
expect(previewText).to.be('css');
expect(previewText).to.eql(
expectedPreviewText,
`Expected previewText to eql [${expectedPreviewText}], but got: [${previewText}]`
);
});
await this.closeIndexPatternFieldEditor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should show preview for fields in _source', async function () {
await PageObjects.settings.changeAndValidateFieldFormat('extension', 'text');
await PageObjects.settings.changeAndValidateFieldFormat({
name: 'extension',
fieldType: 'text',
expectedPreviewText: 'css',
});
});

it('should show preview for fields not in _source', async function () {
await PageObjects.settings.changeAndValidateFieldFormat('extension.raw', 'keyword');
await PageObjects.settings.changeAndValidateFieldFormat({
name: 'extension.raw',
fieldType: 'keyword',
expectedPreviewText: 'css',
});
});
});
});
Expand Down

0 comments on commit 3a3f130

Please sign in to comment.