1- import { WorkspaceState } from '~/shared/types' ;
21import { home } from '~/__tests__/cypress/cypress/pages/home' ;
32import {
43 mockWorkspaces ,
54 mockWorkspacesByNS ,
65} from '~/__tests__/cypress/cypress/tests/mocked/workspace.mock' ;
6+ import type { Workspace } from '~/shared/types' ;
77import { mockNamespaces } from '~/__mocks__/mockNamespaces' ;
88import { mockBFFResponse } from '~/__mocks__/utils' ;
99
1010// 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 ) => {
1212 // Validate the workspace name
1313 cy . findByTestId ( `workspace-row-${ index } ` )
1414 . find ( '[data-testid="workspace-name"]' )
1515 . should ( 'have.text' , workspace . name ) ;
1616
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-
2517 cy . findByTestId ( `workspace-row-${ index } ` )
2618 . find ( '[data-testid="pod-config"]' )
27- . should ( 'have.text' , workspace . options . podConfig ) ;
19+ . should ( 'have.text' , workspace . pod_template . pod_config . current ) ;
2820} ;
2921
3022// Test suite for workspace-related tests
3123describe ( 'Workspaces tests' , ( ) => {
3224 beforeEach ( ( ) => {
3325 home . visit ( ) ;
26+
27+ cy . intercept ( 'GET' , '/api/v1/namespaces' , {
28+ body : mockBFFResponse ( mockNamespaces ) ,
29+ } ) . as ( 'getNamespaces' ) ;
30+
3431 cy . intercept ( 'GET' , '/api/v1/workspaces' , {
3532 body : mockBFFResponse ( mockWorkspaces ) ,
3633 } ) . as ( 'getWorkspaces' ) ;
@@ -103,11 +100,18 @@ describe('Workspace by namespace functionality', () => {
103100describe ( 'Workspaces Component' , ( ) => {
104101 beforeEach ( ( ) => {
105102 // Mock the namespaces API response
103+
104+ cy . visit ( '/' ) ;
106105 cy . intercept ( 'GET' , '/api/v1/namespaces' , {
107106 body : mockBFFResponse ( mockNamespaces ) ,
108107 } ) . as ( 'getNamespaces' ) ;
109- cy . visit ( '/' ) ;
110108 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+ } ) ;
111115 } ) ;
112116
113117 function openDeleteModal ( ) {
@@ -122,6 +126,10 @@ describe('Workspaces Component', () => {
122126 ( ) => cy . get ( '[aria-label="Close"]' ) . click ( ) ,
123127 ] ;
124128
129+ // Change namespace to "kubeflow"
130+ cy . findByTestId ( 'namespace-toggle' ) . click ( ) ;
131+ cy . findByTestId ( 'dropdown-item-kubeflow' ) . click ( ) ;
132+
125133 closeModalActions . forEach ( ( closeAction ) => {
126134 openDeleteModal ( ) ;
127135 cy . findByTestId ( 'delete-modal-input' ) . type ( 'Some Text' ) ;
@@ -138,6 +146,9 @@ describe('Workspaces Component', () => {
138146 } ) ;
139147
140148 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 ( ) ;
141152 openDeleteModal ( ) ;
142153 cy . findByTestId ( 'delete-modal' ) . within ( ( ) => {
143154 cy . get ( 'strong' )
0 commit comments