Skip to content

Commit 27b375f

Browse files
committed
feat: Record & upload test failures in CI.
1 parent 2cc7478 commit 27b375f

19 files changed

+118
-6
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ jobs:
6969
- name: Run tests (up to 50 times)
7070
run: |
7171
cd main/test/webdriverio/test
72-
for i in $(seq 1 50);
73-
do
72+
#for i in $(seq 1 50);
73+
#do
7474
echo "Attempt $i"
7575
npx mocha --timeout 30000 dist
76-
done
76+
#done
77+
78+
- name: Upload test failure screenshots
79+
if: always()
80+
uses: actions/upload-artifact@v5
81+
with:
82+
name: test-failure-screenshots
83+
path: test/webdriverio/test/failures
7784

7885
webdriverio_tests:
7986
name: WebdriverIO tests (against pinned v12)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"wdio:build": "npm run wdio:build:app && npm run wdio:build:tests",
2323
"wdio:build:app": "cd test/webdriverio && webpack",
2424
"wdio:build:tests": "tsc -p ./test/webdriverio/test/tsconfig.json",
25-
"wdio:clean": "cd test/webdriverio/test && rm -rf dist",
26-
"wdio:run": "npm run wdio:build && cd test/webdriverio/test && npx mocha dist",
25+
"wdio:clean": "cd test/webdriverio/test && rm -rf dist && rm -rf failures",
26+
"wdio:run": "npm run wdio:build && cd test/webdriverio/test && mkdir failures && npx mocha dist",
2727
"wdio:run:ci": "npm run wdio:build && cd test/webdriverio/test && npx mocha --timeout 30000 dist"
2828
},
2929
"main": "./dist/index.js",

test/webdriverio/test/actions_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
sendKeyAndWait,
2121
keyRight,
2222
contextMenuItems,
23+
checkForFailures,
2324
} from './test_setup.js';
2425

2526
const isDarwin = process.platform === 'darwin';
@@ -99,6 +100,10 @@ suite('Menus test', function () {
99100
await this.browser.pause(PAUSE_TIME);
100101
});
101102

103+
teardown(async function() {
104+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
105+
});
106+
102107
test('Menu action via keyboard on block opens menu', async function () {
103108
// Navigate to draw_circle_1.
104109
await focusOnBlock(this.browser, 'draw_circle_1');

test/webdriverio/test/basic_test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
keyRight,
2323
keyUp,
2424
keyDown,
25+
checkForFailures,
2526
} from './test_setup.js';
2627
import {Key} from 'webdriverio';
2728

@@ -37,6 +38,10 @@ suite('Keyboard navigation on Blocks', function () {
3738
);
3839
});
3940

41+
teardown(async function() {
42+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
43+
});
44+
4045
test('Default workspace', async function () {
4146
const blockCount = await this.browser.execute(() => {
4247
return Blockly.getMainWorkspace().getAllBlocks(false).length;
@@ -235,6 +240,10 @@ suite('Keyboard navigation on Fields', function () {
235240
);
236241
});
237242

243+
teardown(async function() {
244+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
245+
});
246+
238247
test('Up from first field selects block', async function () {
239248
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
240249
await this.browser.pause(PAUSE_TIME);

test/webdriverio/test/block_comment_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
testFileLocations,
1515
keyRight,
1616
PAUSE_TIME,
17+
checkForFailures,
1718
} from './test_setup.js';
1819
import {Key} from 'webdriverio';
1920

@@ -34,6 +35,10 @@ suite('Block comment navigation', function () {
3435
});
3536
});
3637

38+
teardown(async function() {
39+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
40+
});
41+
3742
test('Activating a block comment icon focuses the comment', async function () {
3843
await focusOnBlock(this.browser, 'p5_canvas_1');
3944
await keyRight(this.browser);

test/webdriverio/test/clipboard_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
blockIsPresent,
1919
getFocusedBlockType,
2020
sendKeyAndWait,
21+
checkForFailures,
2122
} from './test_setup.js';
2223
import {Key, KeyAction, PointerAction, WheelAction} from 'webdriverio';
2324

@@ -31,6 +32,10 @@ suite('Clipboard test', function () {
3132
await this.browser.pause(PAUSE_TIME);
3233
});
3334

35+
teardown(async function() {
36+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
37+
});
38+
3439
test('Copy and paste while block selected', async function () {
3540
// Navigate to draw_circle_1.
3641
await focusOnBlock(this.browser, 'draw_circle_1');

test/webdriverio/test/delete_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
sendKeyAndWait,
1919
keyRight,
2020
focusOnBlockField,
21+
checkForFailures,
2122
} from './test_setup.js';
2223
import {Key} from 'webdriverio';
2324

@@ -34,6 +35,10 @@ suite('Deleting Blocks', function () {
3435
await this.browser.pause(PAUSE_TIME);
3536
});
3637

38+
teardown(async function() {
39+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
40+
});
41+
3742
test('Deleting block selects parent block', async function () {
3843
await focusOnBlock(this.browser, 'controls_if_2');
3944
await this.browser.pause(PAUSE_TIME);

test/webdriverio/test/duplicate_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
testFileLocations,
1616
testSetup,
1717
sendKeyAndWait,
18+
checkForFailures,
1819
} from './test_setup.js';
1920

2021
suite('Duplicate test', function () {
@@ -27,6 +28,10 @@ suite('Duplicate test', function () {
2728
await this.browser.pause(PAUSE_TIME);
2829
});
2930

31+
teardown(async function() {
32+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
33+
});
34+
3035
test('Duplicate block', async function () {
3136
// Navigate to draw_circle_1.
3237
await focusOnBlock(this.browser, 'draw_circle_1');

test/webdriverio/test/flyout_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
getCurrentFocusNodeId,
2121
getCurrentFocusedBlockId,
2222
tabNavigateToToolbox,
23+
checkForFailures,
2324
} from './test_setup.js';
2425

2526
suite('Toolbox and flyout test', function () {
@@ -32,6 +33,10 @@ suite('Toolbox and flyout test', function () {
3233
await this.browser.pause(PAUSE_TIME);
3334
});
3435

36+
teardown(async function() {
37+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
38+
});
39+
3540
test('Tab navigating to toolbox should open flyout', async function () {
3641
// Two tabs should navigate to the toolbox (initial element is skipped).
3742
await tabNavigateForward(this.browser);

test/webdriverio/test/insert_test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
blockIsPresent,
2323
keyUp,
2424
tabNavigateToToolbox,
25+
checkForFailures,
2526
} from './test_setup.js';
2627

2728
suite('Insert test', function () {
@@ -34,6 +35,10 @@ suite('Insert test', function () {
3435
await this.browser.pause(PAUSE_TIME);
3536
});
3637

38+
teardown(async function() {
39+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
40+
});
41+
3742
test('Insert and cancel with block selection', async function () {
3843
// Navigate to draw_circle_1.
3944
await focusOnBlock(this.browser, 'draw_circle_1');
@@ -148,6 +153,10 @@ suite('Insert test with more blocks', function () {
148153
await this.browser.pause(PAUSE_TIME);
149154
});
150155

156+
teardown(async function() {
157+
await checkForFailures(this.browser, this.currentTest!.title, this.currentTest?.state);
158+
});
159+
151160
test('Does not bump immovable input blocks on insert', async function () {
152161
// Focus the print block with a connected input block. Ordinarily, inserting
153162
// an input block would connect it to this block and bump its child, but

0 commit comments

Comments
 (0)