Test typescriptification continued#8327
Conversation
…ncryption-test.ts Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
…r-test.ts Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
Codecov Report
@@ Coverage Diff @@
## develop #8327 +/- ##
===========================================
- Coverage 30.83% 30.74% -0.10%
===========================================
Files 893 892 -1
Lines 50781 50706 -75
Branches 12923 12906 -17
===========================================
- Hits 15657 15588 -69
+ Misses 35124 35118 -6
|
turt2live
left a comment
There was a problem hiding this comment.
otherwise lgtm - the questions are legitimate questions, not necessarily hints that things need to change.
| // This test uses localStorage, clear it beforehand | ||
| localStorage.clear(); | ||
| // this functionality is commented out in DecryptionFailureTracker | ||
| // commenting as well as xit here to avoid fixing ts issues for dead code |
There was a problem hiding this comment.
can we just delete it? (and the code in DecryptionFailureTracker)
we have git history if it needs to be recovered.
| const error1 = new MockDecryptionError(undefined); | ||
| const error2 = new MockDecryptionError(undefined); | ||
| const error3 = new MockDecryptionError(undefined); |
There was a problem hiding this comment.
I think this was testing the unknown error code behaviour? undefined does aggregate, but so should the 3 stringy error codes (according to the test)
There was a problem hiding this comment.
@duxovni is this the correct behaviour? Should DecryptionFailureTracker actually being aggregating the errors my their mapped code before calling the tracking function in trackFailures? Feels like the description of the test and the actual behaviour are at odds
| class MockDecryptionError extends Error { | ||
| constructor(code) { | ||
| constructor( | ||
| public readonly errcode, |
| const counts = {}; | ||
| const tracker = new DecryptionFailureTracker( | ||
| (total, errorCode) => counts[errorCode] = (counts[errorCode] || 0) + total, | ||
| (errorCode) => Array.from(errorCode).reverse().join(''), |
There was a problem hiding this comment.
this seemed important to the test?
There was a problem hiding this comment.
This was testing that error codes are being run through this map function by asserting the reversed error code was present on the error map expect(counts['1_EDOC_RORRE']).toBe(1)
Because types, and I think because it tests the code in use in our app better, I've tested using the actual error code mapper that the singleton instance uses (
matrix-react-sdk/src/DecryptionFailureTracker.ts
Lines 48 to 60 in 113d69c
and asserted that
MEGOLM_UNKNOWN_INBOUND_SESSION_ID maps to OlmKeysNotSentError and that the track function is called with the mapped error code.
|
|
||
| import { | ||
| MatrixClient, | ||
| Room } from 'matrix-js-sdk/src/matrix'; |
There was a problem hiding this comment.
| Room } from 'matrix-js-sdk/src/matrix'; | |
| Room, | |
| } from 'matrix-js-sdk/src/matrix'; |
Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
Signed-off-by: Kerry Archibald <kerrya@element.io>
duxovni
left a comment
There was a problem hiding this comment.
I already typescriptified test/DecryptionFailureTracker-test.ts in #8272 (along with changing some functionality and adding a bunch of other tests); would you be up for reverting this file, and leaving feedback there if there's anything from this PR I should add into mine?
turt2live
left a comment
There was a problem hiding this comment.
thanks! apologies for the horribly long review (please poke me in a DM if that happens)
|
Kudos, SonarCloud Quality Gate passed!
|








element-hq/element-web#21965
This change is marked as an internal change (Task), so will not be included in the changelog.
Preview: https://pr8327--matrix-react-sdk.netlify.app
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.