Skip to content

Conversation

@mark-fitzgerald
Copy link
Contributor

Summary:

Now that the feature flag is on for all apps, we can remove all code involed in the old version of the widget. This PR removes those old widget files, leaving the *.new.tsx files. It also updates numerous unit tests to properly reference the multiple choice options.

Issue: LEMS-3847

Test plan:

Unit tests pass
Visual regression tests pass

Update radio.ff.tsx to only use the new version of the widget.
…ntext to the top-level widget class (radio.ff.tsx)

Update unit tests for new widget details.
Remove radio.test.ts as all of its tests are now in multiple-choice.test.ts.
Update unit tests to reference multiple choice options correctly (role = "button") and to check for its name correctly (name: /(Choice A)/).
@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

Size Change: -4.5 kB (-0.92%)

Total Size: 483 kB

Filename Size Change
packages/perseus/dist/es/index.js 187 kB -4.5 kB (-2.35%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12.1 kB
packages/perseus-core/dist/es/index.js 25 kB
packages/perseus-editor/dist/es/index.js 96.7 kB
packages/perseus-linter/dist/es/index.js 8.84 kB
packages/perseus-score/dist/es/index.js 9.25 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 7.44 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (500751e) and published it to npm. You
can install it using the tag PR3199.

Example:

pnpm add @khanacademy/perseus@PR3199

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3199

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3199

});

// LEMS-3445: Ensures that deselecting one choice doesn't select other choices
it("should not select other choices when deselecting current choice", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be in the multiple-select section, but since it is using a single-select question, I moved it here.

});

// LEMS-3445: Ensures that deselecting one choice doesn't select other choices
it("should not select other choices when deselecting current choice - single select", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the single-select section above.

…t to actually look for the intended content (original change was not done correctly).

Remove commented out line in index.ts.
Copy link
Contributor

@ivyolamit ivyolamit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall PR looks good to me on my first pass, will take a look again first thing tomorrow morning and do a smoke test.

I did noticed in the storybook we still have these two

Image


constructor(props: Props) {
super(props);
this.ffIsOn = props.apiOptions.flags?.["new-radio-widget"] ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Comment on lines 147 to 151
if (!radioInput) {
throw new Error(
`Could not find radio input for choice content: ${choice.content}`,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using getBy* queries and assertions instead of conditionals / manual throws? This looks like an anti-pattern that existed in the file already, but wanted to flag it so we can avoid continuing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this test is to activate the button associated with the given choice. We only know the text of the choice, not the letter. Therefore, I used queryByText to find the choice content, and then navigated to the button associated with it. I wasn't confident that clicking the found text would trigger the onClick event handler that we have on the <li> tag. After testing that theory, it appears to work properly. I will update the test to not use the DOM queries.

… to click the found choice text instead of searching for the associated button.

Update the Storybook files to have a single "Radio" section.
Copy link
Contributor

@ivyolamit ivyolamit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark-fitzgerald going to approve this PR changes looks logical to me and smoke testing 👌🏼
Great work on this! 👏🏼

…sert non-null states instead of using if statements.

Format as AAA.
Comment on lines +154 to 156
// Assert
expect(widgetJSON.type).toEqual("radio");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests are much better! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants