Commit Graph

136 Commits

Author SHA1 Message Date
Christopher Allen
307ff71c21 refactor(build): Preparation for building TypeScript (#6205)
* chore(deps): Update closure/goog/base.js, add goog.js

  - Update base.js from the latest version (20220502.0.0).
  - Also copy over goog.js, which provides access to a suitable subset
    of goog.* via an importable module).

* chore(build): Split gulpfiles/config.js exports object

  This makes it possible for entries to depend on each other.

* chore(build): build config consistency

  - Reorder entries in gulpfiles.config.js to better match order they
    are used.
  - Have update_metadata.sh reference config.js and vice versa.

* refactor(build): Move deps.js (+ deps.mocha.js) from test/ to build/

  Once we start using tsc, deps.js will be created based on the ouptut
  of tsc rather than the raw source in core/.  Since tsc will need to
  be run before running closure-make-deps and also before trying to
  load blockly_uncompressed.js, it doesn't really make sense to check
  in deps.js; it's better to re-create as needed.

  To reduce inconvenience, a new "prepare" script is added to
  package.json which will run the buildDeps gulp target automaticaly
  when one runs npm install.

* refactor(build): Always build from TypeScript sources

  - Add buildJavaScript gulp task to use tsc to compile any .ts files
    in core/ into build/src/core/ (and also copy any .js files that
    are not yet migrated to TypeScript, which for now is all of them.
  - Remove closure/goog from explicit inputs to tsc; it will find
    the files it needs (e.g., goog.js) automatically.
  - Have buildDeps, the playground, and all the tests that run in
    uncompiled mode use build/src/core/ instead of core/ as their
    input directory.

* feat(build): Add buildJavaScriptAndDeps gulp task

  Have npm run build:deps (and npm run prepare) use a new gulp task,
  buildJavaScriptAndDeps, to run tsc followed by closure-make-deps,
  ensuring that deps.js is calculated based on the most recent code
  in core/.

* fix(build): Fix implementation of flattenCorePaths

  Even though this function is going away I want to remove it in
  a separate PR so that we can revert easily if desired.  But the
  previous checked-in code was totally wrong.  This version works.

* fix(build): Don't let checkinBuilt copy build/src/**

  Now that we are putting a lot more stuff in build/ (specifically,
  all the tsc output in build/src/), modify checkinBuilt so that it
  only copies the specific things we want to check in (for now):

  - _compressed.js build artifacts and their accompanying .js.maps
  - the generated build/msg/js/*.js language files.

  Unrelatedly, also fix safety-quoting of arguments for one execSync
  call.
2022-06-14 22:20:42 +01:00
gregdyke
0afff23d49 fix: json serialize lists_getIndex with json extraState (#6136) (#6170)
* fix: json serialize lists_getIndex with json extraState (#6136)

* address review comments

* fix: move block tests to mocha/block folder
2022-05-24 19:12:03 -07:00
YAMADA Yutaka
85ce3b82c6 fix: comments not being restored when dragging (#6011)
* fix comment deserialization

* add restore comment test

* Fix comment.

* fix: Modify test structure.
2022-03-21 07:51:51 -07:00
Maribeth Bottorff
0b2bf3ae9d feat: make mocha fail if it encounters 0 tests (#5981) 2022-03-16 17:16:06 -07:00
Beka Westberg
01d45972d4 fix: revert converting test helpers to es modules (#5982)
* Revert "fix: lint"

This reverts commit 050956d105.

* Revert "fix: run mocha as a module"

This reverts commit 4dac25ae99.

* Revert "move to modules, but break mocha"

This reverts commit 220d7bbd1d.
2022-03-09 07:38:37 -08:00
Maribeth Bottorff
7d250fa9cf feat: add mocha failure messages to console output (#5984)
* feat: add mocha failure messages to console output

* fix: line up the messages
2022-03-07 18:55:11 -08:00
Beka Westberg
2edd228117 fix: move test helpers from samples into core (#5969)
* fix: move core test helpers into new directory

* fix: add test helpers to core and convert to goog modules

* fix: change tests to use local helpers

* fix: change local tests to use chai asserts

* fix: skip field tests in serializer b/c test blocks are unavailable

* fix: rename some helper files

* fix: rename some helper modules

* fix: split block helpers into code gen and serialization

* fix: split block defs into new helper file

* fix: split warning helpers into new file

* fix: split user input helpers into new file

* fix: split event helpers into a new file

* fix: split variable helper into new file

* fix: move remaining test helpers to new setup-teardown file

* fix: rename setup and teardown module

* fix: cleanup from rebase

* fix: undo accidental rename

* fix: lint?

* fix: bad toolbox definitions namespace

* fix: fixup warning helpers

* fix: remove inclusion of dev-tools in mocha tests

* move to modules, but break mocha

* fix: run mocha as a module

* fix: lint
2022-03-04 13:10:03 -08:00
Christopher Allen
5078dcbc6d refactor(blocks)!: Rename Blockly.blocks.* modules to Blockly.libraryBlocks.* (#5953)
...and rename Blockly.blocks.all (blocks/all.js) to
Blockly.libraryBlocks (blocks/blocks.js

BREAKING CHANGE: (only) because the exports object from the
`blocks_compressed.js` chunk will be accessed as
`Blockly.libraryBlocks` instead of `Blockly.blocks.all` when the
chunk is loaded in a browser via a `<script>` tag.  There will
be no changes visible when the chunk is loaded via ES module
`import` or CJS `require`.
2022-02-23 21:25:52 +00:00
Christopher Allen
335ff199d7 refactor: Update uncompiled-mode dependency loading for playground, tests (#5715)
* chore: rename module Blockly.blocks.Lists to ....lists

All the other Blockly.blocks modules have lower-case names.  This
one being named with an upper-case initial appears to have been a
typo on my part.

This module name is not mentioned anywhere else in the source code
(though it will be soon!) so no other files need to be edited.
Further, it does not appear anywhere in the last release (which
before PR #5696) so it is not necessary to add an entry in
renamings.js for this change.

* chore(build): Rationalise deps.js, deps.mocha.js

* Include blocks/*.js (Blockly.blocks.*) in tests/deps.js, since
  these modules are used in the playground.  (They are goog.provide
  modules loaded via <script> tags, so their absence from deps.js
  does not cause errors - but it will when they are migrated to
  goog.module and must be loaded via goog.require.)

* Filter the entries in deps.mocha.js so that it includes only the
  additional mocha test modules (i.e. those not mentioned in deps.js
  already).

* refactor: Load blocks and generators using goog.require
2021-11-17 00:04:45 +00:00
Beka Westberg
410365f4a1 feat: add support for defining toolboxes using pure json (#5392)
* feat: add recycling to core

* feat: add support for json block definitions in flyout

* tests: reorganize tests

* tests: add tests for generating contents

* Fixup reycling

* tests: add tests for recycling

* fix: types

* fix: lint

* fix: PR comments

* fix: creating blocks from flyout

* test: add test block to playground

* fix: types

* feat: add support for enabled
2021-09-20 13:08:35 -07:00
Beka Westberg
4f890d73a5 fix: redo disconnect from shadow bug 2021-09-20 13:08:35 -07:00
Beka Westberg
486123e4ff fix: insertion markers and change events to work with JSO hooks (#5378)
* fix: add tests for fixing change events

* fix: change events and insertion markers

* fix: build:

* fix: remove duplicate code

* fix: requires
2021-09-20 13:08:35 -07:00
Beka Westberg
9138bca93c feat: add initialization of blocks and event firing (#5166)
* Change playground to use JSO system

* Add tests for initialization and events

* Add initialization of blocks

* PR Comments
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
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
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
alschmiedt
57ac0ae33b test: Changes mocha tests to use node_modules (#5467) 2021-09-15 08:23:42 -07:00
Beka Westberg
75f118b4f9 Refactor interpolate_ into multiple functions & remove direct new Field call (#4585)
* Refactor interpolation

* Added docs

* Add tests

* Add test for dummy input after field not prefixed with field_

* Fix typings

* Pr comments
2021-01-22 12:44:50 -08:00
alschmiedt
a3adc42e8a Remove keyboard navigation from core (#4593) 2021-01-19 11:50:51 -08:00
Monica Kozbial
dd0d5aee53 Adding procedure tests and handling procedures instantiated without name (#4428)
* Expand procedure tests and fix bug with default ids

* Add tests

* Remove xml_procedures_test.js and add non-overlapping test cases into procedures_test.js
2020-11-06 11:48:48 -08:00
alschmiedt
f1498e7f07 Keyboard shortcuts (#4421)
* Adds shortcut registry and removes action and key map (#4398)

* Adds Shortcut tests and refactored navigation tests (#4412)

* Adds shortcut items (#4408)

* Add shortcuts for navigation (#4409)

* Add final keyboard shortcut cleanup (#4413)
2020-11-02 13:30:05 -08:00
alschmiedt
7eb9c498e6 Test Blockly.onKeyDown method (#4373) 2020-10-16 11:26:32 -07:00
Monica Kozbial
6ec002e3d4 Adding tests for multiline block (#4317)
* Adding tests for multiline input
2020-09-30 15:20:35 -07:00
alschmiedt
3d698f4bcc Block factory fix (#4327) 2020-09-28 10:42:45 -07:00
Beka Westberg
47cc3b97b0 Add getTooltip (#4254)
* Add getTooltip

* Add tests

* Fix typings?

* Fix typings?

* PR Comments
2020-09-10 08:57:05 -07:00
alschmiedt
d01169fa79 Toolbox Rewrite (#4223)
Rewrite the toolbox in order to get rid of old closure code and make it easier to extend.

Co-authored-by: Maribeth Bottorff <maribethb@google.com>
2020-09-02 08:13:07 -07:00
Monica Kozbial
7dd57adf83 Give Blockly div in tests a height. (#4207) 2020-08-20 19:02:19 -07:00
Monica Kozbial
f8f98831af Add zoom controls tests. (#4159) 2020-08-12 18:39:35 -07:00
Monica Kozbial
b0b3c67b90 Support dispatching pointer events in click tests (#4154)
* Add helpers for simulating mouse click.

* Update field and workspace click tests.
2020-08-11 11:17:33 -07:00
Maribeth Bottorff
9568d3f2cc Add tests for contextmenu_items (#4118)
Add tests for context menu items
2020-08-10 11:46:10 -07:00
Rachel Fenichel
3322834a9b Add deprecation warnings and tests 2020-07-16 17:40:13 -06:00
Rachel Fenichel
bb8348befd Move to a single canConnect function, and update tests 2020-07-16 17:40:12 -06:00
Monica Kozbial
4ac4332f5e Update logic for field default values. (#3953)
* Update logic for field default values.

* Fix bugs

* Use contant for default value.

* Fix FieldColour

* Update field number tests.

* Update field angle test.

* Minor update.

* Update field checkbox test.

* Undo enabling logging

* Remove only.

* Update field colour test.

* Update invalid test cases for field colour

* Update field label tests

* Update field textinput test.

* Minor cleanup

* Make lint happy.
2020-06-12 15:18:28 -07:00
alschmiedt
61054ee55a Registry (#3914)
Create a global registry that fields, renderers and future objects can use
2020-05-26 11:21:42 -07:00
Sam El-Husseini
a5a3b045d3 Use the Blockly AST for block toString (#3895)
* Use the AST tree to populate block toString, add paranthesis around Number and Boolean connections
2020-05-14 17:06:35 -07:00
alschmiedt
d0e91a15a2 Toolbox definition (#3891)
* Add support for creating a toolbox with JSON
2020-05-13 08:16:53 -07:00
Sam El-Husseini
888e348c69 Clean out the date field (#3876) 2020-05-06 09:42:24 -07:00
Beka Westberg
65bb33635d Add ignoring insertion markers in code gen 2020-05-02 07:37:58 -07:00
Monica Kozbial
e606b872c2 Converting logic_ternary block tests to mocha (#3868)
* Convert logic_ternary block tests to mocha.
2020-04-29 11:30:23 -07:00
Monica Kozbial
e516a08430 Workspace svg tests (#3857)
* Converting workspace svg tests to mocha and calling workspace tests.

* Removing jsunit style test for workspace_svg.

* Fix eslint error.
2020-04-27 16:32:52 -07:00
Monica Kozbial
b3d4932d49 Enabling workspace comments test. (#3856) 2020-04-24 15:07:44 -07:00
Monica Kozbial
2f33a37fa4 Convert workspace comment tests to mocha. (#3850) 2020-04-22 14:49:42 -07:00
alschmiedt
10444d76ec Toolbox tests (#3846)
* Add tests for toolbox
2020-04-22 08:47:08 -07:00
Monica Kozbial
b934fdc93c Converting generator tests to mocha. (#3845) 2020-04-21 17:38:26 -07:00
Monica Kozbial
61c60019fd Converting widget div tests to mocha. (#3844) 2020-04-21 14:03:32 -07:00
Monica Kozbial
17eade1017 Partial conversion of workspace tests to mocha. (#3838) 2020-04-17 16:31:12 -07:00
Monica Kozbial
a74cd0898c Converting variable map tests to mocha. (#3827)
* Converting variable map tests to mocha.

* Removing TODO updating chai syntax.
2020-04-16 17:47:17 -07:00
Monica Kozbial
e838027629 Convert variable model tests to mocha. (#3829)
* Convert variable model tests to mocha.

* Delete old jsunit test.

* Updating to use chai syntax.
2020-04-16 17:39:38 -07:00
Monica Kozbial
9c400f2bf0 Converting variable tests to mocha. (#3828) 2020-04-16 14:18:12 -07:00
Monica Kozbial
d61f3c6f38 Converting extensions_test to mocha. (#3820)
* Converting extensions_test to mocha.

* Add spacing between test cases.

* Fix cleanup for block type.

* Add cleanup for event state.
2020-04-15 15:55:49 -07:00