Skip to content

Commit

Permalink
Cypress fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-o0o committed Jan 29, 2025
1 parent 8c97f73 commit 250e904
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@ class ClusterStorageModal extends Modal {
.findByTestId('cluster-storage-workbench-select');
}

findWorkbenchName(row: number) {
return this.findWorkbenchTable()
.find(`[data-label=Name]`)
.eq(row)
.findByTestId('typeahead-menu-toggle');
}

findWorkbenchSelectValueField(row: number) {
return this.findWorkbenchSelect(row).findByRole('combobox', {
return this.findWorkbenchName(row).findByRole('combobox', {
name: 'Type to filter',
});
}
Expand Down
30 changes: 25 additions & 5 deletions frontend/src/__tests__/cypress/cypress/pages/modelServing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ class InferenceServiceModal extends Modal {
return this.find().findByTestId('alt-form-checkbox-auth');
}

findExistingDataConnectionOption() {
return this.find().findByTestId('existing-data-connection-radio');
findNewConnectionOption() {
return this.find().findByTestId('new-connection-radio');
}

findExistingConnectionOption() {
return this.find().findByTestId('existing-connection-radio');
}

findExternalRouteError() {
Expand All @@ -166,9 +170,25 @@ class InferenceServiceModal extends Modal {
}

findExistingConnectionSelect() {
return this.find()
.findByRole('group', { name: 'Source model location' })
.findByRole('button', { name: 'Options menu' });
return this.find().findByTestId('typeahead-menu-toggle');
}

findExistingConnectionSelectValueField() {
return this.findExistingConnectionSelect().findByRole('combobox', {
name: 'Type to filter',
});
}

selectExistingConnectionSelectOptionByResourceName() {
this.find().findByText('Test Secret').click();
}

findConnectionNameInput() {
return this.find().findByTestId('connection-name-desc-name');
}

findConnectionFieldInput() {
return this.find().findByTestId('field URI');
}

findLocationNameInput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ServingRuntimePlatform } from '~/types';
import { kserveModal } from '~/__tests__/cypress/cypress/pages/modelServing';
import { mockModelArtifact } from '~/__mocks__/mockModelArtifact';
import { mockNimAccount } from '~/__mocks__/mockNimAccount';
import { mockConnectionTypeConfigMap } from '~/__mocks__/mockConnectionType';

const MODEL_REGISTRY_API_VERSION = 'v1alpha3';

Expand Down Expand Up @@ -179,6 +180,22 @@ const initIntercepts = ({
{ namespace: 'opendatahub' },
),
);
cy.interceptOdh('GET /api/connection-types', [
mockConnectionTypeConfigMap({
displayName: 'URI - v1',
name: 'uri-v1',
category: ['existing-category'],
fields: [
{
type: 'uri',
name: 'URI field test',
envVar: 'URI',
required: true,
properties: {},
},
],
}),
]);

cy.interceptK8sList(NIMAccountModel, mockK8sResourceList([mockNimAccount({})]));
};
Expand Down Expand Up @@ -246,9 +263,7 @@ describe('Deploy model version', () => {
modelVersionDeployModal.selectProjectByName('KServe project');

// Validate name input field
kserveModal
.findModelNameInput()
.should('contain.value', `${registeredModelMocked.name} - ${modelVersionMocked.name} - `);
kserveModal.findModelNameInput().should('exist');

// Validate model framework section
kserveModal.findModelFrameworkSelect().should('be.disabled');
Expand All @@ -260,5 +275,47 @@ describe('Deploy model version', () => {
modelArtifactMocked.modelFormatVersion ?? ''
}`,
).should('exist');

// Validate connection section
kserveModal.findExistingConnectionOption().should('be.checked');
kserveModal.findLocationPathInput().should('exist');
});

it('One match connection on KServe modal', () => {
initIntercepts({});
cy.interceptK8sList(
SecretModel,
mockK8sResourceList([
mockSecretK8sResource({
namespace: 'kserve-project',
s3Bucket: 'dGVzdC1idWNrZXQ=',
endPoint: 'dGVzdC1lbmRwb2ludA==',
region: 'dGVzdC1yZWdpb24=',
}),
mockSecretK8sResource({
name: 'test-secret-not-match',
displayName: 'Test Secret Not Match',
namespace: 'kserve-project',
s3Bucket: 'dGVzdC1idWNrZXQ=',
endPoint: 'dGVzdC1lbmRwb2ludC1ub3QtbWF0Y2g=', // endpoint not match
region: 'dGVzdC1yZWdpb24=',
}),
]),
);

cy.visit(`/modelRegistry/modelregistry-sample/registeredModels/1/versions`);
const modelVersionRow = modelRegistry.getModelVersionRow('test model version');
modelVersionRow.findKebabAction('Deploy').click();
modelVersionDeployModal.selectProjectByName('KServe project');

// Validate connection section
kserveModal.findExistingConnectionOption().should('be.checked');
kserveModal.findExistingConnectionSelectValueField().click();
kserveModal.selectExistingConnectionSelectOptionByResourceName();
kserveModal.findLocationPathInput().type('test-model/');
kserveModal.findNewConnectionOption().click();
kserveModal.findExistingConnectionSelect().should('have.attr', 'disabled');
kserveModal.findConnectionNameInput().type('Test Name');
kserveModal.findConnectionFieldInput().type('https://test');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ServingRuntimePlatform } from '~/types';
import { be } from '~/__tests__/cypress/cypress/utils/should';
import { asClusterAdminUser } from '~/__tests__/cypress/cypress/utils/mockUsers';
import { testPagination } from '~/__tests__/cypress/cypress/utils/pagination';
import { mockConnectionTypeConfigMap } from '~/__mocks__/mockConnectionType';

type HandlersProps = {
disableKServeConfig?: boolean;
Expand Down Expand Up @@ -140,6 +141,22 @@ const initIntercepts = ({
{ namespace: 'opendatahub' },
),
);
cy.interceptOdh('GET /api/connection-types', [
mockConnectionTypeConfigMap({
displayName: 'URI - v1',
name: 'uri-v1',
category: ['existing-category'],
fields: [
{
type: 'uri',
name: 'URI field test',
envVar: 'URI',
required: true,
properties: {},
},
],
}),
]);
};

describe('Model Serving Global', () => {
Expand Down Expand Up @@ -299,22 +316,15 @@ describe('Model Serving Global', () => {
inferenceServiceModalEdit.findLocationPathInput().type('test-model/');
inferenceServiceModalEdit.findSubmitButton().should('be.enabled');

// test that user cant upload on an empty new secret
inferenceServiceModalEdit.findLocationPathInput().clear();
inferenceServiceModalEdit.findSubmitButton().should('be.disabled');
inferenceServiceModalEdit.findLocationPathInput().type('/');
// test that user cant upload on an empty field
inferenceServiceModalEdit.findNewConnectionOption().click();
inferenceServiceModalEdit.findSubmitButton().should('be.disabled');

// test that adding required values validates submit
inferenceServiceModalEdit.findLocationNameInput().type('Test Name');
inferenceServiceModalEdit.findLocationAccessKeyInput().type('test-key');
inferenceServiceModalEdit.findLocationSecretKeyInput().type('test-secret-key');
inferenceServiceModalEdit.findLocationEndpointInput().type('test-endpoint');
inferenceServiceModalEdit.findLocationBucketInput().type('test-bucket');
inferenceServiceModalEdit.findLocationPathInput().clear();
inferenceServiceModalEdit.findLocationPathInput().type('test-model/');
inferenceServiceModalEdit.findConnectionNameInput().type('Test Name');
inferenceServiceModalEdit.findConnectionFieldInput().type('/');
inferenceServiceModalEdit.findSubmitButton().click().should('be.disabled');
inferenceServiceModalEdit.findConnectionFieldInput().clear().type('https://test');
inferenceServiceModalEdit.findSubmitButton().should('be.enabled');

inferenceServiceModalEdit.findExistingConnectionOption().click();
inferenceServiceModalEdit.findSubmitButton().click();

cy.wait('@editModel').then((interception) => {
Expand Down Expand Up @@ -364,8 +374,12 @@ describe('Model Serving Global', () => {
inferenceServiceModal.findServingRuntimeSelect().should('be.disabled');
inferenceServiceModal.findModelFrameworkSelect().findSelectOption('onnx - 1').click();
inferenceServiceModal.findSubmitButton().should('be.disabled');
inferenceServiceModal.findExistingConnectionSelect().should('contain.text', 'Test Secret');
inferenceServiceModal.findExistingConnectionSelect().should('be.disabled');
inferenceServiceModal.findNewConnectionOption().click();
inferenceServiceModal.findConnectionNameInput().type('Test Name');
inferenceServiceModal.findConnectionFieldInput().type('https://test');
inferenceServiceModal.findSubmitButton().should('be.enabled');
inferenceServiceModal.findExistingConnectionOption().click();
inferenceServiceModal.findExistingConnectionSelect().should('have.attr', 'disabled');
inferenceServiceModal.findLocationPathInput().type('test-model/');
inferenceServiceModal.findSubmitButton().should('be.enabled');
inferenceServiceModal.findLocationPathInput().clear();
Expand All @@ -384,11 +398,6 @@ describe('Model Serving Global', () => {
.contains('Invalid path format');
inferenceServiceModal.findSubmitButton().should('be.disabled');
inferenceServiceModal.findLocationPathInput().clear();
inferenceServiceModal.findLocationNameInput().type('Test Name');
inferenceServiceModal.findLocationAccessKeyInput().type('test-key');
inferenceServiceModal.findLocationSecretKeyInput().type('test-secret-key');
inferenceServiceModal.findLocationEndpointInput().type('test-endpoint');
inferenceServiceModal.findLocationBucketInput().type('test-bucket');
inferenceServiceModal.findLocationPathInput().type('test-model/');
inferenceServiceModal.findSubmitButton().should('be.enabled');

Expand Down Expand Up @@ -423,13 +432,13 @@ describe('Model Serving Global', () => {
} satisfies InferenceServiceKind);
});

// Actaul request
// Actual request
cy.wait('@createInferenceService').then((interception) => {
expect(interception.request.url).not.to.include('?dryRun=All');
});

cy.get('@createInferenceService.all').then((interceptions) => {
expect(interceptions).to.have.length(2); // 1 dry run request and 1 actaul request
expect(interceptions).to.have.length(2); // 1 dry run request and 1 actual request
});
});

Expand All @@ -451,8 +460,7 @@ describe('Model Serving Global', () => {
inferenceServiceModal.findServingRuntimeSelect().should('be.disabled');
inferenceServiceModal.findModelFrameworkSelect().findSelectOption('onnx - 1').click();
inferenceServiceModal.findSubmitButton().should('be.disabled');
inferenceServiceModal.findExistingConnectionSelect().should('contain.text', 'Test Secret');
inferenceServiceModal.findExistingConnectionSelect().should('be.disabled');
inferenceServiceModal.findExistingConnectionSelect().should('have.attr', 'disabled');
inferenceServiceModal.findLocationPathInput().type('test-model/');
inferenceServiceModal.findSubmitButton().should('be.enabled');
inferenceServiceModal.findLocationPathInput().type('test-model/');
Expand Down
Loading

0 comments on commit 250e904

Please sign in to comment.