Skip to content

Commit

Permalink
Swap out deprecated input-number with numeric-input in some tests (#1995
Browse files Browse the repository at this point in the history
)

# Subject 

The `input-number` widget is deprecated and was causing issues in the work I'm doing for validation and SSS. Swapping them out for the `numeric-input` so that I have a path forward. 

# Test Plan 

`yarn test`
`yarn typecheck`


Issue: LEMS-2561

Author: jeremywiebe

Reviewers: Myranae, handeyeco, SonicScrewdriver

Required Reviewers:

Approved By: handeyeco

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #1995
  • Loading branch information
jeremywiebe authored Dec 13, 2024
1 parent cfbe3dc commit 99cd254
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-cups-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

TESTS: swap input-number out of renderer tests as it is deprecated
33 changes: 21 additions & 12 deletions packages/perseus/src/__testdata__/renderer.testdata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
DropdownWidget,
ImageWidget,
InputNumberWidget,
NumericInputWidget,
PerseusRenderer,
} from "../perseus-types";
import type {RenderProps} from "../widgets/radio";
Expand Down Expand Up @@ -49,22 +49,31 @@ export const imageWidget: ImageWidget = {
version: {major: 0, minor: 0},
};

export const inputNumberWidget: InputNumberWidget = {
export const numericInputWidget: NumericInputWidget = {
graded: true,
version: {
major: 0,
minor: 0,
},
type: "input-number",
graded: true,
alignment: "default",
static: false,
type: "numeric-input",
options: {
maxError: 0.1,
inexact: false,
value: 0.3333333333333333,
simplify: "optional",
answerType: "rational",
coefficient: false,
static: false,
answers: [
{
status: "correct",
maxError: null,
strict: false,
value: 1252,
simplify: "required",
message: "",
},
],
labelText: "",
size: "normal",
},
alignment: "default",
};

export const question1: PerseusRenderer = {
Expand All @@ -76,15 +85,15 @@ export const question1: PerseusRenderer = {

export const question2: PerseusRenderer = {
content:
"Denis baked a peach pie and cut it into $3$ equal-sized pieces. Denis's dad eats $1$ section of the pie. \n\n**What fraction of the pie did Denis's dad eat?** \n![](https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png) \n[[\u2603 input-number 1]] \n\n\n\n",
"Denis baked a peach pie and cut it into $3$ equal-sized pieces. Denis's dad eats $1$ section of the pie. \n\n**What fraction of the pie did Denis's dad eat?** \n![](https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png) \n[[\u2603 numeric-input 1]] \n\n\n\n",
images: {
"https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png":
{
width: 200,
height: 200,
},
},
widgets: {"input-number 1": inputNumberWidget},
widgets: {"numeric-input 1": numericInputWidget},
};

export const definitionItem: PerseusRenderer = {
Expand Down
12 changes: 6 additions & 6 deletions packages/perseus/src/__tests__/perseus-markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ describe("perseus markdown", () => {
],
},
{
content: "[[☃ test 1]]+[[☃ input-number 2]]",
content: "[[☃ test 1]]+[[☃ numeric-input 2]]",
expected: [
{
type: "paragraph",
Expand All @@ -314,15 +314,15 @@ describe("perseus markdown", () => {
},
{
type: "widget",
widgetType: "input-number",
id: "input-number 2",
widgetType: "numeric-input",
id: "numeric-input 2",
},
],
},
],
},
{
content: "*[[☃ test 2]]* [[☃ input-number 1]]",
content: "*[[☃ test 2]]* [[☃ numeric-input 1]]",
expected: [
{
type: "paragraph",
Expand All @@ -343,8 +343,8 @@ describe("perseus markdown", () => {
},
{
type: "widget",
widgetType: "input-number",
id: "input-number 1",
widgetType: "numeric-input",
id: "numeric-input 1",
},
],
},
Expand Down
Loading

0 comments on commit 99cd254

Please sign in to comment.