{
expect(screen.queryByTitle("sidebar.expand")).not.toBeInTheDocument();
});
});
+
+describe("When an error occurs", () => {
+ const buildState = (error) => ({
+ editor: {
+ project: {
+ project_type: "python",
+ components: [
+ { name: "main", extension: "py", content: "print('hello')" },
+ ],
+ image_list: [],
+ },
+ codeRunTriggered: true,
+ openFiles: [["main.py"]],
+ focussedFileIndices: [0],
+ error,
+ },
+ auth: {},
+ });
+
+ test("switches from the output tab to the code tab", () => {
+ const { rerender } = render(
+
+
+ ,
+ );
+ const codeTab = screen.getByText("mobile.code").closest("li");
+ const outputTab = screen.getByText("mobile.output").closest("li");
+ expect(outputTab).toHaveAttribute("aria-selected", "true");
+
+ rerender(
+
+
+ ,
+ );
+ expect(codeTab).toHaveAttribute("aria-selected", "true");
+ });
+
+ test("does not change tab when the error is cleared", () => {
+ const { rerender } = render(
+
+
+ ,
+ );
+ const outputTab = screen.getByText("mobile.output").closest("li");
+ fireEvent.click(outputTab);
+ expect(outputTab).toHaveAttribute("aria-selected", "true");
+
+ rerender(
+
+
+ ,
+ );
+ expect(outputTab).toHaveAttribute("aria-selected", "true");
+ });
+});
diff --git a/src/components/RunButton/RunBar.jsx b/src/components/RunButton/RunBar.jsx
index 10eff8ec0..a209b4f1c 100644
--- a/src/components/RunButton/RunBar.jsx
+++ b/src/components/RunButton/RunBar.jsx
@@ -6,7 +6,7 @@ import "../../assets/stylesheets/RunBar.scss?inline";
const RunBar = ({ embedded = false }) => {
return (
-
+
);
};
diff --git a/src/components/RunButton/RunnerControls.jsx b/src/components/RunButton/RunnerControls.jsx
index c82ad02ba..de7b92bb1 100644
--- a/src/components/RunButton/RunnerControls.jsx
+++ b/src/components/RunButton/RunnerControls.jsx
@@ -9,7 +9,11 @@ import { stopCodeRun, stopDraw, triggerCodeRun } from "../../redux/EditorSlice";
import { runStoppedEvent } from "../../events/WebComponentCustomEvents";
import "../../assets/stylesheets/RunnerControls.scss?inline";
-const RunnerControls = ({ embedded = false, skinny = false }) => {
+const RunnerControls = ({
+ embedded = false,
+ skinny = false,
+ small = false,
+}) => {
const codeRunTriggered = useSelector(
(state) => state.editor.codeRunTriggered,
);
@@ -86,7 +90,7 @@ const RunnerControls = ({ embedded = false, skinny = false }) => {
className={classNames("btn--primary", {
"btn--run": !isRunning,
"btn--stop": isRunning,
- "btn--small": skinny,
+ "btn--small": skinny || small,
})}
disabled={
!isRunning &&
diff --git a/src/components/RunButton/RunnerControls.test.jsx b/src/components/RunButton/RunnerControls.test.jsx
index cbe1977c7..bf11625b2 100644
--- a/src/components/RunButton/RunnerControls.test.jsx
+++ b/src/components/RunButton/RunnerControls.test.jsx
@@ -31,6 +31,18 @@ test("Run button shows when code is not running", () => {
expect(runButton).toBeInTheDocument();
});
+test("Run button is small when small is set", () => {
+ const store = mockStore({ editor: {} });
+ render(
+
+
+ ,
+ );
+ const runButton = screen.getByText("runButton.run").closest("button");
+ expect(runButton).toHaveClass("btn--small");
+ expect(runButton.parentElement).not.toHaveClass("btn-outer");
+});
+
test("Stop button shows when code is running", () => {
const initialState = {
editor: {