fix(tests): revert change in marker_svg to keep keyboard nav tests working #6457
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.
The basics
npm run format
andnpm run lint
The details
Resolves
Resolves one of the issues blocking google/blockly-samples#1297 (comment)
Proposed Changes
Use a cast and checking for a property, rather than an
instanceof
check, to make it safe to callbeginElement()
on a marker. This avoids breaking tests when run in jsdom.Behavior Before Change
Tests broke becuase
SVGAnimationElement
was not defined when running with jsdom.Behavior After Change
These tests pass (although a different set of tests fails >.<)
Reason for Changes
The tests are running in Mocha, and using jsdom to pretend that they are in a rendered page. The marker SVG and similar elements are created but certain classes don't exist.
SVGAnimationElement
is one of them, which triggered a failure.Note that the tests running rendered in jsdom is a bit weird, but they cannot run in headless mode because keyboard navigation is not built for non-rendered workspaces.
Test Coverage
I built, packaged, and linked changes so that I could run keyboard navigation tests. The tests no longer fail on
SVGAnimationElement
, although two tests still fail.Documentation
Additional Information
Once this change is in Beka will cut a beta so that we can test it over on samples and move the
blocky-9-beta
branch one step closer to working.