blockly-samples
blockly-samples copied to clipboard
fix: keyboard navigation tests
The changes
Actual keyboard nav implementation: Adjust how it's calling a superclass function in a strange bit of monkeypatching code. This change is necessary because of the switch to ES6 classes.
Test code:
- Stop overriding
Blockly.utils.dom.getFastTextWidthWithSizeString.- This is no longer accessible for replacement. Unfortunately, without this monkeypatch, the tests fail any time they try to render a field with text that has to be measured.
- Replace text fields with colour fields in test blocks.
- Colour fields can render just fine, because they don't need text width measurement. The fields are mostly used to test that the correct block has been selected after a series of key presses. That happens by looking at the value of the field, which is set in the hardcoded toolbox definition. I updated the block definitions, toolbox definitions, and test assertions to all be for my colour fields.
- Don't access a private field in
MarkerManagerfor a test assert. Particularly since that field's name has changed. Use the getter instead. - Call
this.navigation.removeWorkspace(this.workspace)in the test teardown for each suite. Otherwise the workspace is disposed before being removed fromthis.navigation, which means that thenavigationobject is manipulating an already-disposedWorkspaceSvgobject.- I'm not sure why this worked before.
Tested
In the keyboard nav playground and with automated tests.