Skip to content

Commit c71a098

Browse files
committed
fix: live preview integ tests remove await timeout in favor of conditional wait
1 parent fa651e5 commit c71a098

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/spec/LiveDevelopmentMultiBrowser-test.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ 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);
363361
}, 30000);
364362

365363
it("should make CSS-relative URLs absolute", async function () {
@@ -644,13 +642,21 @@ define(function (require, exports, module) {
644642
await awaitsFor(() => LiveDevMultiBrowser.status === LiveDevMultiBrowser.STATUS_ACTIVE,
645643
"status active");
646644

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-
652-
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.css"]),
653-
"simple1.css");
645+
// Ensure we get a clean copy of simple1.css from disk, not a modified cached version
646+
// from previous tests. We verify the file doesn't contain #090 background-color.
647+
// in linux, or if system slow, it will take some time for file system change event to catch
648+
// up and update document. so we need to do this below.
649+
await awaitsFor(async function () {
650+
await awaitsForDone(CommandManager.execute(Commands.FILE_CLOSE_ALL, { _forceClose: true }),
651+
"closing all files before opening simple1.css");
652+
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.css"]),
653+
"simple1.css");
654+
const doc = DocumentManager.getCurrentDocument();
655+
const text = doc.getText();
656+
// The original simple1.css should NOT contain background-color:#090
657+
// That gets added by a previous test and must be cleaned up
658+
return !text.includes("background-color:#090");
659+
}, "simple1.css to be in clean state without background-color:#090", 5000);
654660

655661
await _openCodeHints({ line: 3, ch: 8 }, ["antiquewhite"]);
656662

0 commit comments

Comments
 (0)