@@ -4,21 +4,95 @@ import { getNotebookImageData } from '~/pages/projects/screens/detail/notebooks/
4
4
import { NotebookImageAvailability } from '~/pages/projects/screens/detail/notebooks/const' ;
5
5
6
6
describe ( 'getNotebookImageData' , ( ) => {
7
- it ( 'should return image data when image stream exists and image version exists' , ( ) => {
7
+ it ( 'should return image data when image stream exists and image version exists with internal registry ' , ( ) => {
8
8
const notebook = mockNotebookK8sResource ( {
9
9
image :
10
10
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
11
+ lastImageSelection : 'jupyter-datascience-notebook' ,
11
12
} ) ;
12
13
const images = [
13
14
mockImageStreamK8sResource ( {
14
15
imageTag :
15
16
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
17
+ name : 'jupyter-datascience-notebook' ,
16
18
} ) ,
17
19
] ;
18
20
const result = getNotebookImageData ( notebook , images ) ;
19
21
expect ( result ?. imageAvailability ) . toBe ( NotebookImageAvailability . ENABLED ) ;
20
22
} ) ;
21
23
24
+ it ( 'should return image data when image stream exists and image version exists without internal registry' , ( ) => {
25
+ const imageName = 'jupyter-datascience-notebook' ;
26
+ const tagName = '2024.1' ;
27
+ const notebook = mockNotebookK8sResource ( {
28
+ image : `image-registry.openshift-image-registry.svc:5000/opendatahub/${ imageName } :${ tagName } ` ,
29
+ lastImageSelection : 'jupyter-datascience-notebook' ,
30
+ } ) ;
31
+ const images = [
32
+ mockImageStreamK8sResource ( {
33
+ imageTag :
34
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
35
+ tagName,
36
+ name : imageName ,
37
+ } ) ,
38
+ ] ;
39
+ const result = getNotebookImageData ( notebook , images ) ;
40
+ expect ( result ?. imageAvailability ) . toBe ( NotebookImageAvailability . ENABLED ) ;
41
+ } ) ;
42
+
43
+ it ( 'should return the right image if multiple ImageStreams have the same image with internal registry' , ( ) => {
44
+ const displayName = 'Jupyter Data Science Notebook' ;
45
+ const notebook = mockNotebookK8sResource ( {
46
+ image :
47
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
48
+ lastImageSelection : 'jupyter-datascience-notebook' ,
49
+ } ) ;
50
+ const images = [
51
+ mockImageStreamK8sResource ( {
52
+ imageTag :
53
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
54
+ name : 'jupyter-datascience-notebook' ,
55
+ displayName,
56
+ } ) ,
57
+ mockImageStreamK8sResource ( {
58
+ imageTag :
59
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
60
+ name : 'custom-notebook' ,
61
+ displayName : 'Custom Notebook' ,
62
+ } ) ,
63
+ ] ;
64
+ const result = getNotebookImageData ( notebook , images ) ;
65
+ expect ( result ?. imageDisplayName ) . toBe ( displayName ) ;
66
+ } ) ;
67
+
68
+ it ( 'should return the right image if multiple ImageStreams have the same tag without internal registry' , ( ) => {
69
+ const imageName = 'jupyter-datascience-notebook' ;
70
+ const tagName = '2024.1' ;
71
+ const displayName = 'Jupyter Data Science Notebook' ;
72
+ const notebook = mockNotebookK8sResource ( {
73
+ image : `image-registry.openshift-image-registry.svc:5000/opendatahub/${ imageName } :${ tagName } ` ,
74
+ lastImageSelection : 'jupyter-datascience-notebook' ,
75
+ } ) ;
76
+ const images = [
77
+ mockImageStreamK8sResource ( {
78
+ imageTag :
79
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
80
+ tagName,
81
+ name : 'code-server' ,
82
+ displayName : 'Code Server' ,
83
+ } ) ,
84
+ mockImageStreamK8sResource ( {
85
+ imageTag :
86
+ 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75' ,
87
+ tagName,
88
+ name : imageName ,
89
+ displayName,
90
+ } ) ,
91
+ ] ;
92
+ const result = getNotebookImageData ( notebook , images ) ;
93
+ expect ( result ?. imageDisplayName ) . toBe ( displayName ) ;
94
+ } ) ;
95
+
22
96
it ( 'should return image data when image stream exists and image version does not exist' , ( ) => {
23
97
const notebook = mockNotebookK8sResource ( {
24
98
image :
0 commit comments