diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout.tsx index d3dae0a8c8b63c..77a7ae25ce887b 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout.tsx @@ -77,10 +77,15 @@ export const EditTransformFlyout: FC = ({ closeFlyout, return ( - + -

+

{i18n.translate('xpack.transform.transformList.editFlyoutTitle', { defaultMessage: 'Edit {transformId}', values: { @@ -121,7 +126,12 @@ export const EditTransformFlyout: FC = ({ closeFlyout, - + {i18n.translate('xpack.transform.transformList.editFlyoutUpdateButtonText', { defaultMessage: 'Update', })} diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form.tsx index a9c230870bfca4..5836898755224e 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form.tsx @@ -25,6 +25,7 @@ export const EditTransformFlyoutForm: FC = ({ return ( = ({ value={formFields.description.value} /> = ({ value={formFields.docsPerSecond.value} /> = ({ + dataTestSubj, errorMessages, helpText, label, @@ -33,6 +35,7 @@ export const EditTransformFlyoutFormTextInput: FC 0} value={value} diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap index 5695b8a847496a..da5ad27c9d6b10 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap @@ -10,6 +10,7 @@ exports[`Transform: Transform List Actions Minimal initializati Minimal initializatio Minimal initialization = ({ itemId }) => { const cloneButton = ( = ({ items, forceDisable }) => let deleteButton = ( = ({ config }) => { const editButton = ( = ({ items, forceDisable }) => { let startButton = ( = ({ items, forceDisable }) => { const stopButton = ( { - // await transform.api.deleteIndices(); + await transform.api.deleteIndices(testData.destinationIndex); + await transform.testResources.deleteIndexPatternByTitle(testData.destinationIndex); }); - it('loads the home page', async () => { + it('should load the home page', async () => { await transform.navigation.navigateTo(); await transform.management.assertTransformListPageExists(); }); + + it('should display the transforms table', async () => { + await transform.management.assertTransformsTableExists(); + }); + + it('should display the original transform in the transform list', async () => { + await transform.table.refreshTransformList(); + await transform.table.filterWithSearchString(transformConfig.id); + const rows = await transform.table.parseTransformTable(); + expect(rows.filter((row) => row.id === transformConfig.id)).to.have.length(1); + }); + + it('should show the actions popover', async () => { + await transform.table.assertTransformRowActions(false); + }); + + it('should display the define pivot step', async () => { + await transform.table.clickTransformRowAction('Clone'); + await transform.wizard.assertDefineStepActive(); + }); + + it('should load the index preview', async () => { + await transform.wizard.assertIndexPreviewLoaded(); + }); + + it('should show the index preview', async () => { + await transform.wizard.assertIndexPreview( + testData.expected.indexPreview.columns, + testData.expected.indexPreview.rows + ); + }); + + it('should display the query input', async () => { + await transform.wizard.assertQueryInputExists(); + await transform.wizard.assertQueryValue(''); + }); + + it('should show the pre-filled group-by configuration', async () => { + await transform.wizard.assertGroupByEntryExists( + testData.expected.groupBy.index, + testData.expected.groupBy.label + ); + }); + + it('should show the pre-filled aggs configuration', async () => { + await transform.wizard.assertAggregationEntryExists( + testData.expected.aggs.index, + testData.expected.aggs.label + ); + }); + + it('should show the pivot preview', async () => { + await transform.wizard.assertPivotPreviewChartHistogramButtonMissing(); + await transform.wizard.assertPivotPreviewColumnValues( + testData.expected.pivotPreview.column, + testData.expected.pivotPreview.values + ); + }); + + it('should load the details step', async () => { + await transform.wizard.advanceToDetailsStep(); + }); + + it('should input the transform id', async () => { + await transform.wizard.assertTransformIdInputExists(); + await transform.wizard.assertTransformIdValue(''); + await transform.wizard.setTransformId(testData.transformId); + }); + + it('should input the transform description', async () => { + await transform.wizard.assertTransformDescriptionInputExists(); + await transform.wizard.assertTransformDescriptionValue(''); + await transform.wizard.setTransformDescription(testData.transformDescription); + }); + + it('should input the destination index', async () => { + await transform.wizard.assertDestinationIndexInputExists(); + await transform.wizard.assertDestinationIndexValue(''); + await transform.wizard.setDestinationIndex(testData.destinationIndex); + }); + + it('should display the create index pattern switch', async () => { + await transform.wizard.assertCreateIndexPatternSwitchExists(); + await transform.wizard.assertCreateIndexPatternSwitchCheckState(true); + }); + + it('should display the continuous mode switch', async () => { + await transform.wizard.assertContinuousModeSwitchExists(); + await transform.wizard.assertContinuousModeSwitchCheckState(false); + }); + + it('should load the create step', async () => { + await transform.wizard.advanceToCreateStep(); + }); + + it('should display the create and start button', async () => { + await transform.wizard.assertCreateAndStartButtonExists(); + await transform.wizard.assertCreateAndStartButtonEnabled(true); + }); + + it('should display the create button', async () => { + await transform.wizard.assertCreateButtonExists(); + await transform.wizard.assertCreateButtonEnabled(true); + }); + + it('should display the copy to clipboard button', async () => { + await transform.wizard.assertCopyToClipboardButtonExists(); + await transform.wizard.assertCopyToClipboardButtonEnabled(true); + }); + + it('should create the transform', async () => { + await transform.wizard.createTransform(); + }); + + it('should start the transform and finish processing', async () => { + await transform.wizard.startTransform(); + await transform.wizard.waitForProgressBarComplete(); + }); + + it('should return to the management page', async () => { + await transform.wizard.returnToManagement(); + }); + + it('should display the transforms table', async () => { + await transform.management.assertTransformsTableExists(); + }); + + it('should display the created transform in the transform list', async () => { + await transform.table.refreshTransformList(); + await transform.table.filterWithSearchString(testData.transformId); + const rows = await transform.table.parseTransformTable(); + expect(rows.filter((row) => row.id === testData.transformId)).to.have.length(1); + }); }); } }); diff --git a/x-pack/test/functional/apps/transform/creation_index_pattern.ts b/x-pack/test/functional/apps/transform/creation_index_pattern.ts index bf267c80cdcced..7c9983101f607f 100644 --- a/x-pack/test/functional/apps/transform/creation_index_pattern.ts +++ b/x-pack/test/functional/apps/transform/creation_index_pattern.ts @@ -432,7 +432,7 @@ export default function ({ getService }: FtrProviderContext) { expect(rows.filter((row) => row.id === testData.transformId)).to.have.length(1); }); - it('job creation displays details for the created job in the job list', async () => { + it('transform creation displays details for the created transform in the transform list', async () => { await transform.table.assertTransformRowFields(testData.transformId, { id: testData.transformId, description: testData.transformDescription, diff --git a/x-pack/test/functional/apps/transform/creation_saved_search.ts b/x-pack/test/functional/apps/transform/creation_saved_search.ts index bc4ded49660f45..54cc5b3f629335 100644 --- a/x-pack/test/functional/apps/transform/creation_saved_search.ts +++ b/x-pack/test/functional/apps/transform/creation_saved_search.ts @@ -235,7 +235,7 @@ export default function ({ getService }: FtrProviderContext) { expect(rows.filter((row) => row.id === testData.transformId)).to.have.length(1); }); - it('job creation displays details for the created job in the job list', async () => { + it('transform creation displays details for the created transform in the transform list', async () => { await transform.table.assertTransformRowFields(testData.transformId, { id: testData.transformId, description: testData.transformDescription, diff --git a/x-pack/test/functional/apps/transform/editing.ts b/x-pack/test/functional/apps/transform/editing.ts new file mode 100644 index 00000000000000..44ecca17328a72 --- /dev/null +++ b/x-pack/test/functional/apps/transform/editing.ts @@ -0,0 +1,149 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import expect from '@kbn/expect'; + +import { FtrProviderContext } from '../../ftr_provider_context'; +import { TransformPivotConfig } from '../../../../plugins/transform/public/app/common'; + +function getTransformConfig(): TransformPivotConfig { + const date = Date.now(); + return { + id: `ec_2_${date}`, + source: { index: ['ft_ecommerce'] }, + pivot: { + group_by: { category: { terms: { field: 'category.keyword' } } }, + aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } }, + }, + description: + 'ecommerce batch transform with avg(products.base_price) grouped by terms(category.keyword)', + dest: { index: `user-ec_2_${date}` }, + }; +} + +export default function ({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const transform = getService('transform'); + + describe('editing', function () { + const transformConfig = getTransformConfig(); + + before(async () => { + await esArchiver.loadIfNeeded('ml/ecommerce'); + await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); + await transform.api.createAndRunTransform(transformConfig); + await transform.testResources.setKibanaTimeZoneToUTC(); + + await transform.securityUI.loginAsTransformPowerUser(); + }); + + after(async () => { + await transform.testResources.deleteIndexPatternByTitle(transformConfig.dest.index); + await transform.api.deleteIndices(transformConfig.dest.index); + await transform.api.cleanTransformIndices(); + }); + + const testData = { + suiteTitle: 'edit transform', + transformDescription: 'updated description', + transformDocsPerSecond: '1000', + transformFrequency: '10m', + expected: { + messageText: 'updated transform.', + row: { + status: 'stopped', + mode: 'batch', + progress: '100', + }, + }, + }; + + describe(`${testData.suiteTitle}`, function () { + it('should load the home page', async () => { + await transform.navigation.navigateTo(); + await transform.management.assertTransformListPageExists(); + }); + + it('should display the transforms table', async () => { + await transform.management.assertTransformsTableExists(); + }); + + it('should display the original transform in the transform list', async () => { + await transform.table.refreshTransformList(); + await transform.table.filterWithSearchString(transformConfig.id); + const rows = await transform.table.parseTransformTable(); + expect(rows.filter((row) => row.id === transformConfig.id)).to.have.length(1); + }); + + it('should show the actions popover', async () => { + await transform.table.assertTransformRowActions(false); + }); + + it('should show the edit flyout', async () => { + await transform.table.clickTransformRowAction('Edit'); + await transform.editFlyout.assertTransformEditFlyoutExists(); + }); + + it('should update the transform description', async () => { + await transform.editFlyout.assertTransformEditFlyoutInputExists('Description'); + await transform.editFlyout.assertTransformEditFlyoutInputValue( + 'Description', + transformConfig?.description ?? '' + ); + await transform.editFlyout.setTransformEditFlyoutInputValue( + 'Description', + testData.transformDescription + ); + }); + + it('should update the transform documents per second', async () => { + await transform.editFlyout.assertTransformEditFlyoutInputExists('DocsPerSecond'); + await transform.editFlyout.assertTransformEditFlyoutInputValue('DocsPerSecond', ''); + await transform.editFlyout.setTransformEditFlyoutInputValue( + 'DocsPerSecond', + testData.transformDocsPerSecond + ); + }); + + it('should update the transform frequency', async () => { + await transform.editFlyout.assertTransformEditFlyoutInputExists('Frequency'); + await transform.editFlyout.assertTransformEditFlyoutInputValue('Frequency', ''); + await transform.editFlyout.setTransformEditFlyoutInputValue( + 'Frequency', + testData.transformFrequency + ); + }); + + it('should update the transform', async () => { + await transform.editFlyout.updateTransform(); + }); + + it('should display the transforms table', async () => { + await transform.management.assertTransformsTableExists(); + }); + + it('should display the updated transform in the transform list', async () => { + await transform.table.refreshTransformList(); + await transform.table.filterWithSearchString(transformConfig.id); + const rows = await transform.table.parseTransformTable(); + expect(rows.filter((row) => row.id === transformConfig.id)).to.have.length(1); + }); + + it('should display the updated transform in the transform list row cells', async () => { + await transform.table.assertTransformRowFields(transformConfig.id, { + id: transformConfig.id, + description: testData.transformDescription, + status: testData.expected.row.status, + mode: testData.expected.row.mode, + progress: testData.expected.row.progress, + }); + }); + + it('should display the messages tab and include an update message', async () => { + await transform.table.assertTransformExpandedRowMessages(testData.expected.messageText); + }); + }); + }); +} diff --git a/x-pack/test/functional/apps/transform/index.ts b/x-pack/test/functional/apps/transform/index.ts index a7859be6923d5a..04a751279bf3ca 100644 --- a/x-pack/test/functional/apps/transform/index.ts +++ b/x-pack/test/functional/apps/transform/index.ts @@ -35,5 +35,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./creation_index_pattern')); loadTestFile(require.resolve('./creation_saved_search')); loadTestFile(require.resolve('./cloning')); + loadTestFile(require.resolve('./editing')); }); } diff --git a/x-pack/test/functional/services/transform/edit_flyout.ts b/x-pack/test/functional/services/transform/edit_flyout.ts new file mode 100644 index 00000000000000..f9504deb39f6a5 --- /dev/null +++ b/x-pack/test/functional/services/transform/edit_flyout.ts @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import expect from '@kbn/expect'; + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export function TransformEditFlyoutProvider({ getService }: FtrProviderContext) { + const retry = getService('retry'); + const testSubjects = getService('testSubjects'); + + return { + async assertTransformEditFlyoutExists() { + await testSubjects.existOrFail('transformEditFlyout'); + }, + + async assertTransformEditFlyoutMissing() { + await testSubjects.missingOrFail('transformEditFlyout'); + }, + + async assertTransformEditFlyoutInputExists(input: string) { + await testSubjects.existOrFail(`transformEditFlyout${input}Input`); + }, + + async assertTransformEditFlyoutInputValue(input: string, expectedValue: string) { + const actualValue = await testSubjects.getAttribute( + `transformEditFlyout${input}Input`, + 'value' + ); + expect(actualValue).to.eql( + expectedValue, + `Transform edit flyout '${input}' input text should be '${expectedValue}' (got '${actualValue}')` + ); + }, + + async setTransformEditFlyoutInputValue(input: string, value: string) { + await testSubjects.setValue(`transformEditFlyout${input}Input`, value, { + clearWithKeyboard: true, + }); + await this.assertTransformEditFlyoutInputValue(input, value); + }, + + async updateTransform() { + await testSubjects.click('transformEditFlyoutUpdateButton'); + await retry.tryForTime(5000, async () => { + await this.assertTransformEditFlyoutMissing(); + }); + }, + }; +} diff --git a/x-pack/test/functional/services/transform/index.ts b/x-pack/test/functional/services/transform/index.ts index 070bc48b432e11..24091ba773218c 100644 --- a/x-pack/test/functional/services/transform/index.ts +++ b/x-pack/test/functional/services/transform/index.ts @@ -7,6 +7,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; import { TransformAPIProvider } from './api'; +import { TransformEditFlyoutProvider } from './edit_flyout'; import { TransformManagementProvider } from './management'; import { TransformNavigationProvider } from './navigation'; import { TransformSecurityCommonProvider } from './security_common'; @@ -19,6 +20,7 @@ import { MachineLearningTestResourcesProvider } from '../ml/test_resources'; export function TransformProvider(context: FtrProviderContext) { const api = TransformAPIProvider(context); + const editFlyout = TransformEditFlyoutProvider(context); const management = TransformManagementProvider(context); const navigation = TransformNavigationProvider(context); const securityCommon = TransformSecurityCommonProvider(context); @@ -30,6 +32,7 @@ export function TransformProvider(context: FtrProviderContext) { return { api, + editFlyout, management, navigation, securityCommon, diff --git a/x-pack/test/functional/services/transform/transform_table.ts b/x-pack/test/functional/services/transform/transform_table.ts index 0c9a5414bdd2b4..453dca904b6059 100644 --- a/x-pack/test/functional/services/transform/transform_table.ts +++ b/x-pack/test/functional/services/transform/transform_table.ts @@ -145,12 +145,52 @@ export function TransformTableProvider({ getService }: FtrProviderContext) { await testSubjects.existOrFail('~transformPivotPreview'); } + public async assertTransformExpandedRowMessages(expectedText: string) { + await testSubjects.click('transformListRowDetailsToggle'); + + // The expanded row should show the details tab content by default + await testSubjects.existOrFail('transformDetailsTab'); + await testSubjects.existOrFail('~transformDetailsTabContent'); + + // Click on the messages tab and assert the messages + await testSubjects.existOrFail('transformMessagesTab'); + await testSubjects.click('transformMessagesTab'); + await testSubjects.existOrFail('~transformMessagesTabContent'); + await retry.tryForTime(5000, async () => { + const actualText = await testSubjects.getVisibleText('~transformMessagesTabContent'); + expect(actualText.includes(expectedText)).to.eql( + true, + `Expected transform messages text to include '${expectedText}'` + ); + }); + } + + public async assertTransformRowActions(isTransformRunning = false) { + await testSubjects.click('euiCollapsedItemActionsButton'); + + await testSubjects.existOrFail('transformActionClone'); + await testSubjects.existOrFail('transformActionDelete'); + await testSubjects.existOrFail('transformActionEdit'); + + if (isTransformRunning) { + await testSubjects.missingOrFail('transformActionStart'); + await testSubjects.existOrFail('transformActionStop'); + } else { + await testSubjects.existOrFail('transformActionStart'); + await testSubjects.missingOrFail('transformActionStop'); + } + } + + public async clickTransformRowAction(action: string) { + await testSubjects.click(`transformAction${action}`); + } + public async waitForTransformsExpandedRowPreviewTabToLoad() { await testSubjects.existOrFail('~transformPivotPreview', { timeout: 60 * 1000 }); await testSubjects.existOrFail('transformPivotPreview loaded', { timeout: 30 * 1000 }); } - async assertTransformsExpandedRowPreviewColumnValues(column: number, values: string[]) { + public async assertTransformsExpandedRowPreviewColumnValues(column: number, values: string[]) { await this.waitForTransformsExpandedRowPreviewTabToLoad(); await this.assertEuiDataGridColumnValues('transformPivotPreview', column, values); }