@@ -19,6 +19,11 @@ export const clusterName = "imported-0";
1919export const branch = "main" ;
2020export const path = "nginx"
2121export const sshString = [ "Public key and private key for SSH" , "Public key and private key for SSH authentication" ]
22+ export const rancherVersion = Cypress . env ( 'rancher_version' )
23+ export const supported_versions_212_and_above = [
24+ / ^ ( p r i m e | p r i m e - o p t i m u s | p r i m e - o p t i m u s - a l p h a | p r i m e - a l p h a | p r i m e - r c | a l p h a ) \/ 2 \. ( 1 [ 2 - 9 ] | [ 2 - 9 ] \d + ) ( \. .* ) ? $ / ,
25+ / ^ h e a d \/ 2 \. ( 1 [ 2 - 9 ] ) $ /
26+ ] ;
2227
2328beforeEach ( ( ) => {
2429
@@ -118,6 +123,62 @@ describe('Agent Scheduling Customization', { tags: '@special_tests' }, () => {
118123 } ) ;
119124} ;
120125
126+ describe ( 'Test move cluster to newly created workspace and deploy application to it.' , { tags : '@special_tests' } , ( ) => {
127+ qase ( 51 ,
128+ it ( "Fleet-51: Test move cluster to newly created workspace and deploy application to it." , { tags : '@fleet-51' } , ( ) => {
129+ const dsFirstClusterName = 'imported-0'
130+ const repoName = 'default-cluster-new-workspace-51'
131+ const branch = "master"
132+ const path = "simple"
133+ const repoUrl = "https://github.com/rancher/fleet-examples"
134+ const flagName = "provisioningv2-fleet-workspace-back-population"
135+ const newWorkspaceName = "new-fleet-workspace"
136+ const fleetDefault = "fleet-default"
137+ let timeout = 30000
138+
139+ //Version check for 2.12 (head)
140+ if ( supported_versions_212_and_above . some ( r => r . test ( rancherVersion ) ) ) {
141+ timeout = 70000
142+ }
143+
144+ // Enable cluster can move to another Fleet workspace feature flag.
145+ cy . enableFeatureFlag ( flagName ) ;
146+
147+ // Create new workspace.
148+ cy . createNewFleetWorkspace ( newWorkspaceName ) ;
149+
150+ // Switch to 'fleet-default' workspace
151+ cy . fleetNamespaceToggle ( fleetDefault ) ;
152+ cy . clickNavMenu ( [ 'Clusters' ] ) ;
153+
154+ // Move first cluster i.e. 'imported-0' to newly created workspace.
155+ cy . moveClusterToWorkspace ( dsFirstClusterName , newWorkspaceName , timeout ) ;
156+
157+ // Create a GitRepo targeting to cluster available in newly created workspace.
158+ cy . addFleetGitRepo ( { repoName, repoUrl, branch, path } ) ;
159+ cy . fleetNamespaceToggle ( newWorkspaceName ) ;
160+ cy . clickButton ( 'Create' ) ;
161+
162+ // Review below line after all tests passed.
163+ cy . checkGitRepoStatus ( repoName , '1 / 1' , '6 / 6' ) ;
164+
165+ // Delete GitRepo
166+ // In Fleet Workspace, namespace name similarly treated as namespace.
167+ cy . deleteAllFleetRepos ( newWorkspaceName ) ;
168+
169+ // Move cluster back to 'fleet-default' workspace
170+ cy . fleetNamespaceToggle ( newWorkspaceName ) ;
171+ cy . restoreClusterToDefaultWorkspace ( dsFirstClusterName , timeout ) ;
172+
173+ // Delete the newly created workspace
174+ cy . continuousDeliveryMenuSelection ( )
175+ cy . continuousDeliveryWorkspacesMenu ( )
176+ cy . filterInSearchBox ( newWorkspaceName )
177+ cy . deleteAll ( false ) ;
178+ } )
179+ )
180+ } ) ;
181+
121182// Note: to be executed after the above test cases
122183// to avoid any interference (i.e: if continuous-delivery feature is not correctly enabled.)
123184// To be replaced into other spec file when required.
@@ -128,6 +189,8 @@ describe("Global settings related tests", { tags: '@special_tests'}, () => {
128189
129190 // Verify is gitrepoJobsCleanup is enabled by default.
130191 cy . accesMenuSelection ( 'local' , 'Workloads' , 'CronJobs' ) ;
192+ // Adding wait for CronJobs page to load correctly.
193+ cy . wait ( 5000 ) ;
131194 cy . nameSpaceMenuToggle ( 'All Namespaces' ) ;
132195 cy . verifyTableRow ( 0 , 'Active' , 'fleet-cleanup-gitrepo-jobs' ) ;
133196
@@ -138,6 +201,8 @@ describe("Global settings related tests", { tags: '@special_tests'}, () => {
138201 cy . contains ( 'Waiting for Restart' , { timeout : 180000 } ) . should ( 'not.exist' ) ;
139202 // Verify is gitrepoJobsCleanup job is not present
140203 cy . accesMenuSelection ( 'local' , 'Workloads' , 'CronJobs' ) ;
204+ // Adding wait for CronJobs page to load correctly.
205+ cy . wait ( 5000 ) ;
141206 cy . contains ( 'fleet-cleanup-gitrepo-jobs' ) . should ( 'not.exist' ) ;
142207
143208 // Re-enable continuous-delivery feature flag and wait for restart.
@@ -147,6 +212,8 @@ describe("Global settings related tests", { tags: '@special_tests'}, () => {
147212 cy . contains ( 'Waiting for Restart' , { timeout : 180000 } ) . should ( 'not.exist' ) ;
148213
149214 cy . accesMenuSelection ( 'local' , 'Workloads' , 'CronJobs' ) ;
215+ // Adding wait for CronJobs page to load correctly.
216+ cy . wait ( 5000 ) ;
150217 cy . nameSpaceMenuToggle ( 'All Namespaces' ) ;
151218 cy . filterInSearchBox ( 'fleet-cleanup-gitrepo-jobs' ) ;
152219 cy . verifyTableRow ( 0 , 'Active' , 'fleet-cleanup-gitrepo-jobs' ) ;
0 commit comments