From f1189e46fb02dd263853194e87cc23cfe7538da3 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Thu, 5 Jun 2025 12:20:35 +0100 Subject: [PATCH 1/2] render blank screen if project is a scratch project --- .../WebComponentProject.jsx | 41 +++++++++++-------- .../WebComponentProject.test.js | 18 ++++++++ src/web-component.js | 2 +- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/components/WebComponentProject/WebComponentProject.jsx b/src/components/WebComponentProject/WebComponentProject.jsx index 44996eebb..99051afb9 100644 --- a/src/components/WebComponentProject/WebComponentProject.jsx +++ b/src/components/WebComponentProject/WebComponentProject.jsx @@ -41,6 +41,7 @@ const WebComponentProject = ({ const projectIdentifier = useSelector( (state) => state.editor.project.identifier, ); + const isScratchProject = project.project_type === "scratch"; const codeRunTriggered = useSelector( (state) => state.editor.codeRunTriggered, ); @@ -137,24 +138,28 @@ const WebComponentProject = ({ return ( <> - {!outputOnly && - (isMobile ? ( - - ) : ( - - ))} - {outputOnly && ( -
- {loading === "success" && } -
+ {!isScratchProject && ( + <> + {!outputOnly && + (isMobile ? ( + + ) : ( + + ))} + {outputOnly && ( +
+ {loading === "success" && } +
+ )} + )} ); diff --git a/src/components/WebComponentProject/WebComponentProject.test.js b/src/components/WebComponentProject/WebComponentProject.test.js index e5f6497e1..ef79ba3c2 100644 --- a/src/components/WebComponentProject/WebComponentProject.test.js +++ b/src/components/WebComponentProject/WebComponentProject.test.js @@ -21,6 +21,7 @@ jest.useFakeTimers(); let store; const renderWebComponentProject = ({ + projectType, instructions, permitOverride = true, loading, @@ -33,6 +34,7 @@ const renderWebComponentProject = ({ const initialState = { editor: { project: { + project_type: projectType, components: [ { name: "main", extension: "py", content: "print('hello')" }, ], @@ -68,6 +70,10 @@ describe("When state set", () => { }); }); + test("Renders", () => { + expect(screen.queryAllByText("output.textOutput")[0]).toBeInTheDocument(); + }); + test("Triggers codeChanged event", () => { act(() => { jest.runAllTimers(); @@ -114,6 +120,18 @@ describe("When state set", () => { }); }); +describe("When project type is scratch", () => { + beforeEach(() => { + renderWebComponentProject({ + projectType: "scratch", + }); + }); + + test("Renders a blank screen", () => { + expect(screen.queryByText("output.textOutput")).not.toBeInTheDocument(); + }); +}); + describe("When there are instructions", () => { beforeEach(() => { renderWebComponentProject({ diff --git a/src/web-component.js b/src/web-component.js index cb65ea397..e75350097 100644 --- a/src/web-component.js +++ b/src/web-component.js @@ -113,7 +113,7 @@ class WebComponent extends HTMLElement { get editorCode() { const state = store.getState(); - return state.editor.project.components[0].content; + return state.editor.project.components[0]?.content; } get menuItems() { From b095c18e8ada6fb692c1dd370e21f3c96c9f0f1a Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Thu, 5 Jun 2025 12:23:28 +0100 Subject: [PATCH 2/2] updating changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b68bb1f3..938d6ac85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fake translation for stress testing (#1206) +### Changed + +- Prevent the Scratch projects from being displayed (#1210) + ### Fixed + - Styling issue on sidebar on mobile (#1194) ## [0.30.0] - 2025-04-15