-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert expression-editor changes to answer form key handling (#827)
## Summary: In #711 we added some protective parsing code for AnswerForm `key`s. However, we discovered ([Slack](https://khanacademy.slack.com/archives/C3SLM30AW/p1701199431143119)) that there are instances of data where the key is entirely missing. Reverting the `throw` for now to unblock our content authors. I'll continue working on this in a separate PR/deploy to fix this more correctly as Ned was onto something! Issue: LC-1502 ## Test plan: Run the tests. They should pass. Author: jeremywiebe Reviewers: nedredmond Required Reviewers: Approved By: nedredmond Checks: ✅ gerald, ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ⏭ Publish npm snapshot, ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 16.x), ✅ Cypress (ubuntu-latest, 16.x), ✅ Jest Coverage (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 16.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 16.x), ✅ gerald Pull Request URL: #827
- Loading branch information
1 parent
7cb40e4
commit c7410cc
Showing
4 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus-editor": minor | ||
--- | ||
|
||
Revert defensive code in ExpressionEditor that caused a crash when an expression config's answer form was missing a `key` property. |
56 changes: 56 additions & 0 deletions
56
packages/perseus-editor/src/widgets/__tests__/expression-editor.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {Dependencies} from "@khanacademy/perseus"; | ||
import {render, screen} from "@testing-library/react"; | ||
import * as React from "react"; | ||
|
||
import "@testing-library/jest-dom"; | ||
|
||
import {testDependencies} from "../../../../../testing/test-dependencies"; | ||
import ExpressionEditor from "../expression-editor"; | ||
|
||
import type {PropsFor} from "@khanacademy/wonder-blocks-core"; | ||
|
||
describe("expression-editor", () => { | ||
beforeEach(() => { | ||
jest.spyOn(Dependencies, "getDependencies").mockReturnValue( | ||
testDependencies, | ||
); | ||
}); | ||
|
||
it("should render", async () => { | ||
render(<ExpressionEditor onChange={() => undefined} />); | ||
|
||
expect(await screen.findByText(/Add new answer/)).toBeInTheDocument(); | ||
}); | ||
|
||
it("should render answerForms missing a key", async () => { | ||
const answerForms: PropsFor<typeof ExpressionEditor>["answerForms"] = [ | ||
{ | ||
value: "x\\cdot3=y", | ||
form: true, | ||
simplify: true, | ||
considered: "correct", | ||
}, | ||
{ | ||
value: "x^2=y", | ||
form: true, | ||
simplify: true, | ||
considered: "wrong", | ||
}, | ||
{ | ||
value: "x=y\\cdotπ", | ||
form: true, | ||
simplify: true, | ||
considered: "wrong", | ||
}, | ||
]; | ||
|
||
render( | ||
<ExpressionEditor | ||
onChange={() => undefined} | ||
answerForms={answerForms} | ||
/>, | ||
); | ||
|
||
expect(await screen.findByText(/π/)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters