-
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
Remove guessAndScore
#1974
Remove guessAndScore
#1974
Conversation
guessAndScore
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (2fbfbf4) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1974 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1974 |
Size Change: -51 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
return {widgetState, score}; | ||
} | ||
|
||
function maybeAddState(message: string, widgetState: string): string { |
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.
I removed widgetState
from the tests and they didn't seem to care. So I'm thinking this is a feature we didn't think was particularly useful. Also since the Renderer isn't scoring now, the correct/incorrect helper isn't the place to get that.
/** | ||
* @deprecated use scorePerseusItem | ||
*/ | ||
guessAndScore: () => [UserInputArray, PerseusScore] = () => { |
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.
Happy about this, but I wanted to go further and delete score
. Unfortunately I'm not sure we're ready for that until we have a path for client-side validation.
perseusRenderData: PerseusRenderer, | ||
userInputMap: UserInputMap, | ||
): PerseusScore { | ||
return scorePerseusItem(perseusRenderData, userInputMap, mockStrings, "en"); |
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.
I just didn't want to bother with importing mockStrings
everywhere.
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.
Praise: I love this technique! Trying to get it into my memory banks so I can use it sometime too. Very cool.
absoluteValueQuestion, | ||
userInput, | ||
); | ||
expect(score).toStrictEqual({ |
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.
Cypress doesn't have access to toHaveBeenAnsweredCorrectly
AFAIK
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.
Comment: Good to know! Haven't written Cypress tests in a while.
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.
That's correct, because toHaveBeenAnsweredCorrectly
is a Jest custom matcher. Although our Cypress tests look kinda like Jest tests, they aren't, and they just happen to have similar assertion APIs. We didn't replicate the custom matchers for the Renderer in Cypress.
// Assert | ||
expect(renderer).toHaveBeenAnsweredCorrectly(); | ||
expect(score).toHaveBeenAnsweredCorrectly(); |
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.
90% of the changes are just updating tests to score outside of Renderer and then using that score for the assertion.
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.
Thanks! Looks great! Went through and tested most of the widgets in SB and they all seem good too.
perseusRenderData: PerseusRenderer, | ||
userInputMap: UserInputMap, | ||
): PerseusScore { | ||
return scorePerseusItem(perseusRenderData, userInputMap, mockStrings, "en"); |
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.
Praise: I love this technique! Trying to get it into my memory banks so I can use it sometime too. Very cool.
// NOTE(jeremy): The graded-group widget does not participate in | ||
// Renderer grading. So we can't call `renderer.score()` and see that | ||
// the widget is answered correctly. The only route to check the answer |
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.
Question: Did you change this because no widgets will participate in renderer grading after this?
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.
Right, since renderer.score
is going away soon I didn't see the need to make that distinction here.
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.
I filed a ticket to look into this more: https://khanacademy.atlassian.net/browse/LEMS-2719
absoluteValueQuestion, | ||
userInput, | ||
); | ||
expect(score).toStrictEqual({ |
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.
Comment: Good to know! Haven't written Cypress tests in a while.
* bulk of it removed, tests passing * odds and ends * changeset * remove i18n * respond to Jeremys feedback * remove scoring things again * changeset * Remove `guessAndScore` (#1974) ## Summary: Remove `guessAndScore` from Renderer. This hasn't been used in learner-facing logic for a little bit now. The bulk of this PR is updating internal usage - tools for testing exercise correctness were using this (specifically in Cypress and our custom matchers for Jest); so most of the work was porting tests to use `scorePerseusItem` instead. ## Test plan: From a learner's perspective, this is dead code. So while this is a major API change, it's mostly removing dead code and updating tests. Tests should continue to run successfully. Author: handeyeco Reviewers: handeyeco, Myranae, jeremywiebe Required Reviewers: Approved By: Myranae, jeremywiebe Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️ [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️ [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️ [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️ [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️ [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (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: #1974
Summary:
Remove
guessAndScore
from Renderer. This hasn't been used in learner-facing logic for a little bit now. The bulk of this PR is updating internal usage - tools for testing exercise correctness were using this (specifically in Cypress and our custom matchers for Jest); so most of the work was porting tests to usescorePerseusItem
instead.Test plan:
From a learner's perspective, this is dead code. So while this is a major API change, it's mostly removing dead code and updating tests. Tests should continue to run successfully.