Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
aa09f15
Create draft PR for #936
create-issue-branch[bot] Feb 27, 2024
8814cae
default to pyodide and switch to skulpt if needed
loiswells97 Feb 27, 2024
1f0e5d0
attempt to parse imports in the runnerfactory
loiswells97 Feb 27, 2024
12bdce4
refactoring
loiswells97 Feb 28, 2024
f0ba6c3
tidying for linter
loiswells97 Feb 28, 2024
825961e
tidying to clarify approach in pr
loiswells97 Feb 28, 2024
e4354ed
refactoring to fix things
loiswells97 Feb 28, 2024
534871c
tidying
loiswells97 Feb 28, 2024
fb17e4d
tidying
loiswells97 Feb 29, 2024
7a3a74c
Merge branch 'main' into issues/936-Spike_Investigate_using_pyodide_d…
loiswells97 Feb 29, 2024
e69126c
Merge branch 'main' into issues/936-Spike_Investigate_using_pyodide_d…
loiswells97 Feb 29, 2024
edabb66
Merge branch 'main' into issues/936-Spike_Investigate_using_pyodide_d…
loiswells97 Feb 29, 2024
ff0587f
fixing shikm assets
loiswells97 Apr 4, 2024
73ae099
Merge branch 'main' into issues/936-Spike_Investigate_using_pyodide_d…
loiswells97 Apr 4, 2024
beaad38
initial attempt at explaining incompatible modules
loiswells97 Apr 4, 2024
901cd1d
Fixing snapshot and skulptrunner tests
loiswells97 Apr 4, 2024
88ce726
fixing pyodiderunner tests
loiswells97 Apr 4, 2024
ea622af
fixing py5 imported mode
loiswells97 Apr 4, 2024
95b85ab
fixing cypress tests
loiswells97 Apr 4, 2024
ef868e0
updating snapshot
loiswells97 Apr 4, 2024
f9d8b67
fixing linting warning
loiswells97 Apr 5, 2024
610f6ad
updating changelog
loiswells97 Apr 5, 2024
e399def
fixing the input function
loiswells97 Apr 5, 2024
797a559
trying to fix cypress
loiswells97 Apr 5, 2024
691f9fb
patching pygal tooltip formatter
loiswells97 Apr 8, 2024
b1683fe
couple of regex patches to eliminate some edge cases
loiswells97 Apr 8, 2024
f76ea51
tidying
loiswells97 Apr 8, 2024
fdc914d
moving pyodiderunner back for now to avoid conflicts
loiswells97 Apr 8, 2024
52c4067
Merge branch 'main' into issues/936-Spike_Investigate_using_pyodide_d…
loiswells97 Apr 8, 2024
1b82f42
tidying
loiswells97 Apr 8, 2024
68d85dc
changing and fixing tests
loiswells97 Apr 9, 2024
41594e6
fixing more tests
loiswells97 Apr 9, 2024
a571b06
fix mission zero tests
loiswells97 Apr 9, 2024
ce79754
testing pythonrunner switching which runner is active
loiswells97 Apr 9, 2024
70d1eea
updating snapshot
loiswells97 Apr 9, 2024
e53a055
tweaking and testing skulpt and pyodide runner visibilities
loiswells97 Apr 9, 2024
868ab31
tweaking incompatibility error message explanation
loiswells97 Apr 9, 2024
d2fcfc3
fix one of the mission zero cypress tests
loiswells97 Apr 10, 2024
a73fcad
update error explanation copy
loiswells97 Apr 10, 2024
bdb30a1
switching turtle to skulpt and forcing skulpt if sense hat always ena…
loiswells97 Apr 10, 2024
5d43c1a
update error explanation to include turtle
loiswells97 Apr 10, 2024
8e8bdc9
updating snapshot
loiswells97 Apr 10, 2024
e45e8e3
switching mission zero cypress port
loiswells97 Apr 10, 2024
d9b38f3
Merge branch 'pyodide-migration' into issues/936-Spike_Investigate_us…
sra405 Apr 29, 2024
73981ea
Merge pull request #937 from RaspberryPiFoundation/issues/936-Spike_I…
sra405 May 31, 2024
410b3d2
Merge branch 'main' into pyodide-migration
sra405 May 31, 2024
d93fd44
renaming and moving files temporarily to try and simplify the merge c…
loiswells97 Oct 1, 2024
8512211
Merge branch 'main' into pyodide-migration
loiswells97 Oct 1, 2024
09a9c60
reverting and fixing a few things post merge
loiswells97 Oct 1, 2024
cf403ca
some test fixing
loiswells97 Oct 1, 2024
3a50dc3
trying to fix cypress tests
loiswells97 Oct 3, 2024
34fed91
remove lingering only from cypress tests
loiswells97 Oct 3, 2024
efd0544
be more defensive looping over project components
loiswells97 Oct 3, 2024
19be64a
Matplotlib support (#1087)
loiswells97 Oct 8, 2024
17dfe0a
Fix dynamic pyodide switching with multiple files (#1097)
create-issue-branch[bot] Oct 9, 2024
41ef481
Web component pyodide support (#1090)
loiswells97 Oct 10, 2024
e582b65
Bump pyodide to latest version (#1098)
create-issue-branch[bot] Oct 11, 2024
b32205f
Webpack v5 bump (#1096)
loiswells97 Oct 15, 2024
b219067
updated .env.example
KristinaDudnyk Oct 15, 2024
18de632
Pyodide testing (#1100)
loiswells97 Oct 17, 2024
c9d94d8
Updated message for ImportErrors
KristinaDudnyk Oct 17, 2024
037ddca
Added handling of upcoming string with html tag
KristinaDudnyk Oct 17, 2024
84c84d6
+test
KristinaDudnyk Oct 17, 2024
d655eff
Merge branch 'pyodide-migration' into 309-update-error-message-for-im…
KristinaDudnyk Oct 17, 2024
7cc2fea
updated cypress test
KristinaDudnyk Oct 17, 2024
2f4d5d3
updated test
KristinaDudnyk Oct 17, 2024
8a02964
updated CHANGELOG
KristinaDudnyk Oct 17, 2024
9062d13
removed console.log
KristinaDudnyk Oct 17, 2024
4ecbe36
Merge branch 'main' into 309-update-error-message-for-importerrors
KristinaDudnyk Oct 18, 2024
8e06394
fixing merge conflicts
KristinaDudnyk Oct 18, 2024
b125b24
Update .env.example
KristinaDudnyk Oct 18, 2024
a4c6f74
Delete public/_internal_sense_hat.js
KristinaDudnyk Oct 18, 2024
6610d19
Delete public/pygal.js
KristinaDudnyk Oct 18, 2024
4d966bf
Update PyodideRunner.jsx
KristinaDudnyk Oct 18, 2024
0efec8d
Update PyodideRunner.jsx
KristinaDudnyk Oct 18, 2024
7c143a2
fixing cypress test
KristinaDudnyk Oct 18, 2024
75badb1
Added locales
KristinaDudnyk Oct 18, 2024
0e7008f
reverse Added locales commit
KristinaDudnyk Oct 21, 2024
09cb867
Merge branch '309-update-error-message-for-importerrors' of https://g…
KristinaDudnyk Oct 21, 2024
703a658
Update CHANGELOG.md
KristinaDudnyk Oct 21, 2024
75d58c2
reverse Added locale commit
KristinaDudnyk Oct 21, 2024
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 @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

### Changed

- Updated the ImportErrors message
- In ErrorMessage component added the way to display html elements in string

### Added

- PyodideWorker setup for the editor (#1104)
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/spec-wc-skulpt.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("Running the code with skulpt", () => {
.find(".error-message__content")
.should(
"contain.text",
"If you are using p5, py5, sense_hat or turtle, matplotlib might not work.",
"ImportError: No module named matplotlib on line 2 of main.py. You should check your code for typos. If you are using p5, py5, sense_hat or turtle, matplotlib might not work - read this article for more information.",
);
});
});
10 changes: 8 additions & 2 deletions src/components/Editor/ErrorMessage/ErrorMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React, { useContext } from "react";
import React, { useContext, useEffect, useRef } from "react";
import "../../../assets/stylesheets/ErrorMessage.scss";
import { useSelector } from "react-redux";
import { SettingsContext } from "../../../utils/settings";

const ErrorMessage = () => {
const message = useRef();
const error = useSelector((state) => state.editor.error);
const settings = useContext(SettingsContext);

useEffect(() => {
if (message.current) {
message.current.innerHTML = error;
}
}, [error]);
return error ? (
<div className={`error-message error-message--${settings.fontSize}`}>
<pre className="error-message__content">{error}</pre>
<pre ref={message} className="error-message__content"></pre>
</div>
) : null;
};
Expand Down
52 changes: 40 additions & 12 deletions src/components/Editor/ErrorMessage/ErrorMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,42 @@ import ErrorMessage from "./ErrorMessage";
import { render, screen } from "@testing-library/react";

describe("When error is set", () => {
beforeEach(() => {
const middlewares = [];
const mockStore = configureStore(middlewares);
const middlewares = [];
const mockStore = configureStore(middlewares);

describe("When error is set", () => {
beforeEach(() => {
const initialState = {
editor: {
error: "Oops",
},
};
const store = mockStore(initialState);
render(
<Provider store={store}>
<SettingsContext.Provider
value={{ theme: "dark", fontSize: "myFontSize" }}
>
<ErrorMessage />
</SettingsContext.Provider>
</Provider>,
);
});

test("Error message displays", () => {
expect(screen.queryByText("Oops")).toBeInTheDocument();
});

test("Font size class is set correctly", () => {
const errorMessage = screen.queryByText("Oops").parentElement;
expect(errorMessage).toHaveClass("error-message--myFontSize");
});
});

it("should render links correctly within the error message", () => {
const initialState = {
editor: {
error: "Oops",
error: `ImportError: No module named pd on line 2 of main.py. You should check your code for typos. If you are using p5, py5, sense_hat or turtle, pd might not work - read this <a href=https://help.editor.raspberrypi.org/hc/en-us/articles/30841379339924-What-Python-libraries-are-available-in-the-Code-Editor>article</a> for more information.`,
},
};
const store = mockStore(initialState);
Expand All @@ -23,14 +53,12 @@ describe("When error is set", () => {
</SettingsContext.Provider>
</Provider>,
);
});

test("Error message displays", () => {
expect(screen.queryByText("Oops")).toBeInTheDocument();
});

test("Font size class is set correctly", () => {
const errorMessage = screen.queryByText("Oops").parentElement;
expect(errorMessage).toHaveClass("error-message--myFontSize");
const linkElement = screen.getByRole("link", { name: "article" });
expect(linkElement).toBeInTheDocument();
expect(linkElement).toHaveAttribute(
"href",
"https://help.editor.raspberrypi.org/hc/en-us/articles/30841379339924-What-Python-libraries-are-available-in-the-Code-Editor",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ const SkulptRunner = ({ active, outputPanels = ["text", "visual"] }) => {
const fileName = err.traceback[0].filename.replace(/^\.\//, "");

if (errorType === "ImportError" && window.crossOriginIsolated) {
const articleLink = `https://help.editor.raspberrypi.org/hc/en-us/articles/30841379339924-What-Python-libraries-are-available-in-the-Code-Editor`;
const moduleName = errorDescription.replace(/No module named /, "");
explanation = `You should check your code for typos. If you are using p5, py5, sense_hat or turtle, ${moduleName} might not work.`;
explanation = `You should check your code for typos. If you are using p5, py5, sense_hat or turtle, ${moduleName} might not work - read this <a href=${articleLink}>article</a> for more information.`;
}

let userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ describe("When there is an import error and the site is cross-origin isolated",
let store;
beforeEach(() => {
window.crossOriginIsolated = true;

const middlewares = [];
const mockStore = configureStore(middlewares);
const initialState = {
Expand Down Expand Up @@ -312,12 +311,10 @@ describe("When there is an import error and the site is cross-origin isolated",
);
});
test("it shows the original error message and the explanation", () => {
expect(store.getActions()).toEqual(
expect.arrayContaining([
setError(
"ImportError: No module named fake_module on line 1 of main.py. You should check your code for typos. If you are using p5, py5, sense_hat or turtle, fake_module might not work.",
),
]),
expect(store.getActions()).toContainEqual(
setError(
`ImportError: No module named fake_module on line 1 of main.py. You should check your code for typos. If you are using p5, py5, sense_hat or turtle, fake_module might not work - read this <a href=https://help.editor.raspberrypi.org/hc/en-us/articles/30841379339924-What-Python-libraries-are-available-in-the-Code-Editor>article</a> for more information.`,
),
);
});
});
Expand Down
Loading
Loading