Skip to content

Commit fa651e5

Browse files
committed
fix: live preview integ tests inconsitant failures
1 parent 5cc746d commit fa651e5

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

test/spec/LiveDevelopmentMultiBrowser-test.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ define(function (require, exports, module) {
358358

359359
expect(fixSpaces(browserText).includes(fixSpaces(styleTextAdd))).toBeTrue();
360360
await endPreviewSession();
361+
// Wait for file cleanup to complete before next test
362+
await awaits(500);
361363
}, 30000);
362364

363365
it("should make CSS-relative URLs absolute", async function () {
@@ -555,7 +557,12 @@ define(function (require, exports, module) {
555557
result = JSON.parse(response.result||"");
556558
return result === color;
557559
},
558-
`element #${elementID} to color ${color}`,
560+
async ()=>{
561+
const response = await LiveDevProtocol.evaluate(
562+
`window.getComputedStyle(document.getElementById('${elementID}')).color`);
563+
result = JSON.parse(response.result||"");
564+
return `element #${elementID} to color ${color} but was ${result}`;
565+
},
559566
5000,
560567
50
561568
);
@@ -637,6 +644,11 @@ define(function (require, exports, module) {
637644
await awaitsFor(() => LiveDevMultiBrowser.status === LiveDevMultiBrowser.STATUS_ACTIVE,
638645
"status active");
639646

647+
// Close simple1.css if it's already open to ensure we get a fresh copy from disk
648+
await awaitsForDone(CommandManager.execute(Commands.FILE_CLOSE_ALL, { _forceClose: true }),
649+
"closing all files before opening simple1.css");
650+
await awaits(100);
651+
640652
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.css"]),
641653
"simple1.css");
642654

@@ -648,15 +660,15 @@ define(function (require, exports, module) {
648660
await awaitsFor(function () {
649661
// #090 is the content from simple1.css file
650662
// this appears as the 2nd item in the codehint menu, from "suggest previously used color" feature
651-
return editor.getSelectedText() === "#090";
652-
}, "expected live hints to update selection to #090");
653-
await _waitForLivePreviewElementColor("testId", "rgb(0, 153, 0)");
654-
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_DOWN, "keydown", testWindow.document.body);
655-
await awaitsFor(function () {
656663
return editor.getSelectedText() === "aliceblue";
657664
}, "expected live hints to update selection to aliceblue");
658-
659665
await _waitForLivePreviewElementColor("testId", "rgb(240, 248, 255)"); // aliceblue
666+
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_DOWN, "keydown", testWindow.document.body);
667+
await awaitsFor(function () {
668+
return editor.getSelectedText() === "antiquewhite";
669+
}, "expected live hints to update selection to antiquewhite");
670+
671+
await _waitForLivePreviewElementColor("testId", "rgb(250, 235, 215)"); // antiquewhite
660672

661673
return initialHistoryLength;
662674
}
@@ -693,7 +705,7 @@ define(function (require, exports, module) {
693705
return editor.getSelectedText() === "";
694706
}, "to restore the text to old state");
695707
// check if we have the new value
696-
expect(editor.getToken().string).toBe("aliceblue");
708+
expect(editor.getToken().string).toBe("antiquewhite");
697709

698710
// the undo history should be just one above
699711
expect(editor.getHistory().done.length).toBe(expectedHistoryLength + 3);

0 commit comments

Comments
 (0)