-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Add support for navigating in mutator workspaces. #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bdd0cdb
feat: Add support for navigating into mutators.
gonfunko 5db39d5
chore: Add tests for navigating in mutators.
gonfunko f280de1
chore: Remove unused imports.
gonfunko c2014e4
fix: Add missing return.
gonfunko f5e18d6
chore: Remove .only clause.
gonfunko 0fda717
Merge branch 'main' into mutator-nav
gonfunko 533814e
fix: Fix bad merge.
gonfunko cc5238a
chore: Add test for exiting mutator flyout.
gonfunko 0ec2ce5
chore: Add comment clarifying resolution of workspaces for checking n…
gonfunko 69192d3
chore: Add a comment explaining icon navigation.
gonfunko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import * as chai from 'chai'; | ||
| import * as Blockly from 'blockly'; | ||
| import { | ||
| focusedTreeIsMainWorkspace, | ||
| focusOnBlock, | ||
| getCurrentFocusNodeId, | ||
| getFocusedBlockType, | ||
| testSetup, | ||
| testFileLocations, | ||
| PAUSE_TIME, | ||
| tabNavigateToWorkspace, | ||
| keyRight, | ||
| keyDown, | ||
| } from './test_setup.js'; | ||
| import {Key} from 'webdriverio'; | ||
|
|
||
| suite('Mutator navigation', function () { | ||
| // Setting timeout to unlimited as these tests take a longer time to run than most mocha test | ||
| this.timeout(0); | ||
|
|
||
| // Setup Selenium for all of the tests | ||
| setup(async function () { | ||
| this.browser = await testSetup(testFileLocations.NAVIGATION_TEST_BLOCKS); | ||
| this.openMutator = async () => { | ||
| await tabNavigateToWorkspace(this.browser); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| await focusOnBlock(this.browser, 'controls_if_1'); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| // Navigate to the mutator icon | ||
| await keyRight(this.browser); | ||
| // Activate the icon | ||
| await this.browser.keys(Key.Enter); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| }; | ||
| }); | ||
|
|
||
| test('Enter opens mutator', async function () { | ||
| await this.openMutator(); | ||
|
|
||
| // Main workspace should not be focused (because mutator workspace is) | ||
| const mainWorkspaceFocused = await focusedTreeIsMainWorkspace(this.browser); | ||
| chai.assert.isFalse(mainWorkspaceFocused); | ||
|
|
||
| // The "if" placeholder block in the mutator should be focused | ||
| const focusedBlockType = await getFocusedBlockType(this.browser); | ||
| chai.assert.equal(focusedBlockType, 'controls_if_if'); | ||
| }); | ||
|
|
||
| test('Escape dismisses mutator', async function () { | ||
| await this.openMutator(); | ||
| await this.browser.keys(Key.Escape); | ||
| await this.browser.pause(PAUSE_TIME); | ||
|
|
||
| // Main workspace should be the focused tree (since mutator workspace is gone) | ||
| const mainWorkspaceFocused = await focusedTreeIsMainWorkspace(this.browser); | ||
| chai.assert.isTrue(mainWorkspaceFocused); | ||
|
|
||
| const mutatorIconId = await this.browser.execute(() => { | ||
| const block = Blockly.getMainWorkspace().getBlockById('controls_if_1'); | ||
| const icon = block?.getIcon(Blockly.icons.IconType.MUTATOR); | ||
| return icon?.getFocusableElement().id; | ||
| }); | ||
|
|
||
| // Mutator icon should now be focused | ||
| const focusedNodeId = await getCurrentFocusNodeId(this.browser); | ||
| chai.assert.equal(mutatorIconId, focusedNodeId); | ||
| }); | ||
|
|
||
| test('T focuses the mutator flyout', async function () { | ||
| await this.openMutator(); | ||
| await this.browser.keys('t'); | ||
| await this.browser.pause(PAUSE_TIME); | ||
|
|
||
| // The "else if" block in the mutator flyout should be focused | ||
| const focusedBlockType = await getFocusedBlockType(this.browser); | ||
| chai.assert.equal(focusedBlockType, 'controls_if_elseif'); | ||
| }); | ||
|
|
||
| test('Blocks can be inserted from the mutator flyout', async function () { | ||
| await this.openMutator(); | ||
| await this.browser.keys('t'); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| // Navigate down to the second block in the flyout | ||
| await keyDown(this.browser); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| // Hit enter to enter insert mode | ||
| await this.browser.keys(Key.Enter); | ||
| await this.browser.pause(PAUSE_TIME); | ||
| // Hit enter again to lock it into place on the connection | ||
| await this.browser.keys(Key.Enter); | ||
|
|
||
| const topBlocks = await this.browser.execute(() => { | ||
| const focusedTree = Blockly.getFocusManager().getFocusedTree(); | ||
| if (!(focusedTree instanceof Blockly.WorkspaceSvg)) return []; | ||
gonfunko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return focusedTree.getAllBlocks(true).map((block) => block.type); | ||
| }); | ||
|
|
||
| chai.assert.deepEqual(topBlocks, ['controls_if_if', 'controls_if_else']); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.