1
- import { WorkspaceState } from '~/shared/types' ;
2
1
import { home } from '~/__tests__/cypress/cypress/pages/home' ;
3
2
import {
4
3
mockWorkspaces ,
5
4
mockWorkspacesByNS ,
6
5
} from '~/__tests__/cypress/cypress/tests/mocked/workspace.mock' ;
6
+ import type { Workspace } from '~/shared/types' ;
7
7
import { mockNamespaces } from '~/__mocks__/mockNamespaces' ;
8
8
import { mockBFFResponse } from '~/__mocks__/utils' ;
9
9
10
10
// Helper function to validate the content of a single workspace row in the table
11
- const validateWorkspaceRow = ( workspace : any , index : number ) => {
11
+ const validateWorkspaceRow = ( workspace : Workspace , index : number ) => {
12
12
// Validate the workspace name
13
13
cy . findByTestId ( `workspace-row-${ index } ` )
14
14
. find ( '[data-testid="workspace-name"]' )
15
15
. should ( 'have.text' , workspace . name ) ;
16
16
17
- // Map workspace state to the expected label
18
- const expectedLabel = WorkspaceState [ workspace . status . state ] ;
19
-
20
- // Validate the state label and pod configuration
21
- cy . findByTestId ( `workspace-row-${ index } ` )
22
- . find ( '[data-testid="state-label"]' )
23
- . should ( 'have.text' , expectedLabel ) ;
24
-
25
17
cy . findByTestId ( `workspace-row-${ index } ` )
26
18
. find ( '[data-testid="pod-config"]' )
27
- . should ( 'have.text' , workspace . options . podConfig ) ;
19
+ . should ( 'have.text' , workspace . pod_template . pod_config . current ) ;
28
20
} ;
29
21
30
22
// Test suite for workspace-related tests
31
23
describe ( 'Workspaces tests' , ( ) => {
32
24
beforeEach ( ( ) => {
33
25
home . visit ( ) ;
26
+
27
+ cy . intercept ( 'GET' , '/api/v1/namespaces' , {
28
+ body : mockBFFResponse ( mockNamespaces ) ,
29
+ } ) . as ( 'getNamespaces' ) ;
30
+
34
31
cy . intercept ( 'GET' , '/api/v1/workspaces' , {
35
32
body : mockBFFResponse ( mockWorkspaces ) ,
36
33
} ) . as ( 'getWorkspaces' ) ;
@@ -103,11 +100,18 @@ describe('Workspace by namespace functionality', () => {
103
100
describe ( 'Workspaces Component' , ( ) => {
104
101
beforeEach ( ( ) => {
105
102
// Mock the namespaces API response
103
+
104
+ cy . visit ( '/' ) ;
106
105
cy . intercept ( 'GET' , '/api/v1/namespaces' , {
107
106
body : mockBFFResponse ( mockNamespaces ) ,
108
107
} ) . as ( 'getNamespaces' ) ;
109
- cy . visit ( '/' ) ;
110
108
cy . wait ( '@getNamespaces' ) ;
109
+ cy . intercept ( 'GET' , 'api/v1/workspaces' , {
110
+ body : mockBFFResponse ( mockWorkspaces ) ,
111
+ } ) . as ( 'getWorkspaces' ) ;
112
+ cy . intercept ( 'GET' , 'api/v1/workspaces/kubeflow' , {
113
+ body : mockBFFResponse ( mockWorkspacesByNS ) ,
114
+ } ) ;
111
115
} ) ;
112
116
113
117
function openDeleteModal ( ) {
@@ -122,6 +126,10 @@ describe('Workspaces Component', () => {
122
126
( ) => cy . get ( '[aria-label="Close"]' ) . click ( ) ,
123
127
] ;
124
128
129
+ // Change namespace to "kubeflow"
130
+ cy . findByTestId ( 'namespace-toggle' ) . click ( ) ;
131
+ cy . findByTestId ( 'dropdown-item-kubeflow' ) . click ( ) ;
132
+
125
133
closeModalActions . forEach ( ( closeAction ) => {
126
134
openDeleteModal ( ) ;
127
135
cy . findByTestId ( 'delete-modal-input' ) . type ( 'Some Text' ) ;
@@ -138,6 +146,9 @@ describe('Workspaces Component', () => {
138
146
} ) ;
139
147
140
148
it ( 'should verify the delete modal verification mechanism' , ( ) => {
149
+ // Change namespace to "kubeflow"
150
+ cy . findByTestId ( 'namespace-toggle' ) . click ( ) ;
151
+ cy . findByTestId ( 'dropdown-item-kubeflow' ) . click ( ) ;
141
152
openDeleteModal ( ) ;
142
153
cy . findByTestId ( 'delete-modal' ) . within ( ( ) => {
143
154
cy . get ( 'strong' )
0 commit comments