-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix unnecesary tab stops * Fix tabbing back to an item not focusing on the active element in some scenarios
- Loading branch information
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
Submodule web-common
updated
3 files
+2 −2 | hooks/use-focus-manager.js | |
+2 −2 | package-lock.json | |
+1 −1 | package.json |
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
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
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,58 @@ | ||
/* | ||
* @jest-environment ./test/utils/zotero-css-env.js | ||
*/ | ||
import '@testing-library/jest-dom'; | ||
import { getByRole, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event' | ||
|
||
import { renderWithProviders } from './utils/render'; | ||
import { JSONtoState } from './utils/state'; | ||
import { MainZotero } from '../src/js/component/main'; | ||
import { applyAdditionalJestTweaks, waitForPosition } from './utils/common'; | ||
import stateRaw from './fixtures/state/desktop-test-user-item-view.json'; | ||
|
||
const state = JSONtoState(stateRaw); | ||
|
||
// these tests include styles which makes them very slow | ||
applyAdditionalJestTweaks({ timeout: 240000 }); | ||
|
||
test('Tabulate back through the UI', async () => { | ||
delete window.location; | ||
window.location = new URL('http://localhost/testuser/collections/WTTJ2J56/items/VR82JUX8/item-details'); | ||
const user = userEvent.setup() | ||
renderWithProviders(<MainZotero />, { preloadedState: state, includeStyles: true }); | ||
|
||
await waitForPosition(); | ||
await user.click(screen.getByRole('textbox', { name: 'Title' })); | ||
expect(screen.getByRole('textbox', { name: 'Title' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
const inputTypeCombo = screen.getByRole('combobox', { name: 'Item Type' }); | ||
expect(getByRole(inputTypeCombo, 'textbox')).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('tab', { name: 'Info' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('row', { name: 'Effects of diet restriction on life span and age-related changes in dogs' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('button', { name: 'New Item' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('searchbox', { name: 'Filter Tags' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('button', { name: 'cute' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('button', { name: 'Collapse Tag Selector' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('treeitem', { name: 'My Library' })).toHaveFocus(); | ||
|
||
await user.keyboard('{shift>}{tab}{/shift}'); | ||
expect(screen.getByRole('searchbox', { name: 'Title, Creator, Year' })).toHaveFocus(); | ||
}); | ||
|
||
|
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