Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
"test:ci": "npm run test:mocha && npm run test:wdio:ci",
"test:mocha": "blockly-scripts test",
"test:wdio": "npm run wdio:clean && npm run wdio:run",
"test:screenreader": "npm run wdio:clean && npm run screenreader:run",
"test:wdio:ci": "npm run wdio:clean && npm run wdio:run:ci",
"wdio:build": "npm run wdio:build:app && npm run wdio:build:tests",
"wdio:build:app": "cd test/webdriverio && webpack",
"wdio:build:tests": "tsc -p ./test/webdriverio/test/tsconfig.json",
"wdio:clean": "cd test/webdriverio/test && rm -rf dist",
"wdio:run": "npm run wdio:build && cd test/webdriverio/test && npx mocha dist",
"screenreader:run": "npm run wdio:build && cd test/webdriverio/test && npx mocha --timeout 30000 --require dist/screenreader/hooks.js dist/screenreader",
"wdio:run:ci": "npm run wdio:build && cd test/webdriverio/test && npx mocha --timeout 30000 dist"
},
"main": "./dist/index.js",
Expand Down Expand Up @@ -58,6 +60,7 @@
"@blockly/field-colour": "^6.0.2",
"@eslint/eslintrc": "^2.1.2",
"@eslint/js": "^8.49.0",
"@guidepup/guidepup": "^0.24.0",
"@types/chai": "^5.2.1",
"@types/mocha": "^10.0.10",
"@types/p5": "^1.7.6",
Expand Down
53 changes: 53 additions & 0 deletions test/webdriverio/test/screenreader/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2025 Raspberry Pi Foundation
* SPDX-License-Identifier: Apache-2.0
*/

import * as chai from 'chai';
import * as Blockly from 'blockly/core';

Check warning on line 8 in test/webdriverio/test/screenreader/basic.ts

View workflow job for this annotation

GitHub Actions / Eslint check

'Blockly' is defined but never used
import {
PAUSE_TIME,
testFileLocations,
testSetup,
focusWorkspace,
} from '../test_setup.js';
import {voiceOver} from '@guidepup/guidepup';

suite('Screenreader', function () {
// Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
if (PAUSE_TIME) this.timeout(0);

// Clear the workspace and load start blocks.
setup(async function () {
this.browser = await testSetup(testFileLocations.BASE, this.timeout());
await this.browser.pause(PAUSE_TIME);
chai.config.truncateThreshold = 0;
await focusWorkspace(this.browser);
});

test('Denotes blocks that begin a stack', async function () {
await voiceOver.press('ArrowRight');
const log = await voiceOver.lastSpokenPhrase();
chai.assert.include(log, 'Begin stack, setup container block');
});

test('Narrates block field values', async function () {
await voiceOver.press('ArrowRight');
await voiceOver.press('ArrowRight');
const log = await voiceOver.lastSpokenPhrase();
chai.assert.include(
log,
'create canvas with width, 400, height, 400, has inputs statement block',
);
});

test('Narrates toolbox categories', async function () {
await voiceOver.press('t');
const log = await voiceOver.lastSpokenPhrase();
chai.assert.include(
log,
'Logic blocks group selected outline row (1 of 9)',
);
});
});
28 changes: 28 additions & 0 deletions test/webdriverio/test/screenreader/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2025 Raspberry Pi Foundation
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Hooks to run before the first test and after the last test.
* These create a shared chromedriver instance, so we don't have to fire up
* a new one for every suite.
*/
import {RootHookObject} from 'mocha';
import {voiceOver} from '@guidepup/guidepup';
import {exec} from 'child_process';

export const mochaHooks: RootHookObject = {
async beforeAll(this: Mocha.Context) {
return voiceOver.start();
},
async beforeEach() {
return exec(
'osascript -e \'tell application "System Events" to set frontmost of the first process whose name is "Google Chrome" to true\'',
);
},
async afterAll() {
return voiceOver.stop();
},
};
Loading