@@ -32,7 +32,22 @@ describe('Space Management - Default Space', () => {
3232
3333describe ( 'Space Management - Create and Delete' , ( ) => {
3434 const createdSpaceName = 'Test Space E2E' ;
35-
35+
36+ /** Dismiss create-space modal if open (e.g. from failed previous test) */
37+ async function dismissCreateModalIfOpen ( ) {
38+ const overlay = await $ ( '[data-testid="create-space-modal-overlay"]' ) ;
39+ if ( await overlay . isDisplayed ( ) . catch ( ( ) => false ) ) {
40+ const cancelBtn = await byTestId ( 'create-space-cancel-btn' ) ;
41+ if ( await cancelBtn . isDisplayed ( ) . catch ( ( ) => false ) ) {
42+ await cancelBtn . click ( ) ;
43+ await browser . pause ( 500 ) ;
44+ } else {
45+ await browser . keys ( 'Escape' ) ;
46+ await browser . pause ( 500 ) ;
47+ }
48+ }
49+ }
50+
3651 it ( 'TC-SP-002: Create a new space' , async ( ) => {
3752 const spacesButton = await byTestId ( 'nav-spaces' ) ;
3853 await spacesButton . click ( ) ;
@@ -59,12 +74,13 @@ describe('Space Management - Create and Delete', () => {
5974 await browser . saveScreenshot ( './tests/e2e/screenshots/sp-02b-name-entered.png' ) ;
6075
6176 // Click Create Space submit button
62- const submitButton = await findElement ( 'create-space-submit-btn' , 'button=Create Space ') ;
77+ const submitButton = await byTestId ( 'create-space-submit-btn' ) ;
6378 const isSubmitDisplayed = await submitButton . isDisplayed ( ) . catch ( ( ) => false ) ;
6479
6580 console . log ( '[DEBUG] Submit button displayed:' , isSubmitDisplayed ) ;
6681
6782 if ( isSubmitDisplayed ) {
83+ await submitButton . waitForClickable ( { timeout : 5000 } ) ;
6884 await submitButton . click ( ) ;
6985 await browser . pause ( 2000 ) ;
7086 }
@@ -87,7 +103,7 @@ describe('Space Management - Create and Delete', () => {
87103 } ) ;
88104
89105 it ( 'TC-SP-003: Set a space as active' , async ( ) => {
90- // Look for Set Active button - try test ID first
106+ await dismissCreateModalIfOpen ( ) ;
91107 const setActiveButtons = await $$ ( '[data-testid^="set-active-space-"]' ) ;
92108
93109 if ( setActiveButtons . length > 0 ) {
@@ -111,6 +127,7 @@ describe('Space Management - Create and Delete', () => {
111127 } ) ;
112128
113129 it ( 'TC-SP-011: Verify spaces are listed on page' , async ( ) => {
130+ await dismissCreateModalIfOpen ( ) ;
114131 const spacesButton = await byTestId ( 'nav-spaces' ) ;
115132 await spacesButton . click ( ) ;
116133 await browser . pause ( 2000 ) ;
@@ -128,7 +145,7 @@ describe('Space Management - Create and Delete', () => {
128145 } ) ;
129146
130147 it ( 'TC-SP-005: Cleanup - Delete test space if exists' , async ( ) => {
131- // Look for delete button - try test ID first
148+ await dismissCreateModalIfOpen ( ) ;
132149 const deleteButtons = await $$ ( '[data-testid^="delete-space-"]' ) ;
133150
134151 await browser . saveScreenshot ( './tests/e2e/screenshots/sp-07-before-delete.png' ) ;
0 commit comments