Commit Graph

1831 Commits

Author SHA1 Message Date
Rachel Fenichel
5ee26c9051 feat: use block instead of block ID in getClickableBlockElement 2023-09-13 11:30:46 -07:00
Rachel Fenichel
cad3d4b10c chore(tests): format 2023-09-12 15:13:43 -07:00
Rachel Fenichel
8d6eb80290 chore(tests): use new helper function in delete tests 2023-09-12 14:50:05 -07:00
Rachel Fenichel
6a920a87cc fix(tests): use new helper function for right-clicks 2023-09-12 14:45:08 -07:00
Rachel Fenichel
1f5dc25b3c fix(tests): use new helper function for right-clicks 2023-09-12 14:43:31 -07:00
Rachel Fenichel
6d63f3cc6b feat(tests): add helper to get a clickable element on a block 2023-09-12 14:30:11 -07:00
John Nesky
1b2e91246e chore: Use JSON objects for context menu callbackFactory (#7382)
* chore: use json object for context callbackFactory

* Add test file for context menu callback function.
2023-09-08 16:16:59 -07:00
Maribeth Bottorff
68261e5dd9 feat: add getVariableName and getProcedureName to CodeGenerator (#7445)
* feat: add getVariableName and getProcedureName to CodeGenerator

* feat: make nameDB_ public

* feat: update block code generators to use new APIs

* chore: fix build

* chore: remove unused imports
2023-08-31 10:49:17 -07:00
Christopher Allen
b0a7c004a9 refactor(build): Delete Closure Library (#7415)
* fix(build): Restore erroneously-deleted filter function

  This was deleted in PR #7406 as it was mainly being used to
  filter core/ vs. test/mocha/ deps into separate deps files -
  but it turns out also to be used for filtering error
  messages too.  Oops.

* refactor(tests): Migrate advanced compilation test to ES Modules

* refactor(build): Migrate main.js to TypeScript

  This turns out to be pretty straight forward, even if it would
  cause crashing if one actually tried to import this module
  instead of just feeding it to Closure Compiler.

* chore(build): Remove goog.declareModuleId calls

  Replace goog.declareModuleId calls with a comment recording the
  former module ID for posterity (or at least until we decide
  how to reformat the renamings file.

* chore(tests): Delete closure/goog/*

  For the moment we still need something to serve as base.js for
  the benefit of closure-make-deps, so we keep a vestigial
  base.js around, containing only the @provideGoog declaration.

* refactor(build): Remove vestigial base.js

  By changing slightly the command line arguments to
  closure-make-deps and closure-calculate-chunks the need to have
  any base.js is eliminated.

* chore: Typo fix for PR #7415
2023-08-31 00:24:47 +01:00
Christopher Allen
be809d9d98 refactor(tests): Migrate generator tests to import shims; delete bootstrap.js (#7414)
* refactor(tests): Use shims instead of bootstrap to load Blockly

  - Modify tests/generators/index.html to import the test shims
    instead of using bootstrap.js to load Blockly.

  - Modify test/generators/webdriver.js to have it wait for the
    workspace to exist before calling loadSelected().  There was
    previously a race which index.html had been winning, but
    now webdriver.js is winning (and the tests failing because
    there is no workspace yet when start() is called.

* chore(tests): Delete bootstrap.js etc.

  - Delete bootstrap.js, bootstrap_helper.js, and bootstrap_done.mjs.
  - Remove remaining references to bootstrap.js

* refactor(build): Remove deps npm script

  buildDeps is now only needed by buildCompiled, not ever for
  runnning in uncompressed mode, so:

  - Remove the deps gulp task (and the deps npm script.
  - Have the minify task run buildJavaScript and buildDeps directly.

  Additionally, the buildAdvanceCompilationTest target hasn't
  needed deps.js for some time (if ever), so skip having it run
  buildDeps entirely.

* refactor(build): Repatriate DEPS_FILE to build_tasks.js

  Since this is no longer used anywhere else it doesn't need to
  live in common.js.

* fix(scripts): Remove vestigial references to deps.mocha.js

* docs(tests): Add additional explanatory note
2023-08-31 00:02:58 +01:00
Beka Westberg
8193cffe77 chore: clean up mutator tests (#7434)
* chore: work on cleaning up mutator tests

* chore: remove need for dragBlockSelector

* chore: add helpers to clean up tests

* chore: add issue link in TODO

* chore: format and add docs for new helpers

* Revert "chore: remove need for dragBlockSelector"

This reverts commit dfec88a6aa.

* chore: fixup connect helper
2023-08-28 22:01:10 +00:00
Maribeth Bottorff
b9a7a0c7ad fix: do not create extra shadow blocks when mirroring events (#7427) 2023-08-23 16:20:40 -07:00
Rachel Fenichel
a38340bfdf chore(tests): set browser pause time in one place and enable toolbox tests (#7402)
* chore(tests): add a PAUSE_TIME constant for all test pauses

* chore(tests): respond to PR feedback
2023-08-18 17:13:32 -07:00
Christopher Allen
6f20ac290d refactor(tests): Use import instead of goog.bootstrap to load Blockly in mocha tests (#7406)
* fix(build): Have buildShims clean up up after itself

  We need to create a build/package.json file to allow node.js to
  load build/src/core/blockly.js and the other chunk entry points
  as ES modules (it forcibly assumes .js means CJS even if one is
  trying to import, unless package.json says {"type": "module"}),
  but this interferes with scripts/migration/js2ts doing a
  require('build/deps.js'), which is _not_ an ES module.

  Specific error message was:

  /Users/cpcallen/src/blockly/scripts/migration/js2ts:56
  require(path.resolve(__dirname, '../../build/deps.js'));
  ^

  Error [ERR_REQUIRE_ESM]: require() of ES Module
  /Users/cpcallen/src/blockly/build/deps.js from /Users/cpcallen/src/blockly/scripts/migration/js2ts
  not supported.
  deps.js is treated as an ES module file as it is a .js file whose
  nearest parent package.json contains "type": "module" which
  declares all .js files in that package scope as ES modules.
  Instead rename deps.js to end in .cjs, change the requiring code
  to use dynamic import() which is available in all CommonJS
  modules, or change "type": "module" to "type": "commonjs" in
  /Users/cpcallen/src/blockly/build/package.json to treat all .js
  files as CommonJS (using .mjs for all ES modules instead).

      at Object.<anonymous> (/Users/cpcallen/src/blockly/scripts/migration/js2ts:56:1) {
    code: 'ERR_REQUIRE_ESM'
  }

* chore(tests): Reorder to put interesting script nearer top of file

* chore(tests): Add missing imports of closure/goog/goog.js

  These modules were depending on being loaded via the
  debug module loader, which cannot be used without first loading
  base.js as a script, and thereby defining goog.declareModuleId
  as a side effect—but if they are to be loaded via direct import
  statements then they need to actually import their own
  dependencies.

  This is a temporary measure as soon the goog.declareMouleId
  calls can themselves be deleted.

* refactor(tests): Use import instead of bootstrap to load Blockly

* chores(build): Stop generating deps.mocha.js

  This file was only needed by tests/mocha/index.html's use of
  the debug module loader (via bootstrap.js), which has now been
  removed.

* chore(tests): Remove unneeded goog.declareModuleId calls

  These were only needed because these modules were previously
  being loaded by goog.require and/or goog.bootstrap.

* chores(tests): Remove dead code

  We are fully committed to proper modules now.
2023-08-18 18:06:52 +01:00
Rachel Fenichel
d32a13cf3f fix(tests): wait for the workspace to render before starting test actions (#7399) 2023-08-16 14:30:05 -07:00
Christopher Allen
5b5a56586c refactor(tests): Introduce loading shims, use in playgrounds (#7380)
* refactor(build): Simplify implementation of posixPath

* fix(closure): Make safe to import in node.js

  Make the implementation declareModlueId safe to import and
  execute in node.js, which does not provide a window global.

  (N.B. because this is an ESM and therefore automatically
  strict, using window?.goog?.declareModuleId doesn't work
  because window being undefined is an early error.)

* feat(tests): Introduce chunk loading shims

  - Add a buildShims task to build_tasks.js that, for each chunk,
    creates a correspondingly-named build/<chunk>.mjs that will
    either (in uncompressed mode) import and reexport that chunk's
    entry point module (e.g. core/blockly.js) or (in compressed
    mode) load dist/<chunk>_compressed.js using a <script> tag
    and then export the corresponding properties on the chunk's
    exports object.

  - Provide helper methods used by these shims in
    tests/scripts/loading.mjs, including code to detect whether
    to load in compressed or uncompressed mode.

  - Add a quote() function to scripts/helpers.js, used by
    buildShims.  This is copied from tests/bootstrap_helper.js,
    which will be removed in a later commit.

* refactor(tests): Update playground.html to use new loading shims

* refactor(tests): Update advanced_playground.html to use new loading shims

* refactor(tests): Update multi_playground.html to use new loading shims

* chore(tests): Delete playgrounds/shared_procedures.html

  Shared procedure support was moved to a plugin and this should
  have been removed from core along with it.

* docs(tests): Typo corrections.

* chore(tests): Add ".loader" infix to shim filenames.

  Per suggestion on PR #7380, have buildShims name the shims
  ${chunk.name}.loader.mjs instead of just `${chunk.name}.mjs`.
2023-08-14 22:47:19 +01:00
John Nesky
f246adbd26 feat: Parse newlines in JSON message as row separators. (#6944)
* feat: Parse message newlines as endOfRow dummies.

* Fix the multilineinput field test.

* Addressing PR feedback.

* Addressing PR feedback.

* Newline parsing now uses a new custom input.

* npm run format

* Added input_end_row to block factory.

* Addres feedback, fix endrow after external value.
2023-08-11 12:41:49 -07:00
Beka Westberg
1a41891bbe feat: merge copy paste work into develop
Merge pull request #7379 from google/operation-copy-that
2023-08-11 11:47:15 -07:00
Beka Westberg
e30c4acd92 chore: upgrade keyboard shortcuts and context menus to use non-deprecated APIs (#7352)
* chore: remove references to clipboard.copy in shortcuts

* chore: remove references to clipboard.copy in context menus

* chore: fix tests

* chore: format

* fix: PR comments
2023-08-11 09:38:50 -07:00
Maribeth Bottorff
8b6c780c3e fix: remove specific warning text (#7376)
* fix: remove specific warning text

* chore: teardown rendered workspace after test

* chore: reformat new tests
2023-08-11 00:01:12 +00:00
Beka Westberg
a901c62d0c fix: bumping copied objects (#7349)
* fix: add logic for bumping pasted blocks

* chore: add tests for bumping pasted blocks to the correct location

* fix: add logic for bumping pasted comments

* chore: add tests for bumping pasted comments
2023-08-09 10:31:29 -07:00
Beka Westberg
001d9ff2c9 feat: make ICopyable generic and update clipboard APIs (#7348)
* chore: rename module-local variables to not conflict

* feat: make ICopyable generic and update clipboard APIs

* chore: switch over more things to use generic ICopyables

* chore: fix shortcut items using copy paste

* chore: add test for interface between clipboard and pasters

* chore: export isCopyable

* chore: format

* chore: fixup PR comments

* chore: add deprecation tags
2023-08-03 15:33:58 -07:00
Rachel Fenichel
8241fca23f chore(tests): cleanup and toolbox drag tests (#7350)
* chore(tests): use helpers for the basic drag test in the playground

* chore(tests): miscellaneous test cleanup

* chore: format

* feat(tests): add test that drags out every block from the toolbox

* feat(tests): add RTL version of toolbox drag tests

* chore: lint

* chore(tests): respond to PR feedback
2023-08-03 00:31:51 +00:00
Maribeth Bottorff
18e0d530e2 chore(tests): fix delete tests (#7351)
* fix(tests): context menu delete test

* fix(tests): try increasing pause length after keys
2023-08-02 10:10:18 -07:00
Christopher Allen
889310726e fix(tests): Make .mocharc.js CWD-independent (#7329)
Move tests/browser/test/.mocharc.js to tests/browser and use
__dirname to make the require directive work regardless of where
mocha is invoked from.

Simplify the browser:test script accordingly, taking advantage
also of the mocha default of running all tests in the test/
subdirectory.
2023-07-31 08:54:19 +01:00
Maribeth Bottorff
1fe82b2354 chore(tests): fix disable block tests (#7330)
* chore(tests): fix disable block tests

* chore: add comment
2023-07-28 09:42:28 -07:00
Rachel Fenichel
9c24848039 chore(tests): update generator test blocks to use forBlock (#7311) 2023-07-28 09:04:07 -07:00
Maribeth Bottorff
9dc293b762 chore(tests): add basic delete tests (#7285)
* chore(tests): add basic delete tests

* chore: fixes from rebase, comments, and format
2023-07-27 17:12:13 -07:00
ericblackmonGoogle
5151889f13 chore: create test for mutator (#7278)
* chore: create mutator test

* chore: create test for undo block movements and editing a field

* chore: create test for mutator

* chore: creating test for mutator

* chore: create test for undo block movements and editing a field

* chore: create mutator test

* chore: create mutator test

* chore: create mutator test

* chore: create mutator test

* chore: create mutator test
2023-07-27 11:34:42 -04:00
Maribeth Bottorff
734b687f40 chore(tests): Update RTL tests and misc improvements to helpers (#7293)
* chore(tests): make switch to rtl wait before continuing

* chore: use browser.pause

* chore: fix documentation

* chore: format

* fix: missing await
2023-07-27 01:03:42 +00:00
Beka Westberg
435e854b8e fix: make deserialization use the new render management system (#7306)
* fix: make JSON use render queue

* fix: updating disabled for JSON system

* fix: make XML use render queue

* chore: make flyout use render queue explicitly
2023-07-26 14:01:19 -07:00
Rachel Fenichel
b5911c25de chore(tests): use a shared chrome instance for all browser tests (#7328)
* chore(tests): use a shared chrome instance for all browser tests

* chore: format

* chore: lint
2023-07-25 16:41:05 +00:00
dependabot[bot]
2546b01d70 chore(deps): Bump prettier from 2.8.8 to 3.0.0 (#7322)
* chore(deps): Bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Reformat using Prettier v3.0 defaults

The main change is to add trailing commas to the last line of
block-formatted function calls.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Christopher Allen <cpcallen+git@google.com>
2023-07-25 14:56:10 +00:00
Rachel Fenichel
c61da55566 fix(tests): fix broken browser tests (#7324)
* fix(tests):broken browser tests

* chore: format

* chore(tests): flip assertion order
2023-07-24 22:10:00 +00:00
Beka Westberg
36ba408b79 fix: have icons use the new render management system (#7296)
* feat: add method for triggering renders

* chore: switch icon methods to use queue
2023-07-24 14:43:14 -07:00
Neil Fraser
06ba992206 feat: Allow dragging from simple toolbox (#7301)
fix: Add delay after block connection.  Otherwise it can randomly and silently fail.
2023-07-18 19:36:20 +02:00
Beka Westberg
abb82a2f91 chore: add tests for disabling blocks (#7279)
* chore: add tests for disabling blocks

* chore: update asserts to be one line

* fix: test setup
2023-07-17 13:28:03 -07:00
Christopher Allen
82a775a982 test: Basic Blocks: verify drag blocks works properly (#7291)
* refactor(tests): Have testSetup accept a URL

  Have testSetup accept a URL.  Make testFileLocations a dictionary
  whose values are URLs, and change the spellings of the keys to
  be CONSTANT_CASE.

  This allows tests to specify their own URL, or to add a query or
  fragment.

* feat(tests): Add getAllBlocks helper

* test: Verify drag blocks works properly

* chore(tests): Reformat comments

  Manually reformat comments to comply with styleguide.
2023-07-14 15:51:38 +01:00
Rachel Fenichel
741e8dbebb chore(tests): Add tests for adding and removing comments (#7284)
* chore(tests): Add tests for adding and removing comments

* chore(tests): respond to PR feedback
2023-07-13 13:57:38 -07:00
ericblackmonGoogle
a940dc5671 chore: Added test for loading json and interblock deletion (#7282)
* chore: Added test for loading json and interblock deletion

* chore: Added test for loading json and interblock deletion

* chore: Added test for loading json and interblock deletion

* chore: Added test for loading json and interblock deletion

* chore: Added test for loading json and interblock deletion
2023-07-12 11:22:59 -04:00
Rachel Fenichel
6b3803e68f chore(tests): Add documentation to browser test helper functions (#7280)
* chore(test): release strictness of jsdoc parsing in browser tests

* chore(tests): add jsdoc to browser test helper functions

* Update tests/browser/test/test_setup.js

Co-authored-by: Beka Westberg <bwestberg@google.com>

---------

Co-authored-by: Beka Westberg <bwestberg@google.com>
2023-07-11 21:43:53 +00:00
ericblackmonGoogle
cae721e968 chore: create test for undo block movements and editing a field (#7272)
* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field

* chore: create test for undo block movements and editing a field
2023-07-11 12:51:04 -04:00
Beka Westberg
b1045a27b0 chore: remove extra waits and shorten necessary ones (#7259) 2023-07-11 09:24:01 -07:00
Rachel Fenichel
c7d0610ed0 feat(tests): add right click tests and helpers (#7262)
* feat(tests): add test for collapsing block

* chore: format

* chore: format

* feat(tests): add right-click tests and helpers

* chore(tests): respond to review feedback
2023-07-10 14:24:30 -07:00
John Nesky
75ea8d9941 fix: disposing workspace comments. (#7264)
* fix: disposing workspace comments.

* whitespace formatting
2023-07-10 09:18:42 -07:00
Christopher Allen
aefb97d780 fix(tests): Make test imports correct and more consistent (#7260)
* fix(tests): Fix invalid import paths in mocha tests

  This resolves the warnings generated during buildDeps by
  closure-make-deps.

  This commit does not attempt to address #7224 or otherwise
  rationalise the imports and usage thereof.

* fix(tests): Fix failing context menu item test

  Test appears to have been wrong: Block.prototype.getIcon is typed
  as

      getIcon<T extends IIcon>(/* ... */): T | undefined

  and documented as "@returns The icon with the given type if it
  exists on the block, undefined otherwise."

* refactor(tests): Clean up inconsistent usage of CommentIcon

  Tweak the test files touched by PR #7200 to be consistent with
  existing usage of Blockly.icons.CommentIcon instead of importing
  this separately.
2023-07-07 17:15:03 +01:00
Beka Westberg
07ba841850 chore: add test helpers for connecting blocks (#7258)
* chore: get procedure test passing on linux

* chore: cleanup

* chore: format
2023-07-06 15:35:58 -07:00
Beka Westberg
eb4025bb61 chore: fix problems from rebase (#7257) 2023-07-06 13:13:58 -07:00
Beka Westberg
956b72ad5c chore: add test helpers for getting blocks from the toolbox (#7255)
* chore: add test helpers for getting blocks from the toolbox

* chore: format

* chore: switch to use getBlockType

* chore: format

* chore: restore teardown
2023-07-06 18:08:29 +00:00
Rachel Fenichel
f1e0e11312 feat(test): add helper functions for getting selected block and block… (#7254)
* feat(test): add helper functions for getting selected block and block by ID

* chore: format test files

* chore: fix lint
2023-07-06 17:30:53 +00:00