Skip to content

Commit c1f5dab

Browse files
authored
Fix some test data (#2770)
## Summary: Ben made me rethink my approach. Maybe we shouldn't be migrating in `renderQuestion`, maybe we just need to be better about typing our test data? ~~While working on answerless rendering, I noticed some test failures related to calling `splitPerseusItem` (which itself calls `parseAndMigratePerseusItem`). It occurred to me that our test helper `renderQuestion` isn't calling the migration function before passing the PerseusItem to ServerItemRenderer; since ServerItemRenderer doesn't upgrade PerseusItems anymore, that's a problem!~~ ~~This fixes `renderQuestion` in `packages/perseus/src/__tests__/test-utils.tsx` (and tests that needed to be updated as a result) but doesn't fix `renderQuestion` in `packages/perseus/src/widgets/__testutils__/renderQuestion.tsx`. That's because that version of `renderQuestion` takes a PerseusRenderer and not a PerseusItem which I don't think our upgrade script handles. While this further strengthens my belief that Renderer should be internal to Perseus (with ServerItemRenderer or ArticleRenderer being the mount for all Perseus rendering), it doesn't change the fact that we have a lot of tests that are currently rendering directly to a Renderer.~~ Author: handeyeco Reviewers: benchristel, ivyolamit, mark-fitzgerald, SonicScrewdriver, anakaren-rojas, nishasy, jeremywiebe Required Reviewers: Approved By: benchristel Checks: ✅ 10 checks were successful Pull Request URL: #2770
1 parent 3c58a9b commit c1f5dab

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

.changeset/shaggy-wasps-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
Fix some test data with malformed PerseusItems

packages/perseus/src/__testdata__/server-item-renderer.testdata.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {
22
type LabelImageWidget,
33
type PerseusItem,
4-
type ExpressionWidget,
5-
type RadioWidget,
64
type NumericInputWidget,
75
getDefaultAnswerArea,
86
} from "@khanacademy/perseus-core";
@@ -177,16 +175,10 @@ export const itemWithRadioAndExpressionWidgets: PerseusItem = {
177175
widgets: {
178176
"radio 1": {
179177
graded: true,
180-
version: {major: 0, minor: 0},
178+
version: {major: 3, minor: 0},
181179
static: false,
182-
numCorrect: 1,
183-
hasNoneOfTheAbove: false,
184-
multipleSelect: false,
185-
countChoices: false,
186-
deselectEnabled: false,
187180
type: "radio",
188181
options: {
189-
static: false,
190182
countChoices: false,
191183
deselectEnabled: false,
192184
hasNoneOfTheAbove: false,
@@ -216,7 +208,7 @@ export const itemWithRadioAndExpressionWidgets: PerseusItem = {
216208
],
217209
},
218210
alignment: "default",
219-
} as RadioWidget,
211+
},
220212
"expression 1": {
221213
type: "expression",
222214
graded: true,
@@ -244,9 +236,8 @@ export const itemWithRadioAndExpressionWidgets: PerseusItem = {
244236
buttonSets: ["basic"],
245237
functions: ["f", "g", "h"],
246238
buttonsVisible: "always",
247-
alignment: "default",
248239
},
249-
} as ExpressionWidget,
240+
},
250241
},
251242
},
252243
hints: [

packages/perseus/src/widgets/expression/serialize-expression.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe("Expression serialization", () => {
3636
widgets: {
3737
"expression 1": {
3838
type: "expression",
39+
version: {major: 2, minor: 0},
3940
options: {
4041
answerForms: [
4142
{

0 commit comments

Comments
 (0)