Skip to content

Commit

Permalink
functional test for navigating from job list annotations to SMV
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtj committed Sep 3, 2024
1 parent 8311dd6 commit 4ca40bd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ export default function ({ getService }: FtrProviderContext) {
await ml.jobExpandedDetails.assertJobRowCalendars(jobId, [calendarId]);
});

it('expanded row with forecast should navigate to single metric view after clicking open forecast button', async () => {
it('expanded row with forecast should navigate to Single Metric Viewer on button click', async () => {
await ml.jobExpandedDetails.openForecastJob(jobId);
});

it('expanded row with annotations should navigate to Single Metric Viewer on button click', async () => {
await ml.navigation.navigateToJobManagement();

const annotationsFromApi = await ml.api.getAnnotations(jobId);

await ml.jobExpandedDetails.openAnnotationInSingleMetricViewer(jobId, annotationsFromApi);
});

it('expanded row with annotations can be edited', async () => {
await ml.navigation.navigateToMl();
await ml.navigation.navigateToJobManagement();

const annotationsFromApi = await ml.api.getAnnotations(jobId);

await ml.jobExpandedDetails.editAnnotation(jobId, 'edited annotation', annotationsFromApi);
Expand Down
30 changes: 25 additions & 5 deletions x-pack/test/functional/services/ml/job_expanded_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,36 @@ export function MachineLearningJobExpandedDetailsProvider(
}
},

async assertAnnotationsFromApi(annotationsFromApi: any) {
const length = annotationsFromApi.length;
expect(length).to.eql(
1,
`Expect annotations from api to have length of 1, but got [${length}]`
);
},

async openAnnotationInSingleMetricViewer(
jobId: string,
annotationsFromApi: any
): Promise<void> {
await this.assertAnnotationsFromApi(annotationsFromApi);

const { _id: annotationId }: { _id: string } = annotationsFromApi[0];

await jobTable.ensureDetailsOpen(jobId);
await jobTable.openAnnotationsTab(jobId);
await this.clearSearchButton();
await jobAnnotationsTable.ensureAnnotationsActionsMenuOpen(annotationId);
await testSubjects.click('mlAnnotationsActionOpenInSingleMetricViewer');
await testSubjects.existOrFail('mlSingleMetricViewerChart');
},

async editAnnotation(
jobId: string,
newAnnotationText: string,
annotationsFromApi: any
): Promise<void> {
const length = annotationsFromApi.length;
expect(length).to.eql(
1,
`Expect annotions from api to have length of 1, but got [${length}]`
);
await this.assertAnnotationsFromApi(annotationsFromApi);

await jobTable.ensureDetailsOpen(jobId);
await jobTable.openAnnotationsTab(jobId);
Expand Down

0 comments on commit 4ca40bd

Please sign in to comment.