mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 23:00:03 +00:00
fix(studio): short-circuit slideshow-island detection with a substring check (review N2)
slideshowIslandRegex scanned the full file content on every editingFile change even for the common non-slideshow case. Gate it behind a plain substring check on SLIDESHOW_ISLAND_TYPE first — cheap, and avoids the full-content RegExp pass for files that plainly have no island. Added a test for the still-open behavior this preserves: a malformed island (invalid JSON) still trips the substring check and the regex, so the tab stays discoverable rather than silently disappearing.
This commit is contained in:
@@ -69,6 +69,13 @@ describe("useSlideshowTabState", () => {
|
||||
harness.unmount();
|
||||
});
|
||||
|
||||
it("still detects a malformed island — presence-only, not full manifest validation", () => {
|
||||
const malformed = `<html><body><script type="application/hyperframes-slideshow+json">{not valid json</script></body></html>`;
|
||||
const harness = renderHook({ editingFileContent: malformed, rightPanelTab: "design" });
|
||||
expect(harness.getState().isSlideshowComposition).toBe(true);
|
||||
harness.unmount();
|
||||
});
|
||||
|
||||
it("bounces rightPanelTab off 'slideshow' to 'renders' on a non-slideshow composition", () => {
|
||||
const harness = renderHook({ editingFileContent: PLAIN_HTML, rightPanelTab: "slideshow" });
|
||||
expect(harness.setRightPanelTabCalls).toEqual(["renders"]);
|
||||
|
||||
Reference in New Issue
Block a user