Skip to content

Commit f9c2bbd

Browse files
committed
chore: format fixes & added/updated docs.
1 parent fe7fba2 commit f9c2bbd

File tree

3 files changed

+69
-44
lines changed

3 files changed

+69
-44
lines changed

test/webdriverio/test/basic_test.ts

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,7 @@ suite('Keyboard navigation on Fields', function () {
262262
test('Up from first field selects block', async function () {
263263
await tabNavigateToWorkspace(this.browser);
264264
await this.browser.pause(PAUSE_TIME);
265-
await focusOnBlockField(
266-
this.browser,
267-
'p5_canvas_1',
268-
'WIDTH',
269-
);
265+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
270266
await this.browser.pause(PAUSE_TIME);
271267
await keyUp(this.browser);
272268

@@ -279,11 +275,7 @@ suite('Keyboard navigation on Fields', function () {
279275
test('Left from first field selects block', async function () {
280276
await tabNavigateToWorkspace(this.browser);
281277
await this.browser.pause(PAUSE_TIME);
282-
await focusOnBlockField(
283-
this.browser,
284-
'p5_canvas_1',
285-
'WIDTH',
286-
);
278+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
287279
await this.browser.pause(PAUSE_TIME);
288280
await keyLeft(this.browser);
289281

@@ -296,11 +288,7 @@ suite('Keyboard navigation on Fields', function () {
296288
test('Right from first field selects second field', async function () {
297289
await tabNavigateToWorkspace(this.browser);
298290
await this.browser.pause(PAUSE_TIME);
299-
await focusOnBlockField(
300-
this.browser,
301-
'p5_canvas_1',
302-
'WIDTH',
303-
);
291+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
304292
await this.browser.pause(PAUSE_TIME);
305293
await keyRight(this.browser);
306294

@@ -314,11 +302,7 @@ suite('Keyboard navigation on Fields', function () {
314302
test('Left from second field selects first field', async function () {
315303
await tabNavigateToWorkspace(this.browser);
316304
await this.browser.pause(PAUSE_TIME);
317-
await focusOnBlockField(
318-
this.browser,
319-
'p5_canvas_1',
320-
'HEIGHT',
321-
);
305+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
322306
await this.browser.pause(PAUSE_TIME);
323307
await keyLeft(this.browser);
324308

@@ -332,11 +316,7 @@ suite('Keyboard navigation on Fields', function () {
332316
test('Right from second field selects next block', async function () {
333317
await tabNavigateToWorkspace(this.browser);
334318
await this.browser.pause(PAUSE_TIME);
335-
await focusOnBlockField(
336-
this.browser,
337-
'p5_canvas_1',
338-
'HEIGHT',
339-
);
319+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
340320
await this.browser.pause(PAUSE_TIME);
341321
await keyRight(this.browser);
342322

@@ -348,11 +328,7 @@ suite('Keyboard navigation on Fields', function () {
348328
test('Down from field selects next block', async function () {
349329
await tabNavigateToWorkspace(this.browser);
350330
await this.browser.pause(PAUSE_TIME);
351-
await focusOnBlockField(
352-
this.browser,
353-
'p5_canvas_1',
354-
'WIDTH',
355-
);
331+
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
356332
await this.browser.pause(PAUSE_TIME);
357333
await keyDown(this.browser);
358334

@@ -364,11 +340,7 @@ suite('Keyboard navigation on Fields', function () {
364340
test("Down from field selects block's child block", async function () {
365341
await tabNavigateToWorkspace(this.browser);
366342
await this.browser.pause(PAUSE_TIME);
367-
await focusOnBlockField(
368-
this.browser,
369-
'controls_repeat_1',
370-
'TIMES',
371-
);
343+
await focusOnBlockField(this.browser, 'controls_repeat_1', 'TIMES');
372344
await this.browser.pause(PAUSE_TIME);
373345
await keyDown(this.browser);
374346

test/webdriverio/test/flyout_test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ suite.only('Toolbox and flyout test', function () {
103103
// Focus should restore to the initial div element. See:
104104
// https://github.com/google/blockly-keyboard-experimentation/issues/523.
105105
const activeElementId = await this.browser.execute(
106-
() => document.activeElement?.id);
106+
() => document.activeElement?.id,
107+
);
107108
chai.assert.strictEqual(activeElementId, 'focusableDiv');
108109
});
109110

@@ -227,6 +228,14 @@ suite.only('Toolbox and flyout test', function () {
227228
});
228229
});
229230

231+
/**
232+
* Checks if the flyout is currently open.
233+
*
234+
* This throws an error if the current main workspace has no flyout.
235+
*
236+
* @param browser The active WebdriverIO Browser object.
237+
* @returns A promise indicating whether the flyout is currently open.
238+
*/
230239
async function checkIfFlyoutIsOpen(
231240
browser: WebdriverIO.Browser,
232241
): Promise<boolean> {

test/webdriverio/test/test_setup.ts

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function driverTeardown() {
9595
export async function testSetup(
9696
playgroundUrl: string,
9797
): Promise<webdriverio.Browser> {
98-
if (!driver) {
98+
if (!driver) {
9999
driver = await driverSetup();
100100
}
101101
await driver.url(playgroundUrl);
@@ -232,6 +232,8 @@ export async function currentFocusIsMainWorkspace(
232232
/**
233233
* Focuses and selects a block with the provided ID.
234234
*
235+
* This throws an error if no block exists for the specified ID.
236+
*
235237
* @param browser The active WebdriverIO Browser object.
236238
* @param blockId The ID of the block to select.
237239
*/
@@ -250,6 +252,9 @@ export async function focusOnBlock(
250252
/**
251253
* Focuses and selects the field of a block given a block ID and field name.
252254
*
255+
* This throws an error if no block exists for the specified ID, or if the block
256+
* corresponding to the specified ID has no field with the provided name.
257+
*
253258
* @param browser The active WebdriverIO Browser object.
254259
* @param blockId The ID of the block to select.
255260
* @param fieldName The name of the field on the block to select.
@@ -415,30 +420,69 @@ export async function tabNavigateForward(browser: WebdriverIO.Browser) {
415420
await browser.pause(PAUSE_TIME);
416421
}
417422

423+
/**
424+
* Navigates backward to the test page's previous tab stop.
425+
*
426+
* @param browser The active WebdriverIO Browser object.
427+
*/
418428
export async function tabNavigateBackward(browser: WebdriverIO.Browser) {
419429
await browser.keys([webdriverio.Key.Shift, webdriverio.Key.Tab]);
420430
await browser.pause(PAUSE_TIME);
421431
}
422432

423-
export async function keyLeft(browser: WebdriverIO.Browser, times: number = 1) {
433+
/**
434+
* Sends the keyboard event for arrow key left.
435+
*
436+
* @param browser The active WebdriverIO Browser object.
437+
* @param times The number of times to repeat the key press (default is 1).
438+
*/
439+
export async function keyLeft(browser: WebdriverIO.Browser, times = 1) {
424440
await sendKeyAndWait(browser, webdriverio.Key.ArrowLeft, times);
425441
}
426442

427-
export async function keyRight(
428-
browser: WebdriverIO.Browser, times: number = 1) {
443+
/**
444+
* Sends the keyboard event for arrow key right.
445+
*
446+
* @param browser The active WebdriverIO Browser object.
447+
* @param times The number of times to repeat the key press (default is 1).
448+
*/
449+
export async function keyRight(browser: WebdriverIO.Browser, times = 1) {
429450
await sendKeyAndWait(browser, webdriverio.Key.ArrowRight, times);
430451
}
431452

432-
export async function keyUp(browser: WebdriverIO.Browser, times: number = 1) {
453+
/**
454+
* Sends the keyboard event for arrow key up.
455+
*
456+
* @param browser The active WebdriverIO Browser object.
457+
* @param times The number of times to repeat the key press (default is 1).
458+
*/
459+
export async function keyUp(browser: WebdriverIO.Browser, times = 1) {
433460
await sendKeyAndWait(browser, webdriverio.Key.ArrowUp, times);
434461
}
435462

436-
export async function keyDown(browser: WebdriverIO.Browser, times: number = 1) {
463+
/**
464+
* Sends the keyboard event for arrow key down.
465+
*
466+
* @param browser The active WebdriverIO Browser object.
467+
* @param times The number of times to repeat the key press (default is 1).
468+
*/
469+
export async function keyDown(browser: WebdriverIO.Browser, times = 1) {
437470
await sendKeyAndWait(browser, webdriverio.Key.ArrowDown, times);
438471
}
439472

440-
export async function sendKeyAndWait(
441-
browser: WebdriverIO.Browser, key: string, times: number) {
473+
/**
474+
* Sends the specified key for the specified number of times, waiting between
475+
* each key press to allow changes to keep up.
476+
*
477+
* @param browser The active WebdriverIO Browser object.
478+
* @param key The WebdriverIO representative key value to press.
479+
* @param times The number of times to repeat the key press.
480+
*/
481+
async function sendKeyAndWait(
482+
browser: WebdriverIO.Browser,
483+
key: string,
484+
times: number,
485+
) {
442486
for (let i = 0; i < times; i++) {
443487
await browser.keys(key);
444488
await browser.pause(PAUSE_TIME);

0 commit comments

Comments
 (0)