Skip to content

Commit 5e35346

Browse files
committed
added cypress test
1 parent feda059 commit 5e35346

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

frontend/src/__mocks__/mockServingRuntimeK8sResource.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type MockResourceConfigType = {
2424
acceleratorProfileNamespace?: string;
2525
isNonDashboardItem?: boolean;
2626
version?: string;
27+
templateName?: string;
2728
};
2829

2930
export const mockServingRuntimeK8sResourceLegacy = ({
@@ -136,6 +137,7 @@ export const mockServingRuntimeK8sResource = ({
136137
hardwareProfileNamespace = undefined,
137138
isNonDashboardItem = false,
138139
version,
140+
templateName = 'ovms',
139141
}: MockResourceConfigType): ServingRuntimeKind => ({
140142
apiVersion: 'serving.kserve.io/v1alpha1',
141143
kind: 'ServingRuntime',
@@ -150,7 +152,7 @@ export const mockServingRuntimeK8sResource = ({
150152
'opendatahub.io/accelerator-name': acceleratorName,
151153
'opendatahub.io/hardware-profile-name': hardwareProfileName,
152154

153-
'opendatahub.io/template-name': 'ovms',
155+
'opendatahub.io/template-name': templateName,
154156
'openshift.io/display-name': displayName,
155157
'opendatahub.io/apiProtocol': apiProtocol,
156158
...(version && {

frontend/src/__tests__/cypress/cypress/pages/modelServing.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ class ModelServingGlobal {
112112
findServingRuntimeVersionLabel() {
113113
return cy.findByTestId('serving-runtime-version-label');
114114
}
115+
116+
findServingRuntimeVersionStatusLabel() {
117+
return cy.findByTestId('serving-runtime-version-status-label');
118+
}
115119
}
116120

117121
class ServingRuntimeGroup extends Contextual<HTMLElement> {}
@@ -615,6 +619,14 @@ class KServeRow extends ModelMeshRow {
615619
}
616620

617621
class InferenceServiceRow extends TableRow {
622+
findServingRuntimeVersionLabel() {
623+
return this.find().findByTestId('serving-runtime-version-label');
624+
}
625+
626+
findServingRuntimeVersionStatusLabel() {
627+
return this.find().findByTestId('serving-runtime-version-status-label');
628+
}
629+
618630
findStatusTooltip() {
619631
return this.find()
620632
.findByTestId('status-tooltip')

frontend/src/__tests__/cypress/cypress/tests/mocked/modelServing/modelServingGlobal.cy.ts

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ import {
2828
ServingRuntimeModel,
2929
TemplateModel,
3030
} from '#~/__tests__/cypress/cypress/utils/models';
31-
import { DeploymentMode, type InferenceServiceKind, type ServingRuntimeKind } from '#~/k8sTypes';
31+
import {
32+
DeploymentMode,
33+
type TemplateKind,
34+
type InferenceServiceKind,
35+
type ServingRuntimeKind,
36+
} from '#~/k8sTypes';
3237
import { ServingRuntimePlatform } from '#~/types';
3338
import { be } from '#~/__tests__/cypress/cypress/utils/should';
3439
import { asClusterAdminUser } from '#~/__tests__/cypress/cypress/utils/mockUsers';
@@ -63,6 +68,7 @@ type HandlersProps = {
6368
disableServingRuntimeParamsConfig?: boolean;
6469
disableProjectScoped?: boolean;
6570
disableHardwareProfiles?: boolean;
71+
servingRuntimesTemplates?: TemplateKind[];
6672
};
6773

6874
const initIntercepts = ({
@@ -948,18 +954,45 @@ describe('Model Serving Global', () => {
948954
cy.findByTestId('app-page-title').should('have.text', 'Test Inference Service metrics');
949955
});
950956
it('Display the version label if the annotation is present', () => {
951-
const servingRuntimeWithVersion = mockServingRuntimeK8sResource({});
952-
servingRuntimeWithVersion.metadata.annotations =
953-
servingRuntimeWithVersion.metadata.annotations || {};
954-
servingRuntimeWithVersion.metadata.annotations['opendatahub.io/runtime-version'] = '1.2.3';
957+
const servingRuntimeWithLatestVersion = mockServingRuntimeK8sResource({
958+
namespace: 'test-project',
959+
name: 'test-inference-service-latest',
960+
templateName: 'template-2',
961+
version: '1.0.0',
962+
});
963+
const servingRuntimeWithOutdatedVersion = mockServingRuntimeK8sResource({
964+
namespace: 'test-project',
965+
name: 'test-inference-service-outdated',
966+
templateName: 'template-2',
967+
version: '0.5.0',
968+
});
969+
const inferenceServiceLatest = mockInferenceServiceK8sResource({
970+
name: 'test-inference-service-latest',
971+
namespace: 'test-project',
972+
displayName: 'Latest Model',
973+
modelName: 'test-inference-service-latest',
974+
});
975+
const inferenceServiceOutdated = mockInferenceServiceK8sResource({
976+
name: 'test-inference-service-outdated',
977+
namespace: 'test-project',
978+
displayName: 'Outdated Model',
979+
modelName: 'test-inference-service-outdated',
980+
});
955981

956982
initIntercepts({
957-
servingRuntimes: [servingRuntimeWithVersion],
983+
servingRuntimes: [servingRuntimeWithLatestVersion, servingRuntimeWithOutdatedVersion],
984+
inferenceServices: [inferenceServiceLatest, inferenceServiceOutdated],
958985
});
959986

960-
modelServingGlobal.visit();
961-
modelServingGlobal.findServingRuntimeVersionLabel().should('exist');
962-
modelServingGlobal.findServingRuntimeVersionLabel().should('contain.text', '1.2.3');
987+
modelServingGlobal.visit('test-project');
988+
989+
const latestRow = modelServingSection.getInferenceServiceRow('Latest Model');
990+
latestRow.findServingRuntimeVersionLabel().should('contain.text', '1.0.0');
991+
latestRow.findServingRuntimeVersionStatusLabel().should('have.text', 'Latest');
992+
993+
const outdatedRow = modelServingSection.getInferenceServiceRow('Outdated Model');
994+
outdatedRow.findServingRuntimeVersionLabel().should('contain.text', '0.5.0');
995+
outdatedRow.findServingRuntimeVersionStatusLabel().should('have.text', 'Outdated');
963996
});
964997

965998
it('Not display the version label if the annotation is absent', () => {
@@ -969,8 +1002,15 @@ describe('Model Serving Global', () => {
9691002
servingRuntimes: [servingRuntimeWithoutVersion],
9701003
});
9711004

972-
modelServingGlobal.visit();
973-
modelServingGlobal.findServingRuntimeVersionLabel().should('not.exist');
1005+
modelServingGlobal.visit('test-project');
1006+
modelServingSection
1007+
.getInferenceServiceRow('Test Inference Service')
1008+
.findServingRuntimeVersionLabel()
1009+
.should('not.exist');
1010+
modelServingSection
1011+
.getInferenceServiceRow('Test Inference Service')
1012+
.findServingRuntimeVersionStatusLabel()
1013+
.should('not.exist');
9741014
});
9751015

9761016
it('Should display env vars from a valueFrom secret', () => {

frontend/src/pages/modelServing/screens/ServingRuntimeVersionStatus.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const ServingRuntimeVersionStatus: React.FC<ServingRuntimeVersionStatusProps> =
5555
bodyContent={body}
5656
>
5757
<Label
58+
data-testid="serving-runtime-version-status-label"
5859
color={isOutdated ? 'yellow' : 'green'}
5960
icon={isOutdated ? <ExclamationTriangleIcon /> : <CheckCircleIcon />}
6061
isCompact

0 commit comments

Comments
 (0)