Skip to content

Commit ef1faa8

Browse files
test: add scenario with workspace and block comments (#620)
Aim is to illustrate a bug where a new workspace comment has different behaviour to one that's been loaded. Will also be useful once navigation is supported for comments themselves.
1 parent 82f5998 commit ef1faa8

File tree

2 files changed

+120
-3
lines changed

2 files changed

+120
-3
lines changed

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
navigation test blocks
206206
</option>
207207
<option value="moveTestBlocks">move test blocks</option>
208+
<option value="comments">comments</option>
208209
</select>
209210
</div>
210211
<div>

test/loadTestBlocks.js

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,121 @@ const moveTestBlocks = {
862862
},
863863
};
864864

865+
const comments = {
866+
'workspaceComments': [
867+
{
868+
'height': 100,
869+
'width': 146.63990783691406,
870+
'id': 'workspace_comment_1',
871+
'x': 96.5390625,
872+
'y': 531.42578125,
873+
'text': 'Workspace comment',
874+
},
875+
],
876+
'blocks': {
877+
'languageVersion': 0,
878+
'blocks': [
879+
{
880+
'type': 'p5_setup',
881+
'id': 'p5_setup_1',
882+
'x': 0,
883+
'y': 75,
884+
'deletable': false,
885+
'inputs': {
886+
'STATEMENTS': {
887+
'block': {
888+
'type': 'p5_canvas',
889+
'id': 'create_canvas_1',
890+
'deletable': false,
891+
'movable': false,
892+
'fields': {
893+
'WIDTH': 400,
894+
'HEIGHT': 400,
895+
},
896+
'next': {
897+
'block': {
898+
'type': 'p5_background_color',
899+
'id': 'set_background_color_1',
900+
'inputs': {
901+
'COLOR': {
902+
'shadow': {
903+
'type': 'colour_picker',
904+
'id': 'set_background_color_1_color',
905+
'fields': {
906+
'COLOUR': '#9999ff',
907+
},
908+
},
909+
},
910+
},
911+
},
912+
},
913+
},
914+
},
915+
},
916+
},
917+
{
918+
'type': 'p5_draw',
919+
'id': 'p5_draw_1',
920+
'x': 0,
921+
'y': 332,
922+
'deletable': false,
923+
'inputs': {
924+
'STATEMENTS': {
925+
'block': {
926+
'type': 'simple_circle',
927+
'id': 'draw_circle_1',
928+
'icons': {
929+
'comment': {
930+
'text': 'Pinned block comment',
931+
'pinned': true,
932+
'height': 80,
933+
'width': 160,
934+
},
935+
},
936+
'inputs': {
937+
'COLOR': {
938+
'shadow': {
939+
'type': 'colour_picker',
940+
'id': 'draw_circle_1_color',
941+
'fields': {
942+
'COLOUR': '#ffff00',
943+
},
944+
},
945+
},
946+
},
947+
'next': {
948+
'block': {
949+
'type': 'simple_circle',
950+
'id': 'draw_circle_2',
951+
'icons': {
952+
'comment': {
953+
'text': 'Unpinned block comment',
954+
'pinned': false,
955+
'height': 80,
956+
'width': 160,
957+
},
958+
},
959+
'inputs': {
960+
'COLOR': {
961+
'shadow': {
962+
'type': 'colour_picker',
963+
'id': 'draw_circle_2_color',
964+
'fields': {
965+
'COLOUR': '#000000',
966+
},
967+
},
968+
},
969+
},
970+
},
971+
},
972+
},
973+
},
974+
},
975+
},
976+
],
977+
},
978+
};
979+
865980
/**
866981
* Loads saved state from local storage into the given workspace.
867982
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
@@ -870,11 +985,12 @@ const moveTestBlocks = {
870985
export const load = function (workspace, scenarioString) {
871986
const scenarioMap = {
872987
'blank': blankCanvas,
873-
'sun': sunnyDay,
874-
'simpleCircle': simpleCircle,
988+
'comments': comments,
875989
'moreBlocks': moreBlocks,
876-
'navigationTestBlocks': navigationTestBlocks,
877990
'moveTestBlocks': moveTestBlocks,
991+
'navigationTestBlocks': navigationTestBlocks,
992+
'simpleCircle': simpleCircle,
993+
'sun': sunnyDay,
878994
};
879995

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

0 commit comments

Comments
 (0)