Skip to content

Commit c9d8689

Browse files
johnneskyRoboErikG
andauthored
chore: Fix and enable field navigation unit tests. (#509)
Co-authored-by: RoboErikG <[email protected]>
1 parent 020dab5 commit c9d8689

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

test/webdriverio/test/basic_test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ suite('Keyboard navigation on Blocks', function () {
256256
.to.include('controls_repeat_ext_1_connection_');
257257
});
258258

259-
// This test fails because the curly quote icons get selected.
260-
test.skip('Right from text block selects input and skips curly quote icons', async function () {
259+
test('Right from text block selects shadow block then field', async function () {
261260
await tabNavigateToWorkspace(this.browser);
262261
await this.browser.pause(PAUSE_TIME);
263262
await setCurrentCursorNodeById(this.browser, 'text_print_1');
@@ -270,10 +269,16 @@ suite('Keyboard navigation on Blocks', function () {
270269
await this.browser.keys(Key.ArrowRight);
271270
await this.browser.pause(PAUSE_TIME);
272271

273-
chai.assert.equal(
274-
await getCurrentFocusNodeId(this.browser),
275-
'text_print_1',
276-
);
272+
chai
273+
.expect(await getCurrentFocusNodeId(this.browser))
274+
.to.include('text_1_field_');
275+
276+
await this.browser.keys(Key.ArrowRight);
277+
await this.browser.pause(PAUSE_TIME);
278+
279+
chai
280+
.expect(await getCurrentFocusNodeId(this.browser))
281+
.to.include('text_print_1_connection_');
277282
chai.assert.equal(
278283
await getFocusedConnectionType(this.browser),
279284
Blockly.ConnectionType.NEXT_STATEMENT,
@@ -282,7 +287,7 @@ suite('Keyboard navigation on Blocks', function () {
282287
});
283288

284289
// TODO(#499) These tests fail because focusing on a field doesn't update the cursor
285-
suite.skip('Keyboard navigation on Fields', function () {
290+
suite('Keyboard navigation on Fields', function () {
286291
// Setting timeout to unlimited as these tests take a longer time to run than most mocha test
287292
this.timeout(0);
288293

@@ -337,7 +342,7 @@ suite.skip('Keyboard navigation on Fields', function () {
337342
.expect(await getCurrentFocusNodeId(this.browser))
338343
.to.include('p5_canvas_1_field_');
339344

340-
chai.assert.equal(await getFocusedFieldName(this.browser), 'HIGHT');
345+
chai.assert.equal(await getFocusedFieldName(this.browser), 'HEIGHT');
341346
});
342347

343348
test('Left from second field selects first field', async function () {
@@ -371,10 +376,9 @@ suite.skip('Keyboard navigation on Fields', function () {
371376
await this.browser.keys(Key.ArrowRight);
372377
await this.browser.pause(PAUSE_TIME);
373378

374-
chai.assert.containSubset(
375-
await getCurrentFocusNodeId(this.browser),
376-
'p5_canvas_1_connection_',
377-
);
379+
chai
380+
.expect(await getCurrentFocusNodeId(this.browser))
381+
.to.include('p5_canvas_1_connection_');
378382
});
379383

380384
test("Down from field selects block's next connection", async function () {
@@ -417,7 +421,7 @@ suite.skip('Keyboard navigation on Fields', function () {
417421

418422
chai.assert.equal(
419423
await getFocusedConnectionType(this.browser),
420-
Blockly.ConnectionType.INPUT_VALUE,
424+
Blockly.ConnectionType.NEXT_STATEMENT,
421425
);
422426
});
423427
});

test/webdriverio/test/insert_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
testSetup,
1616
} from './test_setup.js';
1717

18-
suite.only('Insert test', function () {
18+
suite('Insert test', function () {
1919
// Setting timeout to unlimited as these tests take longer time to run
2020
this.timeout(0);
2121

test/webdriverio/test/test_setup.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ export async function setCurrentCursorNodeByIdAndFieldName(
208208
const block = workspaceSvg.getBlockById(blockId);
209209
const field = block?.getField(fieldName);
210210
if (field) {
211-
field.getFocusableElement()?.focus();
211+
// TODO: Stop referencing getCursor() and use focus() instead.
212+
// getCursor().setCurNode() calls Marker.setCurNode(), but focus() does
213+
// not accomplish the same goal yet.
214+
workspaceSvg.getCursor()?.setCurNode(field);
215+
// field.getFocusableElement()?.focus();
212216
}
213217
},
214218
blockId,

0 commit comments

Comments
 (0)