diff --git a/frontend/src/__mocks__/mockDashboardConfig.ts b/frontend/src/__mocks__/mockDashboardConfig.ts index ef2831e497..370e500251 100644 --- a/frontend/src/__mocks__/mockDashboardConfig.ts +++ b/frontend/src/__mocks__/mockDashboardConfig.ts @@ -1,4 +1,5 @@ import { DashboardConfigKind, KnownLabels } from '~/k8sTypes'; +import { NotebookSize } from '~/types'; type MockDashboardConfigType = { disableInfo?: boolean; @@ -26,6 +27,7 @@ type MockDashboardConfigType = { disableDistributedWorkloads?: boolean; disableModelRegistry?: boolean; disableNotebookController?: boolean; + notebookSizes?: NotebookSize[]; }; export const mockDashboardConfig = ({ @@ -54,6 +56,73 @@ export const mockDashboardConfig = ({ disableDistributedWorkloads = false, disableModelRegistry = true, disableNotebookController = false, + notebookSizes = [ + { + name: 'XSmall', + resources: { + limits: { + cpu: '0.5', + memory: '500Mi', + }, + requests: { + cpu: '0.1', + memory: '100Mi', + }, + }, + }, + { + name: 'Small', + resources: { + limits: { + cpu: '2', + memory: '8Gi', + }, + requests: { + cpu: '1', + memory: '8Gi', + }, + }, + }, + { + name: 'Medium', + resources: { + limits: { + cpu: '6', + memory: '24Gi', + }, + requests: { + cpu: '3', + memory: '24Gi', + }, + }, + }, + { + name: 'Large', + resources: { + limits: { + cpu: '14', + memory: '56Gi', + }, + requests: { + cpu: '7', + memory: '56Gi', + }, + }, + }, + { + name: 'X Large', + resources: { + limits: { + cpu: '30', + memory: '120Gi', + }, + requests: { + cpu: '15', + memory: '120Gi', + }, + }, + }, + ], }: MockDashboardConfigType): DashboardConfigKind => ({ apiVersion: 'opendatahub.io/v1alpha', kind: 'OdhDashboardConfig', @@ -147,73 +216,7 @@ export const mockDashboardConfig = ({ }, }, ], - notebookSizes: [ - { - name: 'XSmall', - resources: { - limits: { - cpu: '0.5', - memory: '500Mi', - }, - requests: { - cpu: '0.1', - memory: '100Mi', - }, - }, - }, - { - name: 'Small', - resources: { - limits: { - cpu: '2', - memory: '8Gi', - }, - requests: { - cpu: '1', - memory: '8Gi', - }, - }, - }, - { - name: 'Medium', - resources: { - limits: { - cpu: '6', - memory: '24Gi', - }, - requests: { - cpu: '3', - memory: '24Gi', - }, - }, - }, - { - name: 'Large', - resources: { - limits: { - cpu: '14', - memory: '56Gi', - }, - requests: { - cpu: '7', - memory: '56Gi', - }, - }, - }, - { - name: 'X Large', - resources: { - limits: { - cpu: '30', - memory: '120Gi', - }, - requests: { - cpu: '15', - memory: '120Gi', - }, - }, - }, - ], + notebookSizes, templateOrder: ['test-model'], templateDisablement: ['test-model'], }, diff --git a/frontend/src/__tests__/cypress/cypress/pages/workbench.ts b/frontend/src/__tests__/cypress/cypress/pages/workbench.ts index d0279617a7..01cbc949f4 100644 --- a/frontend/src/__tests__/cypress/cypress/pages/workbench.ts +++ b/frontend/src/__tests__/cypress/cypress/pages/workbench.ts @@ -299,6 +299,11 @@ class CreateSpawnerPage { findBucketInput() { return cy.findByTestId('field AWS_S3_BUCKET'); } + + shouldNotHaveCustomContainerSizeInput() { + cy.findByTestId('container-size-group').contains('Custom').should('not.exist'); + return this; + } } class EditSpawnerPage extends CreateSpawnerPage { diff --git a/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts index f43db7f18c..47233766a1 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts @@ -1,4 +1,5 @@ import { + mockDashboardConfig, mockDscStatus, mockK8sResourceList, mockNotebookK8sResource, @@ -399,10 +400,72 @@ describe('Workbench page', () => { }); cy.get('@editWorkbench.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 }); }); + it('Handle deleted notebook sizes in workbenches table', () => { + initIntercepts({}); + cy.interceptOdh( + 'GET /api/config', + mockDashboardConfig({ + notebookSizes: [ + { + name: 'Medium', + resources: { + limits: { + cpu: '6', + memory: '24Gi', + }, + requests: { + cpu: '3', + memory: '24Gi', + }, + }, + }, + { + name: 'Large', + resources: { + limits: { + cpu: '14', + memory: '56Gi', + }, + requests: { + cpu: '7', + memory: '56Gi', + }, + }, + }, + { + name: 'X Large', + resources: { + limits: { + cpu: '30', + memory: '120Gi', + }, + requests: { + cpu: '15', + memory: '120Gi', + }, + }, + }, + ], + }), + ); + workbenchPage.visit('test-project'); + const notebookRow = workbenchPage.getNotebookRow('Test Notebook'); + notebookRow.shouldHaveNotebookImageName('Test Image'); + notebookRow.shouldHaveContainerSize('Custom'); + notebookRow.findKebabAction('Edit workbench').click(); + editSpawnerPage.shouldHaveContainerSizeInput('Custom'); + workbenchPage.visit('test-project'); + workbenchPage.findCreateButton().click(); + createSpawnerPage.findSubmitButton().should('be.disabled'); + verifyRelativeURL('/projects/test-project/spawner'); + // Custom container size dropdown option should not be present for create workbench + createSpawnerPage.shouldNotHaveCustomContainerSizeInput(); + }); + it('Validate that updating invalid workbench will navigate to the new page with an error message', () => { initIntercepts({}); notFoundSpawnerPage.visit('updated-notebook'); diff --git a/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx b/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx index a75a88a6d4..09a488652c 100644 --- a/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx +++ b/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx @@ -52,6 +52,7 @@ const NotebookList: React.FC = () => {