fix(tests): correct unit tests that pass without verifying behavior#5012
Open
PascalThuet wants to merge 3 commits into
Open
fix(tests): correct unit tests that pass without verifying behavior#5012PascalThuet wants to merge 3 commits into
PascalThuet wants to merge 3 commits into
Conversation
- DashParser: replace .bind() with arrow functions so parse() is actually called with the intended arguments (lines 17-28) - DashParser: move async fixture loading from describe() scope into a before() hook — Mocha does not support async describe (line 64) - MssParser: same .bind() fix (line 62) - Stream: await the Promise from setMediaSource() so the assertion runs before Mocha marks the test as passed (lines 93-98) Fixes Dash-Industry-Forum#5011 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
parseXml() can return a non-null object for any parseable XML-like string. The existing guard only checked for null, so non-MPD input (e.g. plain text) would pass validation and crash later when accessing .protocol on undefined. Add a check for the presence of MPD or Patch root elements before proceeding. This gives callers the expected 'failed to parse the manifest' error instead of a cryptic property access error. Bug exposed by fixing the .bind() test pattern in Dash-Industry-Forum#5012. Refs Dash-Industry-Forum#5011 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
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.
Summary
Fixes 4 unit tests that counted as "passed" without actually exercising the code they describe, fixes the parser bug they were hiding, and adds a missing test for Patch parsing. See #5011 for the full analysis.
Test fixes (commit 1):
dash.DashParser.jslines 17-28 — replace.bind()with arrow functions soparse()is actually calledmss.parser.MssParser.jsline 62 — same.bind()fixdash.DashParser.jsline 64 — moveawaitfrom unsupportedasync describe()into abefore()hookstreaming.Stream.jslines 93-98 —awaitthe Promise fromsetMediaSource()so the assertion runs before Mocha marks the test as passedParser fix (commit 2):
Fixing the
.bind()pattern revealed thatDashParser.parse()does not reject non-MPD XML input.parseXml()returns a non-null object for any parseable string, so the existingif (!manifest)guard passes, and the code crashes later on.protocolaccess.The fix strengthens the validation gate to check for
MPDorPatchroot elements:if (!manifest || (!manifest.MPD && !manifest.Patch)).New test (commit 3):
Adds a test verifying that
parse()correctly handles valid Patch XML input (MPD Patch per DASH-IF spec), exercising themanifest.Patchbranch that was previously untested.Impact
Test plan
'failed to parse the manifest'Fixes #5011
🤖 Generated with Claude Code