@@ -1975,7 +1975,6 @@ define(function (require, exports, module) {
1975
1975
LiveDevMultiBrowser . updateConfig ( JSON . stringify ( LiveDevMultiBrowser . config ) ) ;
1976
1976
}
1977
1977
}
1978
- await awaits ( 500 ) ;
1979
1978
}
1980
1979
1981
1980
async function switchToEditMode ( ) {
@@ -1985,7 +1984,6 @@ define(function (require, exports, module) {
1985
1984
LiveDevMultiBrowser . updateConfig ( JSON . stringify ( LiveDevMultiBrowser . config ) ) ;
1986
1985
}
1987
1986
}
1988
- await awaits ( 500 ) ;
1989
1987
}
1990
1988
1991
1989
it ( "should show info box on hover when elemHighlights is 'hover'" , async function ( ) {
@@ -2179,10 +2177,12 @@ define(function (require, exports, module) {
2179
2177
}
2180
2178
` ) ;
2181
2179
2182
- // Wait for the operation to complete
2183
- await awaits ( 1000 ) ;
2184
-
2185
2180
// 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
+
2186
2186
const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
2187
2187
expect ( updatedContent ) . not . toContain ( 'id="testId"' ) ;
2188
2188
expect ( updatedContent . length ) . toBeLessThan ( originalContent . length ) ;
@@ -2232,7 +2232,11 @@ define(function (require, exports, module) {
2232
2232
` ) ;
2233
2233
2234
2234
// 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" ) ;
2236
2240
2237
2241
// Verify the element is duplicated in source code
2238
2242
const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2280,8 +2284,10 @@ define(function (require, exports, module) {
2280
2284
element.dispatchEvent(event);
2281
2285
` ) ;
2282
2286
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
+ } ) ;
2285
2291
2286
2292
// Verify element is in edit mode (contenteditable)
2287
2293
await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
@@ -2308,7 +2314,10 @@ define(function (require, exports, module) {
2308
2314
` ) ;
2309
2315
2310
2316
// 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" ) ;
2312
2321
2313
2322
// Verify the text is updated in source code
2314
2323
const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2360,7 +2369,9 @@ define(function (require, exports, module) {
2360
2369
` ) ;
2361
2370
2362
2371
// Wait for edit mode to activate
2363
- await awaits ( 500 ) ;
2372
+ await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
2373
+ return result === true ;
2374
+ } ) ;
2364
2375
2365
2376
// Verify element is in edit mode
2366
2377
await forRemoteExec ( `document.getElementById('testId').hasAttribute('contenteditable')` , ( result ) => {
@@ -2386,7 +2397,10 @@ define(function (require, exports, module) {
2386
2397
` ) ;
2387
2398
2388
2399
// 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" ) ;
2390
2404
2391
2405
// Verify changes in source code
2392
2406
const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2425,8 +2439,6 @@ define(function (require, exports, module) {
2425
2439
element.dispatchEvent(event);
2426
2440
` ) ;
2427
2441
2428
- await awaits ( 500 ) ;
2429
-
2430
2442
// Modify the text content
2431
2443
await forRemoteExec ( `
2432
2444
const element = document.getElementById('testId');
@@ -2446,7 +2458,10 @@ define(function (require, exports, module) {
2446
2458
` ) ;
2447
2459
2448
2460
// 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" ) ;
2450
2465
2451
2466
// Verify source code is unchanged (edit was cancelled)
2452
2467
const finalContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2490,8 +2505,6 @@ define(function (require, exports, module) {
2490
2505
element.dispatchEvent(event);
2491
2506
` ) ;
2492
2507
2493
- await awaits ( 500 ) ;
2494
-
2495
2508
// Modify the text content
2496
2509
await forRemoteExec ( `
2497
2510
const element = document.getElementById('testId');
@@ -2505,7 +2518,10 @@ define(function (require, exports, module) {
2505
2518
` ) ;
2506
2519
2507
2520
// 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" ) ;
2509
2525
2510
2526
// Verify changes were saved in source code
2511
2527
const updatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2561,7 +2577,10 @@ define(function (require, exports, module) {
2561
2577
` ) ;
2562
2578
2563
2579
// 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" ) ;
2565
2584
2566
2585
// Verify the element is removed from source code
2567
2586
const deletedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2586,7 +2605,10 @@ define(function (require, exports, module) {
2586
2605
` ) ;
2587
2606
2588
2607
// 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" ) ;
2590
2612
2591
2613
// Verify the element is restored in source code
2592
2614
const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2643,7 +2665,11 @@ define(function (require, exports, module) {
2643
2665
` ) ;
2644
2666
2645
2667
// 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" ) ;
2647
2673
2648
2674
// Verify the element is duplicated in source code
2649
2675
const duplicatedContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2669,7 +2695,11 @@ define(function (require, exports, module) {
2669
2695
` ) ;
2670
2696
2671
2697
// 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" ) ;
2673
2703
2674
2704
// Verify the duplicate is removed and we're back to original state
2675
2705
const restoredContent = DocumentManager . getCurrentDocument ( ) . getText ( ) ;
@@ -2743,7 +2773,6 @@ define(function (require, exports, module) {
2743
2773
2744
2774
// Step 5: Verify clicking element in preview mode doesn't show boxes
2745
2775
await forRemoteExec ( `document.getElementById('testId').click()` ) ;
2746
- await awaits ( 300 ) ; // Brief wait to ensure no boxes appear
2747
2776
await waitForMoreOptionsBox ( false ) ;
2748
2777
await waitForClickedElement ( false ) ;
2749
2778
@@ -2775,21 +2804,18 @@ define(function (require, exports, module) {
2775
2804
2776
2805
// Step 3: Click the preview (play icon) button in the toolbar
2777
2806
testWindow . $ ( "#previewModeLivePreviewButton" ) . click ( ) ;
2778
- await awaits ( 1000 ) ; // Wait for mode switch and preference update
2779
2807
2780
2808
// Step 4: Verify boxes are hidden after clicking preview button
2781
2809
await waitForMoreOptionsBox ( false ) ;
2782
2810
await waitForClickedElement ( false ) ;
2783
2811
2784
2812
// Step 5: Verify clicking element in preview mode doesn't show boxes
2785
2813
await forRemoteExec ( `document.getElementById('testId').click()` ) ;
2786
- await awaits ( 300 ) ;
2787
2814
await waitForMoreOptionsBox ( false ) ;
2788
2815
await waitForClickedElement ( false ) ;
2789
2816
2790
2817
// Step 6: Click preview button again to toggle back to edit mode
2791
2818
testWindow . $ ( "#previewModeLivePreviewButton" ) . click ( ) ;
2792
- await awaits ( 1000 ) ; // Wait for mode switch and preference update
2793
2819
2794
2820
// Step 7: Click element to verify boxes work again in edit mode
2795
2821
await forRemoteExec ( `document.getElementById('testId').click()` ) ;
0 commit comments