Commit Graph

372 Commits

Author SHA1 Message Date
Beka Westberg
780b6162ce Add serialization of mutators (#5054)
* Add tests for saving extra state

* Add serializing extra state

* Fix backwards compatibility

* Switch to other function declarations

* Handle null returns from hooks

* Remove backwards compatibility

* Remove XML require, and fix type

* Fix JSDoc formatting
2021-09-20 13:08:35 -07:00
Beka Westberg
ceeda333dc Add serialization of basic block attributes to JSOs (#5053)
* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
2021-09-20 13:08:35 -07:00
Beka Westberg
2fa0e9801a Add JSO hooks for blocks and fields. (#5052)
* Add JSON serialiation hooks for fields

* Add checking for JSON hooks

* Fix other checks and move checks to function

* Remove error for both serialization hooks being defined

* Fixup comments and errors

* Add tests

* Add json hooks to block properties

* Cleanup

* Rip out fragile backwards compatibility
2021-09-20 13:08:35 -07:00
Beka Westberg
319423959b Adds a serializer test suite - project cereal (#5034)
* Setup basic architecture for tests

* Attribute tests

* Easy field tests added

* Work on tests

* Work on tests

* Work on tests

* Add mutation tests

* Fixup ID tests

* Add more mutator tests

* Fixup lint and typos

* Uncomment tests

* Use test helpers

* Small PR comments

* Use test helpers for setup and teardown

* Add TODOs and fixup types

* Fix types

* Actually fix types
2021-09-20 13:08:35 -07:00
Aaron Dodson
511ce5df2b Migrate core/blockly.js to goog.module syntax (#5494)
* Migrate core/blockly.js to ES6 const/let

* Migrate core/blockly.js to goog.module

* Migrate core/blockly.js to named requires

* clang-format core/blockly.js

* Consolidate accessors in core/blockly.js
2021-09-17 14:30:23 -07:00
Aaron Dodson
7aab18409f Migrate selected from Blockly to Blockly.common (#5489)
* Add getSelected/setSelected to core/common.js

* Migrate core to use Blockly.common.getSelected/setSelected instead of Blockly.selected

* Migrate demos to use Blockly.common.getSelected/setSelected instead of Blockly.selected

* Remove Blockly.selected

* Use variable instead of calling common.getSelected() multiple times

* Add accessor for selected on Blockly

* Add renaming record for Blockly.selected -> Blockly.common.getSelected/setSelected
2021-09-17 11:42:43 -07:00
Maribeth Bottorff
1334bd3f1b refactor: Migrate Blockly.onKeyDown out of blockly.js (#5476)
* refactor: move Blockly.onKeyDown to inject.js

* fix the tests
2021-09-16 14:48:03 -07:00
alschmiedt
5b1586ee1b test: update mocha tests to use goog_module (#5440)
* Use goog.module in mocha tests

* Fix compiler warnings

* Make test helpers a module

* Name test modules Blockly.test.*

This is to be more consistent with how non-test modules are named.

Also remove top-level goog.require of TestHelpers (now
Blockly.test.helpers) since requiring a side-effect-less module does
nothing.

* Convert block_test.js and comment_test.js to goog.module syntax

* Address PR comments

* Goog modulify tests

* Goog modulify toolbox helpers

* Fixes imports and moves common tests from workspace_test.js to a helper file.

* Update test deps after rebase

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
2021-09-16 13:00:38 -07:00
Aaron Dodson
6a4a359f7b Migrate hideChaff() from Blockly to WorkspaceSvg (#5460)
* Add hideChaff() to core/workspace_svg.js

* Mark Blockly.hideChaff as deprecated

* Update uses of Blockly.hideChaff() to WorkspaceSvg.hideChaff() in core

* Update uses of Blockly.hideChaff() to WorkspaceSvg.hideChaff() in demos

* Style and formatting fixes

* Switch from accessor to stub wrapper for Blockly.hideChaff

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2021-09-15 13:41:20 -07:00
alschmiedt
57ac0ae33b test: Changes mocha tests to use node_modules (#5467) 2021-09-15 08:23:42 -07:00
Aaron Dodson
ce8e7921a2 Move alert/confirm/prompt to a new file, dialog.js (#5457)
* Migrate prompt/alert/confirm to dedicated module

* Update core/blockly.js to pass through calls to prompt/alert/confirm to core/dialog.js

* Update calls to Blockly.prompt/alert/confirm to dialog.prompt/alert/confirm

* Fix typo and errant redeclaration of Blockly.prompt

* Clarify JSDoc on customizing Blockly.dialog.alert/confirm/prompt
2021-09-14 08:19:53 -07:00
Christopher Allen
a6471c4276 Rename Blockly.utils.IdGenerator to idGenerator and move Blockly.utils.genUid to there (#5441)
* Rename Blockly.utils.IdGenerator -> idGenerator
* Move genUid from Blockly.utils to Blockly.utils.idGenerator
2021-09-09 17:08:44 +01:00
alschmiedt
168b71e964 Updates to the new pattern for testing private 2021-08-19 17:07:05 -07:00
alschmiedt
3d75bd6493 Attempt to fix tests 2021-08-19 17:03:55 -07:00
Aaron Dodson
9046ce165b Migrate core/widgetdiv.js to goog.module syntax (#5331)
* Migrate core/widgetdiv.js to ES6 const/let

* Migrate core/widgetdiv.js to goog.module

* Migrate core/widgetdiv.js to named requires

* clang-format core/widgetdiv.js

* Mark WidgetDiv.DIV as deprecated and refactor callers to use setters/getters

* Fix deprecation date

* Refactor tests to make setDiv() in core/widgetdiv.js test-only

* Fix type annotations for WidgetDiv.DIV and move test cleanup into sharedTestTeardown
2021-08-16 10:23:50 -07:00
Aaron Dodson
c86c8f8e92 Migrate core/variables.js to goog.module syntax (#5321)
* Migrate core/variables.js to ES6 const/let

* Migrate core/variables.js to goog.module

* Migrate core/variables.js to named requires

* clang-format core/variables.js

* Add JSDoc and make testdeps function test-only

* Fix return type for getTestDeps

* Migrate to new style of exposing methods for mocking in core/variables.js
2021-08-12 09:55:38 -07:00
Aaron Dodson
a04debf275 Fix issue that prevented Mocha and generator tests from running on certain configurations (#5344)
* Fix issue that prevented Mocha and generator tests from running on certain configurations

* Link to Blockly issue re: --disable-gpu flag
2021-08-10 15:11:56 -07:00
kozbial
abbc1b3de3 Split classes from core/events/block_events.js into multiple files 2021-08-09 18:26:43 -07:00
alschmiedt
e7709cbd1f Remove extra output from generator and mocha tests (#5196)
* Remove extra output from generator tests

* Fix test

* Update loglevel for both tests
2021-08-03 13:36:50 -07:00
Rachel Fenichel
961254663d Move clipboard functions to a separate namespace 2021-07-28 11:57:24 -07:00
alschmiedt
d101e591de Removes unnecessary test 2021-07-20 13:06:39 -07:00
jschanker
de1b3214be Enforce connection preconditions for setParent (#4999)
* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per #4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).

* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Error now thrown when calling `a.setParent(null)` if a is connected to a superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per #4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).

* Fix error conditions for setParent #4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per google#4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).
* Fixed lint errors.

* Fix error conditions for setParent google#4989

* Error now thrown when calling `a.setParent(b)` on non-null b if the output/previous connection of a is not connected to an input/next connection of b without removing block from old parent's child list.
* Commented out error for when calling `a.setParent(null)` if a is connected to superior block.
* Adjusted comment to reflect that blocks were no longer being disconnected in this method.
* Also changed == to === per google#4924 (`newParent` and `this.parentBlock_` must both be instances of `Blockly.Block`).
* Fixed lint errors.
* Adjusted comment.

* Removed unnecessary set to null/added tests

* One is failing (commented out), will investigate later

* Lint fix

* Removed failing test that correctly fails

* Update comments to conform to style guide

Capitalize first letter, period at end
2021-07-13 13:56:42 -07:00
Monica Kozbial
0af6bc4b01 Remove unused parameters from test helpers (#5032) 2021-07-13 13:13:06 -07:00
Monica Kozbial
e2d0498db2 Add flag to webdriverio options (#5035)
* Add flag to webdriverio options

* update indentation of code
2021-07-13 09:31:21 -07:00
Monica Kozbial
2c83652733 Add missing whitespace to test files (#5031)
* Add missing spaces

* undo incorrect replaces in utils tests
2021-07-12 15:11:33 -07:00
Beka Westberg
13bb9f5bf6 Refactor connect logic (#4880)
* Refactor connect logic.

* Fixup from rebase

* Fix build

* PR Comments
2021-06-18 09:53:43 -07:00
Neil Fraser
c8bea1ff3a Remove return value from Field dropdownCreate_ (#4915)
These functions have side effects and set all kinds of private fields.  It is misleading for them to return the top-level element, for the caller to assign to a private field.
2021-06-18 08:22:25 -07:00
Aaron Dodson
245a44b030 Merge pull request #4920 from gonfunko/capture-warning
Use captureWarning helper from dev-tools instead of mocha/test_helpers.js implementation
2021-06-17 16:04:23 -07:00
jschanker
672574b056 Require field name to be string, test changes
* Now throws error for getField/getFieldValue/setFieldValue if provided name is not a string
* Changed error to more specific TypeError
* Type checking and error message moved up to getField
* Tests added/modified to check that non-string types for field names produce type errors
2021-06-16 10:46:05 +01:00
jschanker
f9c5260fb0 Added tests/setFieldValue error message
* Added tests for getting/setting field (values) when names are not supplied and test for getting a field value, setting it to a new value, and getting it again.
* Added more user-friendly error message for setFieldValue telling the developer that he/she is missing the name rather than Field "undefined" not found.
2021-06-16 10:46:05 +01:00
Aaron Dodson
355c54f70a Use captureWarning helper from dev-tools instead of mocha/test_helpers.js implementation. 2021-06-15 19:10:13 +00:00
Aaron Dodson
df7da795a3 Use selenium-standalone-service to automatically start and stop Selenium when running the test suite. 2021-06-14 11:52:49 -07:00
Neil Fraser
96315ad449 Fix removal of spaces near parens inside strings
Extra spaces should only be stripped from the inside of paren tokens.  Parens in strings (and other static content) should not be edited.
2021-06-09 22:16:35 -07:00
Monica Kozbial
8e7cb406f9 Handle overriding components in ComponentManager (#4856) 2021-06-08 12:28:59 -07:00
Monica Kozbial
6f7ead6e9c Fix error caused by extra teardown call (#4877) 2021-06-08 10:19:08 -07:00
Beka Westberg
ab5616cff7 Add tests for connecting blocks (#4853) 2021-06-07 08:14:13 -07:00
Neil Fraser
a385f3c2a6 Enable extraction of names from name DB.
Also gets rid of hacky name_realm contatination.
2021-05-27 21:30:26 -07:00
Beka Westberg
5ffd43824f Change lastConnectionInRow to getPlaceForOrphanedOutput - Take 2 (#4851)
* Change lastConnectionInRow to getPlaceForOrphanedOutput

* PR comments
2021-05-26 09:16:33 -07:00
Beka Westberg
9fbf06c5df PR Comments 2021-04-27 15:59:25 -07:00
Beka Westberg
43e95af14e Fix getDefinition being too restrictive 2021-04-25 14:46:51 -07:00
Monica Kozbial
5139057664 Merge consecutive viewport change events (#4792) 2021-04-23 10:56:52 -07:00
Monica Kozbial
62dc2ff6fa Include oldCoordinate and oldContents in ws comment event serialization (#4718)
* Include oldCoordinate and oldContent in ws comment event serialization
2021-03-22 08:41:31 -07:00
Monica Kozbial
7eabb8e8a3 Update inccorect jsdoc in mocha tests (#4707) 2021-03-19 16:33:41 -07:00
alschmiedt
d58c80db76 Refactor flyout and toolbox metrics (#4648) 2021-03-15 12:37:23 -07:00
alschmiedt
869e4eb366 Update flyout metrics to work with the new metrics manager (#4684) 2021-03-09 17:09:49 -08:00
Sam El-Husseini
17d2e72ab0 Fix circular dependencies in shortcut + contextmenu registries (#4681)
* Fix circular dependencies in shortcut and contextmenu registries
2021-03-08 13:35:11 -08:00
Rachel Fenichel
855185c6cf Merge pull request #4682 from rachel-fenichel/toolbox_constants
Use Blockly.utils.toolbox.Position enum everywhere
2021-03-08 10:52:58 -08:00
Monica Kozbial
f837f1e44e Add zoom support for single-direction-scroll (#4653)
* Add zoom support for single-direction scroll
2021-03-05 14:37:41 -08:00
Rachel Fenichel
f7e0d5f4ea Use existing toolbox position enum 2021-03-05 14:16:43 -08:00
Rachel Fenichel
59084a043c TOOLBOX_AT_TOP and friends -> constants.toolboxPosition.TOP, etc 2021-03-05 13:48:45 -08:00