From 42b5d787e654bca0c1e0b789cd7f6f27065b7109 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Thu, 1 Oct 2020 07:46:07 +0200 Subject: [PATCH] [ML] Functional tests - stabilize calendar edit tests (#78950) This PR stabilizes the calendar edit test by making sure the correct calendar form is displayed on the edit page. --- .../__snapshots__/calendar_form.test.js.snap | 9 +++++++-- .../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 ++++++++++++--- 5 files changed, 30 insertions(+), 11 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`] = ` - +

+

- +

+ {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) {