Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to duplicate a serving runtime #2339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ const CustomServingRuntimeAddTemplate: React.FC<CustomServingRuntimeAddTemplateP
title={
existingTemplate
? `Edit ${getServingRuntimeDisplayNameFromTemplate(existingTemplate)}`
: 'Add serving runtime'
: `${state ? 'Duplicate' : 'Add'} serving runtime`
}
description={
existingTemplate
? 'Modify properties for your serving runtime.'
: state
? 'Add a new, editable runtime by duplicating an existing runtime.'
: 'Add a new runtime that will be available for users on this cluster.'
}
breadcrumb={
Expand All @@ -123,7 +125,7 @@ const CustomServingRuntimeAddTemplate: React.FC<CustomServingRuntimeAddTemplateP
</BreadcrumbItem>
)}
<BreadcrumbItem isActive>
{existingTemplate ? 'Edit' : 'Add'} serving runtime
{existingTemplate ? 'Edit' : state ? 'Duplicate' : 'Add'} serving runtime
</BreadcrumbItem>
</Breadcrumb>
}
Expand Down Expand Up @@ -211,7 +213,7 @@ const CustomServingRuntimeAddTemplate: React.FC<CustomServingRuntimeAddTemplateP
});
}}
>
{existingTemplate ? 'Update' : 'Add'}
{existingTemplate ? 'Update' : 'Create'}
</Button>
<Button
isDisabled={loading}
Expand Down
Loading