Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 23 additions & 18 deletions src/components/WebComponentProject/WebComponentProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -137,24 +138,28 @@ const WebComponentProject = ({

return (
<>
{!outputOnly &&
(isMobile ? (
<MobileProject
withSidebar={withSidebar}
sidebarOptions={sidebarOptions}
/>
) : (
<Project
nameEditable={nameEditable}
withProjectbar={withProjectbar}
withSidebar={withSidebar}
sidebarOptions={sidebarOptions}
/>
))}
{outputOnly && (
<div className="embedded-viewer" data-testid="output-only">
{loading === "success" && <Output outputPanels={outputPanels} />}
</div>
{!isScratchProject && (
<>
{!outputOnly &&
(isMobile ? (
<MobileProject
withSidebar={withSidebar}
sidebarOptions={sidebarOptions}
/>
) : (
<Project
nameEditable={nameEditable}
withProjectbar={withProjectbar}
withSidebar={withSidebar}
sidebarOptions={sidebarOptions}
/>
))}
{outputOnly && (
<div className="embedded-viewer" data-testid="output-only">
{loading === "success" && <Output outputPanels={outputPanels} />}
</div>
)}
</>
)}
</>
);
Expand Down
18 changes: 18 additions & 0 deletions src/components/WebComponentProject/WebComponentProject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jest.useFakeTimers();
let store;

const renderWebComponentProject = ({
projectType,
instructions,
permitOverride = true,
loading,
Expand All @@ -33,6 +34,7 @@ const renderWebComponentProject = ({
const initialState = {
editor: {
project: {
project_type: projectType,
components: [
{ name: "main", extension: "py", content: "print('hello')" },
],
Expand Down Expand Up @@ -68,6 +70,10 @@ describe("When state set", () => {
});
});

test("Renders", () => {
expect(screen.queryAllByText("output.textOutput")[0]).toBeInTheDocument();
});

test("Triggers codeChanged event", () => {
act(() => {
jest.runAllTimers();
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/web-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading