From e9f385c0b4c500ffeb2d5491bf6287ad95024c28 Mon Sep 17 00:00:00 2001 From: Dipanshu Gupta Date: Tue, 16 Jan 2024 15:40:58 +0530 Subject: [PATCH] Unable to duplicate a serving runtime --- .../CustomServingRuntimes.cy.ts | 112 ++++++++++-------- .../CustomServingRuntimeAddTemplate.tsx | 8 +- 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/e2e/customServingRuntimes/CustomServingRuntimes.cy.ts b/frontend/src/__tests__/cypress/cypress/e2e/customServingRuntimes/CustomServingRuntimes.cy.ts index a4c33b7e03..42c6bb43a5 100644 --- a/frontend/src/__tests__/cypress/cypress/e2e/customServingRuntimes/CustomServingRuntimes.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/e2e/customServingRuntimes/CustomServingRuntimes.cy.ts @@ -6,57 +6,73 @@ import { mockStatus } from '~/__mocks__/mockStatus'; import { servingRuntimes } from '~/__tests__/cypress/cypress/pages/servingRuntimes'; import { ServingRuntimePlatform } from '~/types'; -it('Custom serving runtimes', () => { - cy.intercept('/api/status', mockStatus()); - cy.intercept('/api/config', mockDashboardConfig({})); - cy.intercept('/api/dashboardConfig/opendatahub/odh-dashboard-config', mockDashboardConfig({})); - cy.intercept( - { pathname: '/api/templates/opendatahub' }, - mockK8sResourceList([ - mockServingRuntimeTemplateK8sResource({ - name: 'template-1', - displayName: 'Multi Platform', - platforms: [ServingRuntimePlatform.SINGLE, ServingRuntimePlatform.MULTI], - }), - mockServingRuntimeTemplateK8sResource({ - name: 'template-2', - displayName: 'Caikit', - platforms: [ServingRuntimePlatform.SINGLE], - }), - mockServingRuntimeTemplateK8sResource({ - name: 'template-3', - displayName: 'OVMS', - platforms: [ServingRuntimePlatform.MULTI], - }), - mockServingRuntimeTemplateK8sResource({ - name: 'template-4', - displayName: 'Serving Runtime with No Annotations', - }), - ]), - ); - cy.intercept( - '/api/k8s/apis/project.openshift.io/v1/projects', - mockK8sResourceList([mockProjectK8sResource({})]), - ); +describe('Custom serving runtimes', () => { + beforeEach(() => { + cy.intercept('/api/status', mockStatus()); + cy.intercept('/api/config', mockDashboardConfig({})); + cy.intercept('/api/dashboardConfig/opendatahub/odh-dashboard-config', mockDashboardConfig({})); + cy.intercept( + { pathname: '/api/templates/opendatahub' }, + mockK8sResourceList([ + mockServingRuntimeTemplateK8sResource({ + name: 'template-1', + displayName: 'Multi Platform', + platforms: [ServingRuntimePlatform.SINGLE, ServingRuntimePlatform.MULTI], + }), + mockServingRuntimeTemplateK8sResource({ + name: 'template-2', + displayName: 'Caikit', + platforms: [ServingRuntimePlatform.SINGLE], + }), + mockServingRuntimeTemplateK8sResource({ + name: 'template-3', + displayName: 'OVMS', + platforms: [ServingRuntimePlatform.MULTI], + }), + mockServingRuntimeTemplateK8sResource({ + name: 'template-4', + displayName: 'Serving Runtime with No Annotations', + }), + ]), + ); + cy.intercept( + '/api/k8s/apis/project.openshift.io/v1/projects', + mockK8sResourceList([mockProjectK8sResource({})]), + ); - servingRuntimes.visit(); + servingRuntimes.visit(); + }); - // check the platform setting labels in the header - servingRuntimes.shouldBeSingleModel(true).shouldBeMultiModel(true); + it('should display platform labels', () => { + servingRuntimes.shouldBeSingleModel(true).shouldBeMultiModel(true); + }); - // check the platform labels in the table row - servingRuntimes.getRowById('template-1').shouldBeSingleModel(true).shouldBeMultiModel(true); - servingRuntimes.getRowById('template-2').shouldBeSingleModel(true).shouldBeMultiModel(false); - servingRuntimes.getRowById('template-3').shouldBeSingleModel(false).shouldBeMultiModel(true); - servingRuntimes.getRowById('template-4').shouldBeSingleModel(false).shouldBeMultiModel(true); + it('should display platform labels in table rows', () => { + servingRuntimes.getRowById('template-1').shouldBeSingleModel(true).shouldBeMultiModel(true); + servingRuntimes.getRowById('template-2').shouldBeSingleModel(true).shouldBeMultiModel(false); + servingRuntimes.getRowById('template-3').shouldBeSingleModel(false).shouldBeMultiModel(true); + servingRuntimes.getRowById('template-4').shouldBeSingleModel(false).shouldBeMultiModel(true); + }); - // Add a new serving runtime - servingRuntimes.findAddButton().click(); + it('should add a new serving runtime', () => { + servingRuntimes.findAddButton().click(); + cy.get('h1').should('contain', 'Add serving runtime'); + servingRuntimes.shouldDisplayValues([ + 'Single-model serving platform', + 'Multi-model serving platform', + 'Single-model and multi-model serving platforms', + ]); + }); - // Check the default values - servingRuntimes.shouldDisplayValues([ - 'Single-model serving platform', - 'Multi-model serving platform', - 'Single-model and multi-model serving platforms', - ]); + it('should duplicate a serving runtime', () => { + cy.get('[aria-label="Kebab toggle"]').first().click(); + cy.get('[role="menuitem"]').contains('Duplicate').click(); + cy.get('h1').should('contain', 'Duplicate serving runtime'); + }); + + it('should edit a serving runtime', () => { + cy.get('[aria-label="Kebab toggle"]').first().click(); + cy.get('[role="menuitem"]').contains('Edit').click(); + cy.get('h1').should('contain', 'Edit Multi Platform'); + }); }); diff --git a/frontend/src/pages/modelServing/customServingRuntimes/CustomServingRuntimeAddTemplate.tsx b/frontend/src/pages/modelServing/customServingRuntimes/CustomServingRuntimeAddTemplate.tsx index 3e1f5be997..aad3982952 100644 --- a/frontend/src/pages/modelServing/customServingRuntimes/CustomServingRuntimeAddTemplate.tsx +++ b/frontend/src/pages/modelServing/customServingRuntimes/CustomServingRuntimeAddTemplate.tsx @@ -106,11 +106,13 @@ const CustomServingRuntimeAddTemplate: React.FC )} - {existingTemplate ? 'Edit' : 'Add'} serving runtime + {existingTemplate ? 'Edit' : state ? 'Duplicate' : 'Add'} serving runtime } @@ -211,7 +213,7 @@ const CustomServingRuntimeAddTemplate: React.FC - {existingTemplate ? 'Update' : 'Add'} + {existingTemplate ? 'Update' : 'Create'}