Repository navigation
test(frontend): cover lecture-view-prefs, login, usage-stats and useClickOutside - #2171
Open
noahkhomer18 wants to merge 1 commit into
Open
noahkhomer18 wants to merge 1 commit into
noahkhomer18 wants to merge 1 commit into
Conversation
…lickOutside Closes TUM-Dev#2166 Signed-off-by: Noah Khomer <108771853+noahkhomer18@users.noreply.github.com>
Author
|
The red e2e check is |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Closes #2166. Four modules in
frontend/src/lib/had no unit tests.Description
One test file next to each module, in the style of the existing
*.test.tsfiles there (samefetchspying asapi.test.ts,@vue/test-utilsfor the composable). Test-only: no source file or existing test is changed.lecture-view-prefs.test.ts: defaults when nothing is stored; every choice restored from its ownspa.key; a stored value that isn't one of the allowed words (the legacy numeric"1","true"for the boolean) is discarded; each change is written back, includinghideWatchedasyes/no.login.test.ts:fetchLoginOptionsreads the three fields from/api/v2/login-options, falls back to#3070B3when the colour is empty or left out of the JSON, and passes a failed request on;requestPasswordResetposts the address to/api/v2/users/reset-passwordand rejects withApiErroron failure.usage-stats.test.ts:pointswith a series, an empty series andundefined;usageStatsconverting thebigintstudent count and handling a response with no series at all;usageCountersandusageChartsin the order, titles and colours the old pages used.useClickOutside.test.ts: a press outside calls the handler, a press inside and a plainclickdon't, nothing happens while there is no target element, and thepointerdownlistener added on mount is the one removed on unmount.Steps for Testing
Each file catches a real break. With one line of the module changed, then restored:
lecture-view-prefs.tsallowed.includes(saved)checkexpected '1' to be 'newest'login.tsexpected '' to be '#3070B3'usage-stats.tsyto0pointsandusageStatsuseClickOutside.tsremoveEventListenercall a no-opremoveEventListenercalled 0 timesScreenshots
None, no UI change.