Skip to content
Merged
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
6 changes: 5 additions & 1 deletion plugins/block-dynamic-connection/test/dynamic_if.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

const chai = require('chai');
const {testHelpers} = require('@blockly/dev-tools');
const Blockly = require('blockly/node');
const Blockly = require('blockly/core');
Copy link
Contributor

@maribethb maribethb Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. This should have been done in #2229 and I'm surprised that not doing so didn't fail that build. You can probably just change it to 'blockly' and not add the rest of the lines importing blocks and en separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't fail because all of the plugins were still using a version of Blockly that didn't have the exports. Christopher was just linking every plugin locally instead of testing against a beta. In the future, I don't think we should test that way. It's too error prone (e.g. this + he lost a week of work to linking incorrectly).

I'm going to continue importing each thing individually, since that's how we recommend people load the code.

require('blockly/blocks');
const En = require('blockly/msg/en');
const {overrideOldBlockDefinitions} = require('../src/index');

const assert = chai.assert;

Blockly.setLocale(En);

suite('If block', function () {
/**
* Asserts that the if block has the expected inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

const chai = require('chai');
const {testHelpers} = require('@blockly/dev-tools');
const Blockly = require('blockly/node');
const Blockly = require('blockly/core');
require('blockly/blocks');
const En = require('blockly/msg/en');
const {overrideOldBlockDefinitions} = require('../src/index');

const assert = chai.assert;

Blockly.setLocale(En);

suite('List create block', function () {
/**
* Asserts that the list create block has the expected inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

const chai = require('chai');
const {testHelpers} = require('@blockly/dev-tools');
const Blockly = require('blockly/node');
const Blockly = require('blockly/core');
require('blockly/blocks');
const En = require('blockly/msg/en');
const {overrideOldBlockDefinitions} = require('../src/index');

const assert = chai.assert;

Blockly.setLocale(En);

suite('Text join block', function () {
/**
* Asserts that the text join block has the expected inputs.
Expand Down
2 changes: 1 addition & 1 deletion plugins/block-plus-minus/test/list_create.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ suite('List create block', function () {
testCases: [
{
title: 'Trivial',
expectedCode: '{None, None, None}',
expectedCode: '{nil, nil, nil}',
createBlock: trivialCreateBlock,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

const Blockly = require('blockly/node');
const Blockly = require('blockly/core');
const chai = require('chai');
const assert = chai.assert;
const sinon = require('sinon');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const chai = require('chai');
const Blockly = require('blockly/node');
const Blockly = require('blockly/core');
const {testHelpers} = require('@blockly/dev-tools');
const {dartGenerator} = require('blockly/dart');
const {javascriptGenerator} = require('blockly/javascript');
Expand Down
73 changes: 42 additions & 31 deletions plugins/keyboard-navigation/test/navigation_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,23 @@ suite('Navigation', function () {
this.controller = new NavigationController();
this.controller.init();
this.navigation = this.controller.navigation;

this.getContextStub = sinon
.stub(window.HTMLCanvasElement.prototype, 'getContext')
.callsFake(() => {
return {
measureText: function () {
return {width: 0};
},
};
});
});

teardown(function () {
this.controller.dispose();
window.cancelAnimationFrame = undefined;
this.jsdomCleanup();
sinon.restore();
});

// Test that toolbox key handlers call through to the right functions and
Expand All @@ -50,9 +61,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
},
Expand Down Expand Up @@ -126,8 +137,8 @@ suite('Navigation', function () {
const flyoutCursor = navigation.getFlyoutCursor(this.workspace);
// See test_helper.js for hardcoded field values.
chai.assert.equal(
flyoutCursor.getCurNode().getLocation().getFieldValue('COLOURFIELD'),
'#ff0000',
flyoutCursor.getCurNode().getLocation().getFieldValue('TEXTFIELD'),
'first',
);
});

Expand Down Expand Up @@ -183,9 +194,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
},
Expand Down Expand Up @@ -225,8 +236,8 @@ suite('Navigation', function () {
.getFlyoutCursor(this.workspace)
.getCurNode()
.getLocation()
.getFieldValue('COLOURFIELD'),
'#ff0000',
.getFieldValue('TEXTFIELD'),
'first',
);
});
test('Previous', function () {
Expand All @@ -242,7 +253,7 @@ suite('Navigation', function () {
.getCurNode()
.getLocation();
// See test_helper.js for hardcoded field values.
chai.assert.equal(flyoutBlock.getFieldValue('COLOURFIELD'), '#00ff00');
chai.assert.equal(flyoutBlock.getFieldValue('TEXTFIELD'), 'second');

const mockEvent = createKeyDownEvent(
Blockly.utils.KeyCodes.W,
Expand All @@ -265,7 +276,7 @@ suite('Navigation', function () {
.getCurNode()
.getLocation();
// See test_helper.js for hardcoded field values.
chai.assert.equal(flyoutBlock.getFieldValue('COLOURFIELD'), '#ff0000');
chai.assert.equal(flyoutBlock.getFieldValue('TEXTFIELD'), 'first');
});

test('Next', function () {
Expand All @@ -290,7 +301,7 @@ suite('Navigation', function () {
.getCurNode()
.getLocation();
// See test_helper.js for hardcoded field values.
chai.assert.equal(flyoutBlock.getFieldValue('COLOURFIELD'), '#00ff00');
chai.assert.equal(flyoutBlock.getFieldValue('TEXTFIELD'), 'second');
});

test('Out', function () {
Expand Down Expand Up @@ -388,9 +399,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
previousStatement: null,
Expand Down Expand Up @@ -564,9 +575,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
},
Expand Down Expand Up @@ -684,9 +695,9 @@ suite('Navigation', function () {
message0: '%1 %2',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
{
type: 'input_value',
Expand Down Expand Up @@ -768,9 +779,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
previousStatement: null,
Expand Down Expand Up @@ -1128,9 +1139,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
previousStatement: null,
Expand Down Expand Up @@ -1251,9 +1262,9 @@ suite('Navigation', function () {
message0: '%1',
args0: [
{
type: 'field_colour',
name: 'COLOURFIELD',
colour: '#ff4040',
type: 'field_input',
name: 'TEXTFIELD',
text: 'test',
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions plugins/keyboard-navigation/test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const {Constants} = require('../src/index');
const {Navigation} = require('../src/index');
const Blockly = require('blockly/node');
const Blockly = require('blockly/core');

/**
* Creates a workspace for testing keyboard navigation.
Expand All @@ -27,15 +27,15 @@ export function createNavigationWorkspace(
id="toolbox-categories" style="display: none">
<category colour="#FFFFFF" name="First" css-container="something">
<block type="basic_block">
<field name="COLOURFIELD">#ff0000</field>
<field name="TEXTFIELD">first</field>
</block>
<block type="basic_block">
<field name="COLOURFIELD">#00ff00</field>
<field name="TEXTFIELD">second</field>
</block>
</category>
<category colour="#FFFFFF" name="Second">
<block type="basic_block">
<field name="COLOURFIELD">#0000ff</field>
<field name="TEXTFIELD">third</field>
</block>
</category>
</xml>
Expand Down
Loading