|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | import * as chai from 'chai'; |
| 8 | +import * as Blockly from 'blockly'; |
8 | 9 | import {Key} from 'webdriverio'; |
9 | 10 | import { |
10 | 11 | getFocusedBlockType, |
@@ -103,4 +104,32 @@ suite('Insert test', function () { |
103 | 104 | await getFocusedBlockType(this.browser), |
104 | 105 | ); |
105 | 106 | }); |
| 107 | + |
| 108 | + test('Does not insert between immovable blocks', async function () { |
| 109 | + // Focus the create canvas block; we want to ensure that the newly |
| 110 | + // inserted block is not attached to its next connection, because doing |
| 111 | + // so would splice it into an immovable stack. |
| 112 | + await focusOnBlock(this.browser, 'create_canvas_1'); |
| 113 | + await this.browser.execute(() => { |
| 114 | + Blockly.getMainWorkspace() |
| 115 | + .getAllBlocks() |
| 116 | + .forEach((b) => b.setMovable(false)); |
| 117 | + }); |
| 118 | + await tabNavigateToToolbox(this.browser); |
| 119 | + |
| 120 | + // Insert 'if' block |
| 121 | + await keyRight(this.browser); |
| 122 | + // Choose. |
| 123 | + await sendKeyAndWait(this.browser, Key.Enter); |
| 124 | + // Confirm position. |
| 125 | + await sendKeyAndWait(this.browser, Key.Enter); |
| 126 | + |
| 127 | + // Assert inserted inside first block p5_setup not at top-level. |
| 128 | + chai.assert.equal('controls_if', await getFocusedBlockType(this.browser)); |
| 129 | + await keyUp(this.browser); |
| 130 | + chai.assert.equal( |
| 131 | + 'p5_background_color', |
| 132 | + await getFocusedBlockType(this.browser), |
| 133 | + ); |
| 134 | + }); |
106 | 135 | }); |
0 commit comments