Skip to content

Commit

Permalink
[ML] Functional tests - stabilize calendar edit tests (#78950)
Browse files Browse the repository at this point in the history
This PR stabilizes the calendar edit test by making sure the correct calendar form is displayed on the edit page.
  • Loading branch information
pheyos authored Oct 1, 2020
1 parent 0776bf7 commit 42b5d78
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_cr
function EditHeader({ calendarId, description }) {
return (
<Fragment>
<EuiTitle>
<EuiTitle data-test-subj="mlCalendarTitle">
<h1>
<FormattedMessage
id="xpack.ml.calendarsEdit.calendarForm.calendarTitle"
Expand Down Expand Up @@ -86,7 +86,7 @@ export const CalendarForm = ({
const redirectToCalendarsManagementPage = useCreateAndNavigateToMlLink(ML_PAGES.CALENDARS_MANAGE);

return (
<EuiForm>
<EuiForm data-test-subj={`mlCalendarForm${isEdit === true ? 'Edit' : 'New'}`}>
{isEdit === true ? (
<EditHeader calendarId={calendarId} description={description} />
) : (
Expand Down
11 changes: 8 additions & 3 deletions x-pack/test/functional/apps/ml/settings/calendar_edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/ml/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
15 changes: 12 additions & 3 deletions x-pack/test/functional/services/ml/settings_calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 42b5d78

Please sign in to comment.