Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ftr] migrate "fieldEditor" to FtrService class #100597

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 37 additions & 41 deletions test/functional/services/field_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,47 @@
* Side Public License, v 1.
*/

import { FtrProviderContext } from '../ftr_provider_context';
import { FtrService } from '../ftr_provider_context';

export function FieldEditorProvider({ getService }: FtrProviderContext) {
const browser = getService('browser');
const testSubjects = getService('testSubjects');
export class FieldEditorService extends FtrService {
private readonly browser = this.ctx.getService('browser');
private readonly testSubjects = this.ctx.getService('testSubjects');

class FieldEditor {
public async setName(name: string) {
await testSubjects.setValue('nameField > input', name);
}
public async enableCustomLabel() {
await testSubjects.setEuiSwitch('customLabelRow > toggle', 'check');
}
public async setCustomLabel(name: string) {
await testSubjects.setValue('customLabelRow > input', name);
}
public async enableValue() {
await testSubjects.setEuiSwitch('valueRow > toggle', 'check');
}
public async disableValue() {
await testSubjects.setEuiSwitch('valueRow > toggle', 'uncheck');
}
public async typeScript(script: string) {
const editor = await (await testSubjects.find('valueRow')).findByClassName(
'react-monaco-editor-container'
);
const textarea = await editor.findByClassName('monaco-mouse-cursor-text');

await textarea.click();
await browser.pressKeys(script);
}
public async save() {
await testSubjects.click('fieldSaveButton');
}
public async setName(name: string) {
await this.testSubjects.setValue('nameField > input', name);
}
public async enableCustomLabel() {
await this.testSubjects.setEuiSwitch('customLabelRow > toggle', 'check');
}
public async setCustomLabel(name: string) {
await this.testSubjects.setValue('customLabelRow > input', name);
}
public async enableValue() {
await this.testSubjects.setEuiSwitch('valueRow > toggle', 'check');
}
public async disableValue() {
await this.testSubjects.setEuiSwitch('valueRow > toggle', 'uncheck');
}
public async typeScript(script: string) {
const editor = await (await this.testSubjects.find('valueRow')).findByClassName(
'react-monaco-editor-container'
);
const textarea = await editor.findByClassName('monaco-mouse-cursor-text');

public async confirmSave() {
await testSubjects.setValue('saveModalConfirmText', 'change');
await testSubjects.click('confirmModalConfirmButton');
}
await textarea.click();
await this.browser.pressKeys(script);
}
public async save() {
await this.testSubjects.click('fieldSaveButton');
}

public async confirmDelete() {
await testSubjects.setValue('deleteModalConfirmText', 'remove');
await testSubjects.click('confirmModalConfirmButton');
}
public async confirmSave() {
await this.testSubjects.setValue('saveModalConfirmText', 'change');
await this.testSubjects.click('confirmModalConfirmButton');
}

return new FieldEditor();
public async confirmDelete() {
await this.testSubjects.setValue('deleteModalConfirmText', 'remove');
await this.testSubjects.click('confirmModalConfirmButton');
}
}
4 changes: 2 additions & 2 deletions test/functional/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { FilterBarProvider } from './filter_bar';
import { FlyoutProvider } from './flyout';
import { GlobalNavProvider } from './global_nav';
import { InspectorProvider } from './inspector';
import { FieldEditorProvider } from './field_editor';
import { FieldEditorService } from './field_editor';
import { ManagementMenuProvider } from './management';
import { QueryBarProvider } from './query_bar';
import { RemoteProvider } from './remote';
Expand Down Expand Up @@ -75,7 +75,7 @@ export const services = {
browser: BrowserProvider,
pieChart: PieChartProvider,
inspector: InspectorProvider,
fieldEditor: FieldEditorProvider,
fieldEditor: FieldEditorService,
vegaDebugInspector: VegaDebugInspectorViewProvider,
appsMenu: AppsMenuProvider,
globalNav: GlobalNavProvider,
Expand Down