-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept 'scientific' as a buttonSets value when parsing Expression wid…
…gets (#2227) Issue: https://khanacademy.atlassian.net/browse/LEMS-2861 ## Test plan: `yarn test` Author: benchristel Reviewers: Myranae, benchristel, handeyeco Required Reviewers: Approved By: Myranae Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (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), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2227
- Loading branch information
1 parent
4300535
commit ce320b4
Showing
10 changed files
with
486 additions
and
25 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-core": patch | ||
--- | ||
|
||
Bugfix: Accept 'scientific' as a buttonSets value when parsing Expression widgets |
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
21 changes: 21 additions & 0 deletions
21
packages/perseus-core/src/parse-perseus-json/perseus-parsers/legacy-button-sets.ts
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,21 @@ | ||
import {array, enumeration} from "../general-purpose-parsers"; | ||
import {defaulted} from "../general-purpose-parsers/defaulted"; | ||
|
||
export const parseLegacyButtonSet = enumeration( | ||
"basic", | ||
"basic+div", | ||
"trig", | ||
"prealgebra", | ||
"logarithms", | ||
"basic relations", | ||
"advanced relations", | ||
"scientific", | ||
); | ||
|
||
export const parseLegacyButtonSets = defaulted( | ||
array(parseLegacyButtonSet), | ||
// NOTE(benchristel): I copied the default buttonSets from | ||
// expression.tsx. See the parse-perseus-json/README.md for | ||
// an explanation of why we want to duplicate the default here. | ||
() => ["basic", "trig", "prealgebra", "logarithms"] as const, | ||
); |
13 changes: 13 additions & 0 deletions
13
packages/perseus-core/src/parse-perseus-json/perseus-parsers/legacy-button-sets.typetest.ts
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,13 @@ | ||
import {summon} from "../general-purpose-parsers/test-helpers"; | ||
|
||
import type {parseLegacyButtonSet} from "./legacy-button-sets"; | ||
import type {LegacyButtonSets} from "../../data-schema"; | ||
import type {ParsedValue} from "../parser-types"; | ||
|
||
type ParsedButtonSet = ParsedValue<typeof parseLegacyButtonSet>; | ||
|
||
// Test: LegacyButtonSets is mutually assignable with the result type of | ||
// parseButtonSets(). This ensures that we keep the parser up to date with any | ||
// new enum values added to the data schema. | ||
summon<ParsedButtonSet>() satisfies LegacyButtonSets[number]; | ||
summon<LegacyButtonSets[number]>() satisfies ParsedButtonSet; |
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
Oops, something went wrong.