diff --git a/clients/ui/frontend/src/__mocks__/mockBFFResponse.ts b/clients/ui/frontend/src/__mocks__/mockBFFResponse.ts deleted file mode 100644 index f1599462..00000000 --- a/clients/ui/frontend/src/__mocks__/mockBFFResponse.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ModelRegistryBody } from '~/app/types'; - -export const mockBFFResponse = (data: T): ModelRegistryBody => ({ - data, -}); diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/support/commands/api.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/support/commands/api.ts index 019f4520..08423f51 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/support/commands/api.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/support/commands/api.ts @@ -1,9 +1,9 @@ import type { GenericStaticResponse, RouteHandlerController } from 'cypress/types/net-stubbing'; +import { mockBFFResponse } from '~/__mocks__/utils'; import type { ModelArtifact, ModelArtifactList, ModelRegistry, - ModelRegistryBody, ModelVersion, ModelVersionList, RegisteredModel, @@ -35,7 +35,7 @@ declare global { interceptApi: (( type: 'GET /api/:apiVersion/model_registry/:modelRegistryName/registered_models', options: { path: { modelRegistryName: string; apiVersion: string } }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'POST /api/:apiVersion/model_registry/:modelRegistryName/registered_models', @@ -47,7 +47,7 @@ declare global { options: { path: { modelRegistryName: string; apiVersion: string; registeredModelId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'POST /api/:apiVersion/model_registry/:modelRegistryName/registered_models/:registeredModelId/versions', @@ -61,28 +61,28 @@ declare global { options: { path: { modelRegistryName: string; apiVersion: string; registeredModelId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'PATCH /api/:apiVersion/model_registry/:modelRegistryName/registered_models/:registeredModelId', options: { path: { modelRegistryName: string; apiVersion: string; registeredModelId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'GET /api/:apiVersion/model_registry/:modelRegistryName/model_versions/:modelVersionId', options: { path: { modelRegistryName: string; apiVersion: string; modelVersionId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'GET /api/:apiVersion/model_registry/:modelRegistryName/model_versions/:modelVersionId/artifacts', options: { path: { modelRegistryName: string; apiVersion: string; modelVersionId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'POST /api/:apiVersion/model_registry/:modelRegistryName/model_versions/:modelVersionId/artifacts', @@ -96,12 +96,12 @@ declare global { options: { path: { modelRegistryName: string; apiVersion: string; modelVersionId: number }; }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable) & (( type: 'GET /api/:apiVersion/model_registry', options: { path: { apiVersion: string } }, - response: ApiResponse>, + response: ApiResponse, ) => Cypress.Chainable); } } @@ -136,7 +136,7 @@ Cypress.Commands.add( } return cy.intercept( { method, pathname, query: options?.query, ...(options?.times && { times: options.times }) }, - response, + mockBFFResponse(response), ); }, ); diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistry/modelRegistry.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistry/modelRegistry.cy.ts index e6cb531c..897b0114 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistry/modelRegistry.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistry/modelRegistry.cy.ts @@ -5,7 +5,6 @@ import { mockModelVersionList } from '~/__mocks__/mockModelVersionList'; import { mockRegisteredModel } from '~/__mocks__/mockRegisteredModel'; import { mockRegisteredModelList } from '~/__mocks__/mockRegisteredModelsList'; import { labelModal, modelRegistry } from '~/__tests__/cypress/cypress/pages/modelRegistry'; -import { mockBFFResponse } from '~/__mocks__/mockBFFResponse'; import type { ModelRegistry, ModelVersion, RegisteredModel } from '~/app/types'; import { be } from '~/__tests__/cypress/cypress/utils/should'; import { MODEL_REGISTRY_API_VERSION } from '~/__tests__/cypress/cypress/support/commands/api'; @@ -69,7 +68,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); cy.interceptApi( @@ -77,7 +76,7 @@ const initIntercepts = ({ { path: { modelRegistryName: 'modelregistry-sample', apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(mockRegisteredModelList({ items: registeredModels })), + mockRegisteredModelList({ items: registeredModels }), ); cy.interceptApi( @@ -89,7 +88,7 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse(mockModelVersionList({ items: modelVersions })), + mockModelVersionList({ items: modelVersions }), ); }; diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistrySettings/modelRegistrySettings.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistrySettings/modelRegistrySettings.cy.ts index 22ed09af..9a28f6e3 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistrySettings/modelRegistrySettings.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistrySettings/modelRegistrySettings.cy.ts @@ -1,6 +1,5 @@ import { mockModelRegistry } from '~/__mocks__/mockModelRegistry'; import type { ModelRegistry } from '~/app/types'; -import { mockBFFResponse } from '~/__mocks__/mockBFFResponse'; import { modelRegistrySettings } from '~/__tests__/cypress/cypress/pages/modelRegistrySettings'; type HandlersProps = { @@ -28,7 +27,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); }; diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionArchive.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionArchive.cy.ts index f52bdc37..29125058 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionArchive.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionArchive.cy.ts @@ -63,7 +63,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); cy.interceptApi( @@ -71,7 +71,7 @@ const initIntercepts = ({ { path: { modelRegistryName: 'modelregistry-sample', apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(mockRegisteredModelList({ size: registeredModelsSize })), + mockRegisteredModelList({ size: registeredModelsSize }), ); cy.interceptApi( @@ -83,11 +83,9 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse( - mockModelVersionList({ - items: modelVersions, - }), - ), + mockModelVersionList({ + items: modelVersions, + }), ); cy.interceptApi( @@ -99,7 +97,7 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse(mockRegisteredModel({ name: 'test-1' })), + mockRegisteredModel({ name: 'test-1' }), ); cy.interceptApi( @@ -111,9 +109,7 @@ const initIntercepts = ({ modelVersionId: 2, }, }, - mockBFFResponse( - mockModelVersion({ id: '2', name: 'model version 2', state: ModelState.ARCHIVED }), - ), + mockModelVersion({ id: '2', name: 'model version 2', state: ModelState.ARCHIVED }), ); cy.interceptApi( @@ -125,7 +121,7 @@ const initIntercepts = ({ modelVersionId: 3, }, }, - mockBFFResponse(mockModelVersion({ id: '3', name: 'model version 3', state: ModelState.LIVE })), + mockModelVersion({ id: '3', name: 'model version 3', state: ModelState.LIVE }), ); }; @@ -199,7 +195,7 @@ describe('Restoring archive version', () => { modelVersionId: 2, }, }, - mockBFFResponse(mockModelVersion({})), + mockModelVersion({}), ).as('versionRestored'); initIntercepts({}); @@ -228,7 +224,7 @@ describe('Restoring archive version', () => { modelVersionId: 2, }, }, - mockBFFResponse(mockModelVersion({})), + mockModelVersion({}), ).as('versionRestored'); initIntercepts({}); @@ -257,7 +253,7 @@ describe('Archiving version', () => { modelVersionId: 3, }, }, - mockBFFResponse(mockModelVersion({})), + mockModelVersion({}), ).as('versionArchived'); initIntercepts({}); @@ -287,7 +283,7 @@ describe('Archiving version', () => { modelVersionId: 3, }, }, - mockBFFResponse(mockModelVersion({})), + mockModelVersion({}), ).as('versionArchived'); initIntercepts({}); diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionDetails.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionDetails.cy.ts index 3bcf9ece..c07827db 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionDetails.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersionDetails.cy.ts @@ -1,7 +1,6 @@ /* eslint-disable camelcase */ import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url'; import { mockModelRegistry } from '~/__mocks__/mockModelRegistry'; -import { mockBFFResponse } from '~/__mocks__/utils'; import { mockRegisteredModel } from '~/__mocks__/mockRegisteredModel'; import { mockModelVersionList } from '~/__mocks__/mockModelVersionList'; import { mockModelVersion } from '~/__mocks__/mockModelVersion'; @@ -34,7 +33,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); cy.interceptApi( @@ -46,7 +45,7 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse(mockRegisteredModel({})), + mockRegisteredModel({}), ); cy.interceptApi( @@ -58,19 +57,17 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse( - mockModelVersionList({ - items: [ - mockModelVersion({ name: 'Version 1', author: 'Author 1', registeredModelId: '1' }), - mockModelVersion({ - author: 'Author 2', - registeredModelId: '1', - id: '2', - name: 'Version 2', - }), - ], - }), - ), + mockModelVersionList({ + items: [ + mockModelVersion({ name: 'Version 1', author: 'Author 1', registeredModelId: '1' }), + mockModelVersion({ + author: 'Author 2', + registeredModelId: '1', + id: '2', + name: 'Version 2', + }), + ], + }), ); cy.interceptApi( @@ -82,23 +79,21 @@ const initIntercepts = ({ modelVersionId: 1, }, }, - mockBFFResponse( - mockModelVersion({ - id: '1', - name: 'Version 1', - labels: [ - 'Testing label', - 'Financial data', - 'Fraud detection', - 'Long label data to be truncated abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc', - 'Machine learning', - 'Next data to be overflow', - 'Label x', - 'Label y', - 'Label z', - ], - }), - ), + mockModelVersion({ + id: '1', + name: 'Version 1', + labels: [ + 'Testing label', + 'Financial data', + 'Fraud detection', + 'Long label data to be truncated abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc', + 'Machine learning', + 'Next data to be overflow', + 'Label x', + 'Label y', + 'Label z', + ], + }), ); cy.interceptApi( @@ -110,7 +105,7 @@ const initIntercepts = ({ modelVersionId: 2, }, }, - mockBFFResponse(mockModelVersion({ id: '2', name: 'Version 2' })), + mockModelVersion({ id: '2', name: 'Version 2' }), ); cy.interceptApi( @@ -122,18 +117,16 @@ const initIntercepts = ({ modelVersionId: 1, }, }, - mockBFFResponse( - mockModelArtifactList({ - items: [ - mockModelArtifact({}), - mockModelArtifact({ - author: 'Author 2', - id: '2', - name: 'Artifact 2', - }), - ], - }), - ), + mockModelArtifactList({ + items: [ + mockModelArtifact({}), + mockModelArtifact({ + author: 'Author 2', + id: '2', + name: 'Artifact 2', + }), + ], + }), ); }; diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersions.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersions.cy.ts index c3fd860e..7ad00d4a 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersions.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelVersions.cy.ts @@ -8,7 +8,6 @@ import type { ModelRegistry, ModelVersion } from '~/app/types'; import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url'; import { mockModelRegistry } from '~/__mocks__/mockModelRegistry'; import { mockModelVersion } from '~/__mocks__/mockModelVersion'; -import { mockBFFResponse } from '~/__mocks__/utils'; import { MODEL_REGISTRY_API_VERSION } from '~/__tests__/cypress/cypress/support/commands/api'; type HandlersProps = { @@ -54,7 +53,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); cy.interceptApi( @@ -62,7 +61,7 @@ const initIntercepts = ({ { path: { modelRegistryName: 'modelregistry-sample', apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(mockRegisteredModelList({ size: registeredModelsSize })), + mockRegisteredModelList({ size: registeredModelsSize }), ); cy.interceptApi( @@ -74,7 +73,7 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse(mockModelVersionList({ items: modelVersions })), + mockModelVersionList({ items: modelVersions }), ); cy.interceptApi( @@ -86,7 +85,7 @@ const initIntercepts = ({ registeredModelId: 1, }, }, - mockBFFResponse(mockRegisteredModel({})), + mockRegisteredModel({}), ); cy.interceptApi( @@ -98,7 +97,7 @@ const initIntercepts = ({ modelVersionId: 1, }, }, - mockBFFResponse(mockModelVersion({ id: '1', name: 'model version' })), + mockModelVersion({ id: '1', name: 'model version' }), ); }; diff --git a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/registeredModelArchive.cy.ts b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/registeredModelArchive.cy.ts index 451b5a7c..d07c89a1 100644 --- a/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/registeredModelArchive.cy.ts +++ b/clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/registeredModelArchive.cy.ts @@ -67,7 +67,7 @@ const initIntercepts = ({ { path: { apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(modelRegistries), + modelRegistries, ); cy.interceptApi( @@ -75,7 +75,7 @@ const initIntercepts = ({ { path: { modelRegistryName: 'modelregistry-sample', apiVersion: MODEL_REGISTRY_API_VERSION }, }, - mockBFFResponse(mockRegisteredModelList({ items: registeredModels })), + mockRegisteredModelList({ items: registeredModels }), ); cy.interceptApi( @@ -87,7 +87,7 @@ const initIntercepts = ({ modelVersionId: 1, }, }, - mockBFFResponse(mockModelVersion({ id: '1', name: 'Version 2' })), + mockModelVersion({ id: '1', name: 'Version 2' }), ); cy.interceptApi( @@ -99,7 +99,7 @@ const initIntercepts = ({ registeredModelId: 2, }, }, - mockBFFResponse(mockModelVersionList({ items: modelVersions })), + mockModelVersionList({ items: modelVersions }), ); cy.interceptApi( @@ -111,7 +111,7 @@ const initIntercepts = ({ registeredModelId: 2, }, }, - mockBFFResponse(mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.ARCHIVED })), + mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.ARCHIVED }), ); cy.interceptApi( @@ -123,7 +123,7 @@ const initIntercepts = ({ registeredModelId: 3, }, }, - mockBFFResponse(mockRegisteredModel({ id: '3', name: 'model 3' })), + mockRegisteredModel({ id: '3', name: 'model 3' }), ); }; @@ -249,7 +249,7 @@ describe('Restoring archive model', () => { registeredModelId: 2, }, }, - mockBFFResponse(mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.LIVE })), + mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.LIVE }), ).as('modelRestored'); initIntercepts({}); @@ -278,7 +278,7 @@ describe('Restoring archive model', () => { registeredModelId: 2, }, }, - mockBFFResponse(mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.LIVE })), + mockRegisteredModel({ id: '2', name: 'model 2', state: ModelState.LIVE }), ).as('modelRestored'); initIntercepts({}); @@ -307,9 +307,7 @@ describe('Archiving model', () => { registeredModelId: 3, }, }, - mockBFFResponse( - mockRegisteredModel({ id: '3', name: 'model 3', state: ModelState.ARCHIVED }), - ), + mockRegisteredModel({ id: '3', name: 'model 3', state: ModelState.ARCHIVED }), ).as('modelArchived'); initIntercepts({}); @@ -339,9 +337,7 @@ describe('Archiving model', () => { registeredModelId: 3, }, }, - mockBFFResponse( - mockRegisteredModel({ id: '3', name: 'model 3', state: ModelState.ARCHIVED }), - ), + mockRegisteredModel({ id: '3', name: 'model 3', state: ModelState.ARCHIVED }), ).as('modelArchived'); initIntercepts({});