Skip to content

Commit

Permalink
Merge pull request #3008 from jpuzz0/RHOAIENG-4702
Browse files Browse the repository at this point in the history
[RHOAIENG-4702] Improve unique naming for runs and versions in pipelines
  • Loading branch information
jpuzz0 authored Jul 24, 2024
2 parents b89b416 + 980dd12 commit 7332e85
Show file tree
Hide file tree
Showing 14 changed files with 510 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ export class CreateRunPage {
}

fillName(value: string): void {
this.findNameInput().type(value);
this.findNameInput().clear().type(value);
}

fillDescription(value: string): void {
this.findDescriptionInput().type(value);
this.findDescriptionInput().clear().type(value);
}

selectExperimentByName(name: string): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
import type { PipelineKFv2, PipelineVersionKFv2 } from '~/concepts/pipelines/kfTypes';
import { type PipelineKFv2, type PipelineVersionKFv2 } from '~/concepts/pipelines/kfTypes';
import { buildMockPipelines } from '~/__mocks__/mockPipelinesProxy';
import { buildMockPipelineVersionsV2 } from '~/__mocks__/mockPipelineVersionsProxy';
import { TableRow } from '~/__tests__/cypress/cypress/pages/components/table';
Expand Down Expand Up @@ -217,21 +217,55 @@ class PipelinesTable {
);
}

mockGetPipelines(pipelines: PipelineKFv2[], namespace: string) {
mockGetPipelines(pipelines: PipelineKFv2[], namespace: string, times?: number) {
return cy.interceptOdh(
'GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines',
{
path: { namespace, serviceName: 'dspa' },
times,
},
(req) => {
const { filter } = req.query;
const predicates = filter ? JSON.parse(filter.toString())?.predicates : [];
const filterName = predicates?.[0]?.string_value;

if (!filterName) {
req.reply(buildMockPipelines(pipelines));
} else {
req.reply(
buildMockPipelines(
pipelines.filter((pipeline) => pipeline.display_name === filterName),
),
);
}
},
buildMockPipelines(pipelines),
);
}

mockGetPipelineVersions(versions: PipelineVersionKFv2[], pipelineId: string, namespace: string) {
mockGetPipelineVersions(
versions: PipelineVersionKFv2[],
pipelineId: string,
namespace: string,
times?: number,
) {
return cy.interceptOdh(
'GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions',
{ path: { namespace, serviceName: 'dspa', pipelineId } },
buildMockPipelineVersionsV2(versions),
{ path: { namespace, serviceName: 'dspa', pipelineId }, times },
(req) => {
const { filter } = req.query;
const predicates = filter ? JSON.parse(filter.toString())?.predicates : [];
const filterName = predicates?.[0]?.string_value;

if (!filterName) {
req.reply(buildMockPipelineVersionsV2(versions));
} else {
req.reply(
buildMockPipelineVersionsV2(
versions.filter((version) => version.display_name === filterName),
),
);
}
},
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,18 @@ declare global {
) => Cypress.Chainable<null>) &
((
type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions`,
options: { path: { namespace: string; serviceName: string; pipelineId: string } },
options: {
path: { namespace: string; serviceName: string; pipelineId: string };
times?: number;
},
response: OdhResponse<ListPipelineVersionsKF | GoogleRpcStatusKF>,
) => Cypress.Chainable<null>) &
((
type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines`,
options: {
path: { namespace: string; serviceName: string };
query?: { sort_by: string };
times?: number;
},
response: OdhResponse<ListPipelinesResponseKF | GoogleRpcStatusKF>,
) => Cypress.Chainable<null>) &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ describe('Pipeline create runs', () => {
createRunPage.find();

// Fill out the form without a schedule and submit
createRunPage.fillName(initialMockRuns[0].display_name);
cy.findByTestId('duplicate-name-help-text').should('be.visible');
createRunPage.fillName('New run');
createRunPage.fillDescription('New run description');
createRunPage.findExperimentSelect().should('contain.text', 'Select an experiment');
Expand Down Expand Up @@ -554,6 +556,8 @@ describe('Pipeline create runs', () => {
createSchedulePage.find();

// Fill out the form with a schedule and submit
createRunPage.fillName(initialMockRecurringRuns[0].display_name);
cy.findByTestId('duplicate-name-help-text').should('be.visible');
createSchedulePage.fillName('New recurring run');
createSchedulePage.fillDescription('New recurring run description');
createSchedulePage.findExperimentSelect().should('contain.text', 'Default');
Expand Down
Loading

0 comments on commit 7332e85

Please sign in to comment.