-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Client Validation] Use emptyWidgetsFunctional in scoring #2083
base: feature/client-validation
Are you sure you want to change the base?
Conversation
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (7f699f6) and published it to npm. You Example: yarn add @khanacademy/perseus@PR2083 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR2083 |
Size Change: +86 B (+0.01%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love seeing a PR that's mostly tests. Thanks!
}) | ||
// Not empty | ||
.mockReturnValueOnce(null); | ||
const scoringSpy = jest.spyOn(DropdownWidgetExport, "scorer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the perspective of an outsider, I like this strategy. From the perspective of someone actively working on splitting up WidgetExports, I wonder if there's a way to do these tests without spying on WidgetExports; for example we could get 90% there by creating an empty user input object and that would keep me from having to refactor this test when I make my changes.
No action needed, just something that came to mind.
This PR completes the work of extracting validation logic from scoring logic. This retains most of the validation that used to be intermingled with scoring.
This means that even when we strip scoring data from the widget options, we'll still be able to check if an answer is scorable.
Notably:
input-number
andnumeric-input
missed the train here. Both of these widgets useKhanAnswerTypes
right at the beginning of scoring. Further, thecoefficient
answer type allows an empty value (""
) and bare negative ("-"
) to be treated as answers by coercing them to1
and-1
respectively. This means that we cannot do any validation/empty checking for these widgets because we need the fullKhanAnswerTypes
logic (which requires scoring data to work).Issue: LEMS-2561
Test plan:
yarn test
yarn typecheck