Skip to content

Fixing instructions state when set to an empty string #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2025
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Instructions empty state to show when instructions are editable (#1165, #1168)
- Allow `instructions` attribute to override instructions attached to the project (#1169)
- Instructions tabs for edit and viewing (#1167)
- Add remove instructions button modal (#1176)
- Add remove instructions button modal (#1176, #1191)
- Dark mode colours (#1182)
- Dark mode for instuctions code block (#1187)
- Change markdown links to open in new tab (#1188)
Expand Down
19 changes: 10 additions & 9 deletions src/components/WebComponentProject/WebComponentProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ const WebComponentProject = ({
dispatch(
setInstructions({
project: {
steps: projectInstructions
? [
{
quiz: false,
title: "",
content: marked.parse(projectInstructions),
},
]
: [],
steps:
typeof projectInstructions === "string"
? [
{
quiz: false,
title: "",
content: marked.parse(projectInstructions),
},
]
: [],
},
permitOverride: true,
}),
Expand Down
31 changes: 31 additions & 0 deletions src/components/WebComponentProject/WebComponentProject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@ describe("When there are instructions", () => {
});
});

describe("When instructions are an empty string", () => {
beforeEach(() => {
renderWebComponentProject({
instructions: "",
codeRunTriggered: true,
});
});

test("Dispatches action to set instructions", () => {
expect(store.getActions()).toEqual(
expect.arrayContaining([
{
type: "instructions/setInstructions",
payload: {
permitOverride: true,
project: {
steps: [
{
title: "",
content: "",
quiz: false,
},
],
},
},
},
]),
);
});
});

describe("When there are no instructions", () => {
beforeEach(() => {
renderWebComponentProject({});
Expand Down
Loading