Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/test-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ jobs:
- name: Run Unit Tests
run: |
cd frontend
npm run test:prod
npm run test:jest
96 changes: 96 additions & 0 deletions frontend/__mocks__/kubeflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Mock for Kubeflow imports used in getK8sObjectUiStatus function
export enum STATUS_TYPE {
UNINITIALIZED = "Uninitialized",
TERMINATING = "Terminating",
WARNING = "Warning",
READY = "Ready",
}

// Interface for Kubernetes condition
export interface Condition {
type: string;
status: string;
reason?: string;
message?: string;
}

// Interface for status object
export interface Status {
phase: STATUS_TYPE;
state: string;
message: string;
}

// Interface for Kubernetes object
export interface K8sObject {
kind: string;
metadata: {
name?: string;
namespace?: string;
deletionTimestamp?: string;
[key: string]: any;
};
status?: {
conditions?: Condition[] | null;
[key: string]: any;
};
spec?: any;
}

// Types for getPredictorExtensionSpec tests
export enum PredictorType {
Tensorflow = 'tensorflow',
Triton = 'triton',
Sklearn = 'sklearn',
Onnx = 'onnx',
Pytorch = 'pytorch',
Xgboost = 'xgboost',
Pmml = 'pmml',
Lightgbm = 'lightgbm',
MLFlow = 'mlflow',
Custom = 'custom',
}

export interface PredictorExtensionSpec {
storageUri?: string;
runtimeVersion?: string;
protocolVersion?: string;
image?: string;
name?: string;
env?: Array<{
name: string;
value: string;
}>;
[key: string]: any;
}

export interface ModelSpec extends PredictorExtensionSpec {
modelFormat: {
name: string;
version?: string;
};
runtime?: string;
}

export interface PredictorSpec {
sklearn?: PredictorExtensionSpec;
xgboost?: PredictorExtensionSpec;
tensorflow?: PredictorExtensionSpec;
pytorch?: PredictorExtensionSpec;
triton?: PredictorExtensionSpec;
onnx?: PredictorExtensionSpec;
pmml?: PredictorExtensionSpec;
lightgbm?: PredictorExtensionSpec;
mlflow?: PredictorExtensionSpec;
model?: ModelSpec;
containers?: Array<{
name?: string;
image?: string;
env?: Array<{
name: string;
value: string;
}>;
[key: string]: any;
}>;
[key: string]: any;
}
28 changes: 28 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
preset: "jest-preset-angular",
setupFilesAfterEnv: ["<rootDir>/src/test-setup.jest.ts"],
testMatch: ["**/*.jest.spec.ts"],
collectCoverageFrom: [
"src/**/*.ts",
"!src/**/*.spec.ts",
"!src/**/*.jest.spec.ts",
"!src/main.ts",
"!src/polyfills.ts",
],
coverageDirectory: "coverage-jest",
testEnvironment: "jsdom",
moduleNameMapper: {
"^kubeflow$": "<rootDir>/__mocks__/kubeflow.ts",
"^src/(.*)$": "<rootDir>/src/$1",
"^@/(.*)$": "<rootDir>/src/$1",
},
moduleFileExtensions: ["ts", "tsx", "js", "json"],
transform: {
"^.+\\.(ts|js|html)$": "jest-preset-angular",
},
transformIgnorePatterns: [
"node_modules/(?!(kubeflow|@angular|rxjs|lodash-es)/)",
],
roots: ["<rootDir>/src"],
modulePaths: ["<rootDir>/src"],
};
Loading