Fix null export (#69) and stale export after clear-retrace (#106)#108
Conversation
Adds Jest test suite and CI workflow. Guards enrichWithResponse against null/undefined from getResponse() (simplesamlphp#69), and filters undefined parsed entries from the export request list (simplesamlphp#106).
|
@khlr I think if you agree with the PR, we should merge and release a new version |
actions/checkout and actions/setup-node both updated to v6; node-version bumped from 20 to 24 per @tvdijen's inline review comments on PR simplesamlphp#108.
|
Done, @tvdijen — bumped checkout, setup-node, and node-version per your suggestions. CI is green. |
khlr
left a comment
There was a problem hiding this comment.
Thank you very much for this excellent contribution, Kellen! The fixes are so 'simple' – it's just crazy. But it's great that you found them.
I'm a huge fan of automated testing. Hence I'm delighted that, as well as carrying out the actual tests, you’ve also put the necessary infrastructure in place.
I’d actually thought about writing tests for SAML-tracer once before. In the end, though, my lack of experience with JavaScript testing and GitHub Actions put me off. It’s great that everything needed is now in place so we can easily add more tests in future!
|
I just published release 1.9.3 to AMO and CWS. After the store-reviews, the new version will be available in the respective store. Thanks again, Kellen! |
This fixes two bugs that both cause the export to silently fail.
The first (related to #69) happens when a request is blocked, cancelled, or interrupted before a response arrives.
getResponse()returnsundefined, which gets passed tocreateFromJSON. Inside there,JSON.stringify(undefined)doesn't produce a string — it returns the JS valueundefined— soJSON.parsethrows a SyntaxError. The exception goes uncaught,ui.exportResultis never updated, and the downloaded file contains justnull. The fix is a one-line null guard inenrichWithResponseinSAMLTraceIO.js.The second (related to #106) happens when a request entry has
isVisibleset butparsedwas never populated — this can occur whenonHeadersReceivedfires beforeonBeforeSendHeadersin a clear-and-retrace scenario. The export filter mapsreq.parsedacross all entries, producingundefinedin the array, which crashescreateFromJSONand leavesui.exportResultstale. The fix is.filter(Boolean)after the.mapcall inexportDialog.js.Both fixes are covered by Jest unit tests and Playwright end-to-end tests. The Playwright suite lives on the
playwright-testingbranch at https://github.com/kellenmurphy/SAML-tracer/tree/playwright-testing — see E2E_TESTS.md there for context and instructions on running the tests. Each bug test was confirmed to fail on unfixed code and pass with the fix applied.