Skip to content

Commit 17b31d1

Browse files
committed
test: custom server live preview banner integ test
1 parent df4d1f7 commit 17b31d1

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ define(function (require, exports, module) {
576576

577577
async function _projectOpened(_evt) {
578578
customLivePreviewBannerShown = false;
579+
$panel.find(".live-preview-custom-banner").addClass("forced-hidden");
579580
_openReadmeMDIfFirstTime();
580581
_customServerMetrics();
581582
if(!LiveDevelopment.isActive()

test/spec/LiveDevelopmentCustomServer-test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,39 @@ define(function (require, exports, module) {
645645
await endPreviewSession();
646646
}, 30000);
647647

648+
it("should custom server show banner on first show only", async function () {
649+
await _setupSimpleProject("sub/", false);
650+
651+
// should still show markdown previews with internal live preview server!
652+
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["readme.md"]),
653+
"open sub.html");
654+
await _waitForIframeMDFile('readme.md');
655+
expect(testWindow.$(".live-preview-custom-banner").is(":visible")).toBe(false);
656+
657+
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["sub/sub.html"]),
658+
"open sub.html");
659+
660+
await awaitsFor(()=>{
661+
return testWindow.$(".live-preview-custom-banner").is(":visible");
662+
}, "banner to show");
663+
664+
testWindow.$(".custom-server-banner-close-icon").click();
665+
expect(testWindow.$(".live-preview-custom-banner").is(":visible")).toBe(false);
666+
667+
// now switch to readme file
668+
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["readme.md"]),
669+
"open sub.html");
670+
await _waitForIframeMDFile('readme.md');
671+
672+
// switch to html file
673+
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["sub/sub.html"]),
674+
"open sub.html");
675+
await _waitForIframeURL('http://localhost:43768/sub.html');
676+
expect(testWindow.$(".live-preview-custom-banner").is(":visible")).toBe(false);
677+
678+
await endPreviewSession();
679+
}, 30000);
680+
648681
async function _forSVGLivePreview() {
649682
await awaitsFor(()=>{
650683
let iFrame = testWindow.document.getElementById("panel-live-preview-frame");

0 commit comments

Comments
 (0)