Add a "flipbook" story for testing multiple Perseus items#3680
Add a "flipbook" story for testing multiple Perseus items#3680benchristel wants to merge 21 commits into
Conversation
…removed and re-added
|
Size Change: 0 B Total Size: 506 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
The "model" pattern is somewhat unusual for us, but it's a lot less code than the equivalent reducer + actions would be.
The downside is that if you forget to call this.observer() in a mutating method, the view doesn't update.
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (3f49984) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3680If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3680If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3680 |
| if (this.clampItemIndex(requestedIndex) === requestedIndex) { | ||
| this.targetItemIndex = requestedIndex; | ||
| this.observer(); | ||
| } |
There was a problem hiding this comment.
Perhaps if the requested index is too low or too high, we should update targetItemIndex to the clamped value.
The only time we really don't want to set targetItemIndex is if parseInt returns NaN.
| model.requestItemNumber("3"); | ||
|
|
||
| expect(model.present().selectedItemNumber.value).toBe("3"); | ||
| expect(observer).toHaveBeenCalledTimes(2); |
There was a problem hiding this comment.
I don't love that the number of observer calls is coupled to the test setup. Maybe I should rethink the design of these tests. If we could clear observer calls before the act section, this assertion could be changed to expect a single call.
Summary:
We have an upcoming playtest for the input-number widget. Because input-number
widgets are deprecated and somewhat rare / hard to find on khanacademy.org, we
want an easier way to manually test them (including rendering, user
interaction, and scoring).
This flipbook story lets you paste in a bunch of newline-separated Perseus
items and page through them one at a time.
Issue: none
Test plan: