Skip to content

Commit 1b64edb

Browse files
committed
failing test
1 parent dc434e2 commit 1b64edb

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

cypress/e2e/spec-html.cy.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ const getIframeDocument = () => {
1313
};
1414

1515
const getIframeBody = () => {
16-
const iframeDocument = getIframeDocument();
17-
return iframeDocument.its("body").should("not.be.null").then(cy.wrap);
16+
return getIframeDocument().its("body").should("not.be.null");
1817
};
1918

2019
const makeNewFile = (filename = "new.html") => {
@@ -183,6 +182,9 @@ it("allows internal links", () => {
183182

184183
const internalLink = getIframeBody().find("a");
185184
internalLink.click();
186-
const content = getIframeBody().find("p");
187-
content.should("include.text", "hello world");
185+
cy.get("editor-wc")
186+
.shadow()
187+
.find("iframe[class=htmlrunner-iframe]")
188+
.its("0.contentDocument.body")
189+
.should("contain.text", "hello world");
188190
});

src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function HtmlRunner() {
5959

6060
const dispatch = useDispatch();
6161
const output = useRef(null);
62+
const reloadAfterPreviewChange = useRef(false);
6263

6364
const isMobile = useMediaQuery({ query: MOBILE_MEDIA_QUERY });
6465

@@ -141,6 +142,7 @@ function HtmlRunner() {
141142
} else if (event.data?.msg === "Allowed external link") {
142143
handleAllowedExternalLink(event.data.payload.linkTo);
143144
} else {
145+
reloadAfterPreviewChange.current = true;
144146
handleRegularExternalLink(event.data.payload.linkTo, setPreviewFile);
145147
}
146148
}
@@ -205,6 +207,13 @@ function HtmlRunner() {
205207
}
206208
}, [focussedFileIndex, openFiles]);
207209

210+
useEffect(() => {
211+
if (reloadAfterPreviewChange.current) {
212+
reloadAfterPreviewChange.current = false;
213+
dispatch(triggerCodeRun());
214+
}
215+
}, [previewFile]);
216+
208217
useEffect(() => {
209218
if (isEmbedded && browserPreview) {
210219
dispatch(setPage(runningFile));

src/utils/externalLinkHelper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const useExternalLinkState = (showModal) => {
2222
const handleRegularExternalLink = (linkTo, setPreviewFile) => {
2323
setExternalLink(null);
2424
setPreviewFile(`${linkTo}.html`);
25-
dispatch(triggerCodeRun());
2625
};
2726

2827
const handleExternalLinkError = () => {

0 commit comments

Comments
 (0)