Skip to content

Commit 9765d35

Browse files
RoboErikGjohnnesky
andauthored
feat: Add additional keyboard navigation tests (#496)
* chore: Implement field navigation tests. * Update expected block with the new one it ends on * Refactor tests to use FocusManager/focus() and comment out failing tests * Use .skip instead of commenting out tests * Fix or skip tests as needed * Add TODO for failing test * Auto-format fixes --------- Co-authored-by: John Nesky <[email protected]>
1 parent 44af6c4 commit 9765d35

File tree

5 files changed

+540
-89
lines changed

5 files changed

+540
-89
lines changed

test/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
<option value="sun">sun</option>
165165
<option value="blank">blank canvas</option>
166166
<option value="moreBlocks">more blocks</option>
167+
<option value="navigationTestBlocks">
168+
navigation test blocks
169+
</option>
167170
</select>
168171
</div>
169172
<div>

test/loadTestBlocks.js

Lines changed: 158 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const simpleCircle = {
220220
},
221221
{
222222
'type': 'p5_draw',
223-
'id': 'draw_root',
223+
'id': 'p5_draw_1',
224224
'x': 0,
225225
'y': 332,
226226
'deletable': false,
@@ -414,6 +414,162 @@ const moreBlocks = {
414414
},
415415
};
416416

417+
const navigationTestBlocks = {
418+
'blocks': {
419+
'languageVersion': 0,
420+
'blocks': [
421+
{
422+
'type': 'p5_setup',
423+
'id': 'p5_setup_1',
424+
'x': 0,
425+
'y': 75,
426+
'deletable': false,
427+
'inputs': {
428+
'STATEMENTS': {
429+
'block': {
430+
'type': 'p5_canvas',
431+
'id': 'p5_canvas_1',
432+
'deletable': false,
433+
'movable': false,
434+
'fields': {
435+
'WIDTH': 400,
436+
'HEIGHT': 400,
437+
},
438+
},
439+
},
440+
},
441+
},
442+
{
443+
'type': 'p5_draw',
444+
'id': 'p5_draw_1',
445+
'x': 0,
446+
'y': 332,
447+
'deletable': false,
448+
'inputs': {
449+
'STATEMENTS': {
450+
'block': {
451+
'type': 'controls_if',
452+
'id': 'controls_if_1',
453+
'next': {
454+
'block': {
455+
'type': 'controls_if',
456+
'id': 'controls_if_2',
457+
'inputs': {
458+
'IF0': {
459+
'block': {
460+
'type': 'logic_boolean',
461+
'id': 'logic_boolean_1',
462+
'fields': {
463+
'BOOL': 'TRUE',
464+
},
465+
},
466+
},
467+
'DO0': {
468+
'block': {
469+
'type': 'text_print',
470+
'id': 'text_print_1',
471+
'inputs': {
472+
'TEXT': {
473+
'shadow': {
474+
'type': 'text',
475+
'id': 'text_1',
476+
'fields': {
477+
'TEXT': 'abc',
478+
},
479+
},
480+
},
481+
},
482+
},
483+
},
484+
},
485+
'next': {
486+
'block': {
487+
'type': 'controls_repeat',
488+
'id': 'controls_repeat_1',
489+
'fields': {
490+
'TIMES': 10,
491+
},
492+
'inputs': {
493+
'DO': {
494+
'block': {
495+
'type': 'draw_emoji',
496+
'id': 'draw_emoji_1',
497+
'fields': {
498+
'emoji': '❤️',
499+
},
500+
'next': {
501+
'block': {
502+
'type': 'simple_circle',
503+
'id': 'simple_circle_1',
504+
'inputs': {
505+
'COLOR': {
506+
'shadow': {
507+
'type': 'colour_picker',
508+
'id': 'colour_picker_1',
509+
'fields': {
510+
'COLOUR': '#ff0000',
511+
},
512+
},
513+
},
514+
},
515+
},
516+
},
517+
},
518+
},
519+
},
520+
'next': {
521+
'block': {
522+
'type': 'controls_repeat_ext',
523+
'id': 'controls_repeat_ext_1',
524+
'inputs': {
525+
'TIMES': {
526+
'shadow': {
527+
'type': 'math_number',
528+
'id': 'math_number_1',
529+
'fields': {
530+
'NUM': 10,
531+
},
532+
},
533+
'block': {
534+
'type': 'math_modulo',
535+
'id': 'math_modulo_1',
536+
'inputs': {
537+
'DIVIDEND': {
538+
'shadow': {
539+
'type': 'math_number',
540+
'id': 'math_number_2',
541+
'fields': {
542+
'NUM': 64,
543+
},
544+
},
545+
},
546+
'DIVISOR': {
547+
'shadow': {
548+
'type': 'math_number',
549+
'id': 'math_number_3',
550+
'fields': {
551+
'NUM': 10,
552+
},
553+
},
554+
},
555+
},
556+
},
557+
},
558+
},
559+
},
560+
},
561+
},
562+
},
563+
},
564+
},
565+
},
566+
},
567+
},
568+
},
569+
],
570+
},
571+
};
572+
417573
/**
418574
* Loads saved state from local storage into the given workspace.
419575
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
@@ -425,6 +581,7 @@ export const load = function (workspace, scenarioString) {
425581
'sun': sunnyDay,
426582
'simpleCircle': simpleCircle,
427583
'moreBlocks': moreBlocks,
584+
'navigationTestBlocks': navigationTestBlocks,
428585
};
429586

430587
const data = JSON.stringify(scenarioMap[scenarioString]);

0 commit comments

Comments
 (0)