@@ -43,6 +43,10 @@ testAgainstRunningApps({
4343 await u . po . apiKeys . selectExpiration ( '1d' ) ;
4444 await u . po . apiKeys . clickSaveButton ( ) ;
4545
46+ // Close copy modal
47+ await u . po . apiKeys . waitForCopyModalOpened ( ) ;
48+ await u . po . apiKeys . clickCopyAndCloseButton ( ) ;
49+ await u . po . apiKeys . waitForCopyModalClosed ( ) ;
4650 await u . po . apiKeys . waitForFormClosed ( ) ;
4751
4852 // Create API key 2
@@ -52,8 +56,14 @@ testAgainstRunningApps({
5256 await u . po . apiKeys . selectExpiration ( '7d' ) ;
5357 await u . po . apiKeys . clickSaveButton ( ) ;
5458
59+ // Wait and close copy modal
60+ await u . po . apiKeys . waitForCopyModalOpened ( ) ;
61+ await u . po . apiKeys . clickCopyAndCloseButton ( ) ;
62+ await u . po . apiKeys . waitForCopyModalClosed ( ) ;
63+ await u . po . apiKeys . waitForFormClosed ( ) ;
64+
5565 // Check if both API keys are created
56- await expect ( u . page . locator ( '.cl-apiKeysTable .cl-tableRow' ) ) . toHaveCount ( 2 ) ;
66+ await expect ( u . page . locator ( '.cl-apiKeysTable .cl-tableBody .cl- tableRow' ) ) . toHaveCount ( 2 ) ;
5767 } ) ;
5868
5969 test ( 'can revoke api keys' , async ( { page, context } ) => {
@@ -74,6 +84,11 @@ testAgainstRunningApps({
7484 await u . po . apiKeys . typeName ( apiKeyName ) ;
7585 await u . po . apiKeys . selectExpiration ( '1d' ) ;
7686 await u . po . apiKeys . clickSaveButton ( ) ;
87+
88+ // Wait and close copy modal
89+ await u . po . apiKeys . waitForCopyModalOpened ( ) ;
90+ await u . po . apiKeys . clickCopyAndCloseButton ( ) ;
91+ await u . po . apiKeys . waitForCopyModalClosed ( ) ;
7792 await u . po . apiKeys . waitForFormClosed ( ) ;
7893
7994 // Retrieve API key
@@ -109,39 +124,27 @@ testAgainstRunningApps({
109124
110125 const apiKeyName = `${ fakeAdmin . firstName } -${ Date . now ( ) } ` ;
111126
112- // Wait for create API response to get the secret
127+ // Create API key and capture the secret from the response
113128 const createResponsePromise = page . waitForResponse (
114129 response => response . url ( ) . includes ( '/api_keys' ) && response . request ( ) . method ( ) === 'POST' ,
115130 ) ;
116-
117- // Create API key
118131 await u . po . apiKeys . clickAddButton ( ) ;
119132 await u . po . apiKeys . waitForFormOpened ( ) ;
120133 await u . po . apiKeys . typeName ( apiKeyName ) ;
121134 await u . po . apiKeys . selectExpiration ( '1d' ) ;
122135 await u . po . apiKeys . clickSaveButton ( ) ;
123136
124- // Get the secret from the create response
125137 const createResponse = await createResponsePromise ;
126- const apiKeyData = await createResponse . json ( ) ;
127- const secret = apiKeyData . secret ;
138+ const secret = ( await createResponse . json ( ) ) . secret ;
128139
129- // Wait for the copy modal to appear
130- const copyModal = page . locator ( '.cl-apiKeysCopyModal' ) ;
131- await copyModal . waitFor ( { state : 'attached' } ) ;
132-
133- // Grant clipboard permissions before clicking the button
140+ // Copy secret via modal and verify clipboard contents
141+ // Wait and close copy modal
142+ await u . po . apiKeys . waitForCopyModalOpened ( ) ;
134143 await context . grantPermissions ( [ 'clipboard-read' ] ) ;
144+ await u . po . apiKeys . clickCopyAndCloseButton ( ) ;
145+ await u . po . apiKeys . waitForCopyModalClosed ( ) ;
146+ await u . po . apiKeys . waitForFormClosed ( ) ;
135147
136- // Click "Copy & Close" button which will copy the secret and close the modal
137- const copyAndCloseButton = copyModal . locator ( '.cl-apiKeysCopyModalSubmitButton' ) ;
138- await copyAndCloseButton . waitFor ( { state : 'attached' } ) ;
139- await copyAndCloseButton . click ( ) ;
140-
141- // Wait for modal to close
142- await copyModal . waitFor ( { state : 'detached' } ) ;
143-
144- // Read clipboard contents to verify the secret was copied
145148 const clipboardText = await page . evaluate ( 'navigator.clipboard.readText()' ) ;
146149 await context . clearPermissions ( ) ;
147150 expect ( clipboardText ) . toBe ( secret ) ;
0 commit comments