@@ -1975,7 +1975,6 @@ define(function (require, exports, module) {
19751975 LiveDevMultiBrowser . updateConfig ( JSON . stringify ( LiveDevMultiBrowser . config ) ) ;
19761976 }
19771977 }
1978- await awaits ( 500 ) ;
19791978 }
19801979
19811980 async function switchToEditMode ( ) {
@@ -1985,7 +1984,6 @@ define(function (require, exports, module) {
19851984 LiveDevMultiBrowser . updateConfig ( JSON . stringify ( LiveDevMultiBrowser . config ) ) ;
19861985 }
19871986 }
1988- await awaits ( 500 ) ;
19891987 }
19901988
19911989 it ( "should show info box on hover when elemHighlights is 'hover'" , async function ( ) {
@@ -2179,10 +2177,12 @@ define(function (require, exports, module) {
21792177 }
21802178 ` ) ;
21812179
2182- // Wait for the operation to complete
2183- await awaits ( 1000 ) ;
2184-
21852180 // Verify the element is removed from source code
2181+ await awaitsFor ( function ( ) {
2182+ const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2183+ return ! updatedContent . includes ( 'id="testId"' ) ;
2184+ } , "element to be removed from source code" ) ;
2185+
21862186 const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
21872187 expect ( updatedContent ) . not . toContain ( 'id="testId"' ) ;
21882188 expect ( updatedContent . length ) . toBeLessThan ( originalContent . length ) ;
@@ -2232,7 +2232,11 @@ define(function (require, exports, module) {
22322232 ` ) ;
22332233
22342234 // Wait for the operation to complete
2235- await awaits ( 1000 ) ;
2235+ await awaitsFor ( function ( ) {
2236+ const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2237+ const newTestIdCount = ( updatedContent . match ( / i d = " t e s t I d " / g) || [ ] ) . length ;
2238+ return newTestIdCount === 2 ;
2239+ } , "element to be duplicated in source code" ) ;
22362240
22372241 // Verify the element is duplicated in source code
22382242 const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2280,8 +2284,10 @@ define(function (require, exports, module) {
22802284 element.dispatchEvent(event);
22812285 ` ) ;
22822286
2283- // Wait a moment for edit mode to activate
2284- await awaits ( 500 ) ;
2287+ // Wait for edit mode to activate
2288+ await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
2289+ return result === true ;
2290+ } ) ;
22852291
22862292 // Verify element is in edit mode (contenteditable)
22872293 await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
@@ -2308,7 +2314,10 @@ define(function (require, exports, module) {
23082314 ` ) ;
23092315
23102316 // Wait for the operation to complete
2311- await awaits ( 1000 ) ;
2317+ await awaitsFor ( function ( ) {
2318+ const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2319+ return updatedContent . includes ( newText ) ;
2320+ } , "text to be updated in source code" ) ;
23122321
23132322 // Verify the text is updated in source code
23142323 const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2360,7 +2369,9 @@ define(function (require, exports, module) {
23602369 ` ) ;
23612370
23622371 // Wait for edit mode to activate
2363- await awaits ( 500 ) ;
2372+ await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
2373+ return result === true ;
2374+ } ) ;
23642375
23652376 // Verify element is in edit mode
23662377 await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
@@ -2386,7 +2397,10 @@ define(function (require, exports, module) {
23862397 ` ) ;
23872398
23882399 // Wait for operation to complete
2389- await awaits ( 1000 ) ;
2400+ await awaitsFor ( function ( ) {
2401+ const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2402+ return updatedContent . includes ( newText ) ;
2403+ } , "text changes to be saved in source code" ) ;
23902404
23912405 // Verify changes in source code
23922406 const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2425,8 +2439,6 @@ define(function (require, exports, module) {
24252439 element.dispatchEvent(event);
24262440 ` ) ;
24272441
2428- await awaits ( 500 ) ;
2429-
24302442 // Modify the text content
24312443 await forRemoteExec ( `
24322444 const element = document.getElementById('testId');
@@ -2446,7 +2458,10 @@ define(function (require, exports, module) {
24462458 ` ) ;
24472459
24482460 // Wait for operation to complete
2449- await awaits ( 1000 ) ;
2461+ await awaitsFor ( function ( ) {
2462+ const finalContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2463+ return finalContent === originalContent ;
2464+ } , "edit to be cancelled and source unchanged" ) ;
24502465
24512466 // Verify source code is unchanged (edit was cancelled)
24522467 const finalContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2490,8 +2505,6 @@ define(function (require, exports, module) {
24902505 element.dispatchEvent(event);
24912506 ` ) ;
24922507
2493- await awaits ( 500 ) ;
2494-
24952508 // Modify the text content
24962509 await forRemoteExec ( `
24972510 const element = document.getElementById('testId');
@@ -2505,7 +2518,10 @@ define(function (require, exports, module) {
25052518 ` ) ;
25062519
25072520 // Wait for operation to complete
2508- await awaits ( 1000 ) ;
2521+ await awaitsFor ( function ( ) {
2522+ const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2523+ return updatedContent . includes ( newText ) ;
2524+ } , "blur event to save changes to source code" ) ;
25092525
25102526 // Verify changes were saved in source code
25112527 const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2561,7 +2577,10 @@ define(function (require, exports, module) {
25612577 ` ) ;
25622578
25632579 // Wait for the delete operation to complete
2564- await awaits ( 1000 ) ;
2580+ await awaitsFor ( function ( ) {
2581+ const deletedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2582+ return ! deletedContent . includes ( 'id="testId"' ) ;
2583+ } , "delete operation to complete" ) ;
25652584
25662585 // Verify the element is removed from source code
25672586 const deletedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2586,7 +2605,10 @@ define(function (require, exports, module) {
25862605 ` ) ;
25872606
25882607 // Wait for the undo operation to complete
2589- await awaits ( 1500 ) ;
2608+ await awaitsFor ( function ( ) {
2609+ const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2610+ return restoredContent . includes ( 'id="testId"' ) ;
2611+ } , "undo operation to restore deleted element" ) ;
25902612
25912613 // Verify the element is restored in source code
25922614 const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2643,7 +2665,11 @@ define(function (require, exports, module) {
26432665 ` ) ;
26442666
26452667 // Wait for the duplicate operation to complete
2646- await awaits ( 1000 ) ;
2668+ await awaitsFor ( function ( ) {
2669+ const duplicatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2670+ const newTestIdCount = ( duplicatedContent . match ( / i d = " t e s t I d " / g) || [ ] ) . length ;
2671+ return newTestIdCount === 2 ;
2672+ } , "duplicate operation to complete" ) ;
26472673
26482674 // Verify the element is duplicated in source code
26492675 const duplicatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2669,7 +2695,11 @@ define(function (require, exports, module) {
26692695 ` ) ;
26702696
26712697 // Wait for the undo operation to complete
2672- await awaits ( 1500 ) ;
2698+ await awaitsFor ( function ( ) {
2699+ const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2700+ const restoredTestIdCount = ( restoredContent . match ( / i d = " t e s t I d " / g) || [ ] ) . length ;
2701+ return restoredTestIdCount === 1 ;
2702+ } , "undo operation to remove duplicate" ) ;
26732703
26742704 // Verify the duplicate is removed and we're back to original state
26752705 const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2743,7 +2773,6 @@ define(function (require, exports, module) {
27432773
27442774 // Step 5: Verify clicking element in preview mode doesn't show boxes
27452775 await forRemoteExec ( `document.getElementById('testId').click()` ) ;
2746- await awaits ( 300 ) ; // Brief wait to ensure no boxes appear
27472776 await waitForMoreOptionsBox ( false ) ;
27482777 await waitForClickedElement ( false ) ;
27492778
@@ -2775,21 +2804,18 @@ define(function (require, exports, module) {
27752804
27762805 // Step 3: Click the preview (play icon) button in the toolbar
27772806 testWindow . $ ( "#previewModeLivePreviewButton" ) . click ( ) ;
2778- await awaits ( 1000 ) ; // Wait for mode switch and preference update
27792807
27802808 // Step 4: Verify boxes are hidden after clicking preview button
27812809 await waitForMoreOptionsBox ( false ) ;
27822810 await waitForClickedElement ( false ) ;
27832811
27842812 // Step 5: Verify clicking element in preview mode doesn't show boxes
27852813 await forRemoteExec ( `document.getElementById('testId').click()` ) ;
2786- await awaits ( 300 ) ;
27872814 await waitForMoreOptionsBox ( false ) ;
27882815 await waitForClickedElement ( false ) ;
27892816
27902817 // Step 6: Click preview button again to toggle back to edit mode
27912818 testWindow . $ ( "#previewModeLivePreviewButton" ) . click ( ) ;
2792- await awaits ( 1000 ) ; // Wait for mode switch and preference update
27932819
27942820 // Step 7: Click element to verify boxes work again in edit mode
27952821 await forRemoteExec ( `document.getElementById('testId').click()` ) ;
0 commit comments