-
Notifications
You must be signed in to change notification settings - Fork 169
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
#3221 - add shortcut shift+tab for switching selection mode #3287
Merged
Nitvex
merged 12 commits into
master
from
3221-add-shortcut-shift+tab-for-switching-selection-mode
Sep 19, 2023
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
831309f
#3221 Add shortcut [Shift+Tab] for switching selection mode
StarlaStarla 5f3f076
#3221 change the shortcut for chlorine from "Shift+C" to just "l"
StarlaStarla 2c4c70a
Merge branch 'master' of https://github.com/epam/ketcher into 3221-ad…
StarlaStarla 603415d
Merge branch 'master' of github.com:epam/ketcher into 3221-add-shortc…
StarlaStarla 374cd3a
#3221 fix autotests
StarlaStarla 2d492b0
Merge branch 'master' of https://github.com/epam/ketcher into 3221-ad…
StarlaStarla d20c334
#3221 enhancement
StarlaStarla a26a44e
#3221 fix autotest
StarlaStarla 1d33985
#3221 remove duplicate page.goto('')
StarlaStarla 188035c
#3221 enhancement
StarlaStarla cddbf70
#3221 add await to expect toBeVisible
StarlaStarla 29afa81
Merge branch 'master' of github.com:epam/ketcher into 3221-add-shortc…
StarlaStarla 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
37 changes: 37 additions & 0 deletions
37
ketcher-autotests/tests/User-Interface/Hot-Keys/hotkeys.spec.ts
This file contains 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,37 @@ | ||
/* eslint-disable no-magic-numbers */ | ||
import { expect, test } from '@playwright/test'; | ||
import { | ||
waitForIndigoToLoad, | ||
selectNestedTool, | ||
SelectTool, | ||
selectTool, | ||
LeftPanelButton, | ||
clickInTheMiddleOfTheScreen, | ||
} from '@utils'; | ||
|
||
test.describe('Hot keys', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you, please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you use |
||
await waitForIndigoToLoad(page); | ||
}); | ||
|
||
test.afterEach(async ({ page }) => { | ||
await expect(page).toHaveScreenshot(); | ||
}); | ||
|
||
test('select last chosen selected tool when user press ESC', async ({ | ||
page, | ||
}) => { | ||
await selectNestedTool(page, SelectTool.FRAGMENT_SELECTION); | ||
await selectTool(LeftPanelButton.AddText, page); | ||
await page.keyboard.press('Escape'); | ||
expect(page.getByTestId('select-fragment')).toBeTruthy(); | ||
StarlaStarla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('Shift+Tab to switch selection tool', async ({ page }) => { | ||
await clickInTheMiddleOfTheScreen(page); | ||
await page.keyboard.press('Shift+Tab'); | ||
await page.keyboard.press('Shift+Tab'); | ||
expect(page.getByTestId('select-fragment')).toBeTruthy(); | ||
}); | ||
}); |
Binary file added
BIN
+34.1 KB
...c.ts-snapshots/Hot-keys-Shift-Tab-to-switch-selection-tool-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.1 KB
...-keys-select-last-chosen-selected-tool-when-user-press-ESC-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 |
---|---|---|
|
@@ -24,7 +24,7 @@ export const atomCuts = { | |
S: 's', | ||
P: 'p', | ||
F: 'f', | ||
Cl: 'Shift+c', | ||
Cl: 'l', | ||
Br: 'b', | ||
I: 'i', | ||
A: 'a', | ||
|
This file contains 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
69 changes: 69 additions & 0 deletions
69
packages/ketcher-react/src/script/ui/state/hotkeys.test.tsx
This file contains 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,69 @@ | ||
import { screen, fireEvent, render as rtlRender } from '@testing-library/react'; | ||
import { LeftToolbarContainer } from '../views/toolbars'; | ||
import { Provider } from 'react-redux'; | ||
import createStore from '../state'; | ||
import { initKeydownListener } from './hotkeys'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
jest.mock('react-intersection-observer', () => { | ||
return { | ||
observe: jest.fn(), | ||
disconnect: jest.fn(), | ||
useInView: jest.fn().mockReturnValue([]), | ||
}; | ||
}); | ||
|
||
describe('Hot keys', () => { | ||
it('should select last chosen selected tool when user press ESC', async () => { | ||
renderWithMockStore(<LeftToolbarContainer />); | ||
const text = screen.getByTestId('text'); | ||
// eslint-disable-next-line testing-library/no-unnecessary-act | ||
act(() => { | ||
fireEvent.click(text); | ||
fireEvent.keyDown(text, { | ||
keyCode: 27, | ||
}); | ||
}); | ||
expect(screen.getByTestId('select-rectangle').className).toContain( | ||
'selected', | ||
); | ||
}); | ||
|
||
it('Shift+Tab to switch selection tool', async () => { | ||
renderWithMockStore(<LeftToolbarContainer />); | ||
// eslint-disable-next-line testing-library/no-unnecessary-act | ||
act(() => { | ||
fireEvent.keyDown(document, { | ||
keyCode: 9, | ||
shiftKey: true, | ||
}); | ||
}); | ||
expect(screen.getByTestId('select-lasso').className).toContain('selected'); | ||
}); | ||
}); | ||
|
||
function renderWithMockStore(component) { | ||
const store = createStore({}, {}, () => null); | ||
store.dispatch(initKeydownListener(document)); | ||
store.dispatch({ | ||
type: 'INIT', | ||
editor: { | ||
tool: jest.fn().mockReturnValue(true), | ||
historySize: () => { | ||
return { undo: [] }; | ||
}, | ||
selection: jest.fn(), | ||
struct: () => { | ||
return { atoms: { keys: () => new Set() } }; | ||
}, | ||
render: { ctab: {} }, | ||
zoom: jest.fn(), | ||
_tool: { mode: '' }, | ||
rotateController: { isRotating: false }, | ||
}, | ||
}); | ||
return { | ||
...rtlRender(<Provider store={store}>{component}</Provider>), | ||
store, | ||
}; | ||
} |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this line? I don't see any magic numbers here