From 5241e1f2788e6f692dab7d41ca4b5e280e2122f9 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Tue, 4 Feb 2025 16:23:02 +0000 Subject: [PATCH 1/2] fixing instructions state when set to an empty strinf --- .../WebComponentProject.jsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/WebComponentProject/WebComponentProject.jsx b/src/components/WebComponentProject/WebComponentProject.jsx index 137bf9bda..44996eebb 100644 --- a/src/components/WebComponentProject/WebComponentProject.jsx +++ b/src/components/WebComponentProject/WebComponentProject.jsx @@ -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, }), From d68345fccb905330ae72712445c2224263092c49 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Tue, 4 Feb 2025 16:28:41 +0000 Subject: [PATCH 2/2] changelog and test --- CHANGELOG.md | 2 +- .../WebComponentProject.test.js | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e4db0cb..085bedfc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/components/WebComponentProject/WebComponentProject.test.js b/src/components/WebComponentProject/WebComponentProject.test.js index c6e3d7c80..e5f6497e1 100644 --- a/src/components/WebComponentProject/WebComponentProject.test.js +++ b/src/components/WebComponentProject/WebComponentProject.test.js @@ -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({});