From f08931987437c911871cb443949dfce66cec8231 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Wed, 30 Sep 2020 15:17:30 +0200 Subject: [PATCH 1/2] [ML] Functional tests - stabilize calendar edit tests --- .../calendars/edit/calendar_form/calendar_form.js | 4 ++-- .../functional/apps/ml/settings/calendar_edit.ts | 11 ++++++++--- x-pack/test/functional/apps/ml/settings/index.ts | 2 +- .../functional/services/ml/settings_calendar.ts | 15 ++++++++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js index 924f730c4e234..9dcb89aec2ead 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js @@ -31,7 +31,7 @@ import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_cr function EditHeader({ calendarId, description }) { return ( - +

+ {isEdit === true ? ( ) : ( diff --git a/x-pack/test/functional/apps/ml/settings/calendar_edit.ts b/x-pack/test/functional/apps/ml/settings/calendar_edit.ts index e738b50a2fe05..f9ba8fccd3c1c 100644 --- a/x-pack/test/functional/apps/ml/settings/calendar_edit.ts +++ b/x-pack/test/functional/apps/ml/settings/calendar_edit.ts @@ -20,8 +20,7 @@ export default function ({ getService }: FtrProviderContext) { const jobConfigs = [createJobConfig('test_calendar_ad_1'), createJobConfig('test_calendar_ad_2')]; const newJobGroups = ['farequote']; - // FLAKY: https://github.com/elastic/kibana/issues/78288 - describe.skip('calendar edit', function () { + describe('calendar edit', function () { before(async () => { await esArchiver.loadIfNeeded('ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); @@ -56,6 +55,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('calendar edit opens existing calendar'); await ml.settingsCalendar.openCalendarEditForm(calendarId); + await ml.settingsCalendar.assertCalendarTitleValue(calendarId); await ml.testExecution.logTestStep( 'calendar edit deselects previous job selection and assigns new job groups' @@ -85,14 +85,19 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('calendar edit re-opens the updated calendar'); await ml.settingsCalendar.openCalendarEditForm(calendarId); + await ml.settingsCalendar.assertCalendarTitleValue(calendarId); + await ml.testExecution.logTestStep('calendar edit verifies the job selection is empty'); await ml.settingsCalendar.assertJobSelection([]); + await ml.testExecution.logTestStep( 'calendar edit verifies the job group selection was updated' ); await ml.settingsCalendar.assertJobGroupSelection(newJobGroups); - await ml.testExecution.logTestStep('calendar edit verifies calendar updated correctly'); + await ml.testExecution.logTestStep( + 'calendar edit verifies calendar events updated correctly' + ); await asyncForEach(testEvents, async ({ description }) => { await ml.settingsCalendar.assertEventRowMissing(description); }); diff --git a/x-pack/test/functional/apps/ml/settings/index.ts b/x-pack/test/functional/apps/ml/settings/index.ts index 5b2c7d15e1959..eb91e005ebd71 100644 --- a/x-pack/test/functional/apps/ml/settings/index.ts +++ b/x-pack/test/functional/apps/ml/settings/index.ts @@ -7,7 +7,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('settings', function () { - this.tags(['quynh', 'skipFirefox']); + this.tags(['mlqa', 'skipFirefox']); loadTestFile(require.resolve('./calendar_creation')); loadTestFile(require.resolve('./calendar_edit')); diff --git a/x-pack/test/functional/services/ml/settings_calendar.ts b/x-pack/test/functional/services/ml/settings_calendar.ts index c269636522923..3a2c9149a0634 100644 --- a/x-pack/test/functional/services/ml/settings_calendar.ts +++ b/x-pack/test/functional/services/ml/settings_calendar.ts @@ -121,7 +121,7 @@ export function MachineLearningSettingsCalendarProvider( async openCalendarEditForm(calendarId: string) { await testSubjects.click(this.rowSelector(calendarId, 'mlEditCalendarLink')); - await testSubjects.existOrFail('mlPageCalendarEdit'); + await testSubjects.existOrFail('mlPageCalendarEdit > mlCalendarFormEdit', { timeout: 5000 }); }, async assertApplyToAllJobsSwitchEnabled(expectedValue: boolean) { @@ -224,6 +224,15 @@ export function MachineLearningSettingsCalendarProvider( ); }, + async assertCalendarTitleValue(expectedCalendarId: string) { + const actualValue = await testSubjects.getVisibleText('mlCalendarTitle'); + const expectedValue = `Calendar ${expectedCalendarId}`; + expect(actualValue).to.eql( + expectedValue, + `Calendar title should be '${expectedValue}' (got '${actualValue}')` + ); + }, + async setCalendarId(calendarId: string) { await mlCommonUI.setValueWithChecks('mlCalendarIdInput', calendarId, { clearWithKeyboard: true, @@ -271,13 +280,13 @@ export function MachineLearningSettingsCalendarProvider( async navigateToCalendarCreationPage() { await testSubjects.existOrFail('mlCalendarButtonCreate'); await testSubjects.click('mlCalendarButtonCreate'); - await testSubjects.existOrFail('mlPageCalendarEdit'); + await testSubjects.existOrFail('mlPageCalendarEdit > mlCalendarFormNew', { timeout: 5000 }); }, async openNewCalendarEventForm() { await testSubjects.existOrFail('mlCalendarNewEventButton'); await testSubjects.click('mlCalendarNewEventButton'); - await testSubjects.existOrFail('mlPageCalendarEdit'); + await testSubjects.existOrFail('mlCalendarEventForm'); }, async assertCalendarEventDescriptionValue(expectedValue: string) { From 1423127aede7853c8a5dd2743588bd02ceb1b78b Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Wed, 30 Sep 2020 15:55:05 +0200 Subject: [PATCH 2/2] Update jest snapshot --- .../__snapshots__/calendar_form.test.js.snap | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/__snapshots__/calendar_form.test.js.snap b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/__snapshots__/calendar_form.test.js.snap index ad76bb9115617..49caddfd29f82 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/__snapshots__/calendar_form.test.js.snap +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/__snapshots__/calendar_form.test.js.snap @@ -1,9 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`CalendarForm CalendarId shown as title when editing 1`] = ` - +

+