Skip to content
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

NxDropdown Managed Key Navigation with aria-activedescendant - RSC-989 #901

Draft
wants to merge 100 commits into
base: RSC-989_add-managed-keynav-and-roles-to-nx-dropdown
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c62ced0
progress on conversion - RSC-1285
Dec 19, 2022
7bed3c3
begin test conversion for first portion of tests - RSC-1234
Dec 20, 2022
17f2d62
toggle open - RSC-1285
Dec 20, 2022
c933d2d
onToggle - RSC-1285
Dec 20, 2022
20f58db
Update lib/src/components/NxAccordion/stateful/__tests__/NxStatefulAc…
rjp99 Dec 27, 2022
173fb95
Merge branch 'main' into RSC-1285_stateful_accordion_RTL
Dec 27, 2022
c5fb4cf
added tests - RSC-1285
Dec 28, 2022
d4f6d98
conflicts - RSC-1285
Dec 28, 2022
77e519d
Merge branch 'main' into RSC-1285_stateful_accordion_RTL
Dec 28, 2022
054d1f2
continue work on conversion - RSC-1234
Dec 29, 2022
10787a8
Merge branch 'main' into RSC-1234_NxTransferListHalf_rtl_conversion
Dec 29, 2022
7ef00d1
Update lib/src/components/NxAccordion/stateful/__tests__/NxStatefulAc…
rjp99 Jan 3, 2023
2f17d25
Update lib/src/components/NxAccordion/stateful/__tests__/NxStatefulAc…
rjp99 Jan 3, 2023
8dd6141
Update lib/src/components/NxAccordion/stateful/__tests__/NxStatefulAc…
rjp99 Jan 3, 2023
9231c4d
Update lib/src/components/NxAccordion/stateful/__tests__/NxStatefulAc…
rjp99 Jan 3, 2023
4ec36d9
Merge branch 'main' into RSC-1285_stateful_accordion_RTL
Jan 3, 2023
0967312
Merge branch 'RSC-1285_stateful_accordion_RTL' of https://github.com/…
Jan 3, 2023
6078c7c
remove class - RSC-1285
Jan 3, 2023
e3278d9
continue work on conversion - RSC-1234
Jan 4, 2023
7fe3a94
change test order - RSC-1285
Jan 4, 2023
5fad745
cleanup tests- RSC-1234
Jan 5, 2023
2e2a677
fix range.getBoundingClientRect is not a function - RSC-1234
Jan 5, 2023
6d1dffc
add tooltip tests for reordering btns - RSC-1234
Jan 6, 2023
56703c6
update test name - RSC-1285
EmilyBermudez88 Jan 6, 2023
7188b0a
add assertions about open state for onClick events - RSC-1285
Jan 6, 2023
76ab1ca
add reminder to improve testing - RSC-1234
Jan 9, 2023
26ae3c2
move Range.prototype.getBoundingClientRect() into setupTests.ts - RSC…
Jan 9, 2023
f9bc1df
update test name - RSC-1234
EmilyBermudez88 Jan 9, 2023
09649e0
Merge branch 'main' into RSC-1234_NxTransferListHalf_rtl_conversion
Jan 9, 2023
bb0d6b5
Use fake timers everywhere - RSC-1336
rpokorny Jan 9, 2023
4fdd3ce
Version bump - RSC-1336
rpokorny Jan 9, 2023
98f6ab4
Fix test linting - RSC-1336
rpokorny Jan 9, 2023
dd26b0a
Remove console statement - RSC-1336
rpokorny Jan 9, 2023
cd90907
inital commit
Serhii-Bondarchuk Jan 10, 2023
141fd74
substitute querySelector for getTestByid - RSC-1285
Jan 10, 2023
cd5f60f
changed tests
Serhii-Bondarchuk Jan 11, 2023
1ef5a5b
Merge branch 'main' of https://github.com/sonatype/sonatype-react-sha…
Serhii-Bondarchuk Jan 11, 2023
e6a0386
update version
Serhii-Bondarchuk Jan 11, 2023
0bead5a
Update lib/src/components/NxLoadWrapper/__tests__/NxLoadWrapper.test.tsx
Serhii-Bondarchuk Jan 11, 2023
ed0e4ce
removed dublicated check
Serhii-Bondarchuk Jan 11, 2023
1b65245
Merge branch 'RSC-1226_Load_Wrapper-convert_tests_to_RTL' of https://…
Serhii-Bondarchuk Jan 11, 2023
378dd78
change name of the test
Serhii-Bondarchuk Jan 11, 2023
02ca8c0
remove accidental console.log - RSC-1285
Jan 11, 2023
f5b263c
Merge branch 'main' into RSC-1285_stateful_accordion_RTL
Jan 11, 2023
58d2866
added minimalProps
Serhii-Bondarchuk Jan 11, 2023
be2b247
remove console.error of unique key prop for children - RSC-1285
Jan 11, 2023
ad2a6b4
Prevent automatic scrolling on click - RSC-1342
rpokorny Jan 11, 2023
53125ed
Make example link naturally mouse-focusable for demonstration purpose…
rpokorny Jan 11, 2023
ac29087
add visual testing for move icons- RSC-1234
Jan 11, 2023
2947c54
Add functional test - RSC-1342
rpokorny Jan 11, 2023
1ea6d4f
Version bump - RSC-1342
rpokorny Jan 11, 2023
b2ed92d
Remove redundant beforeEaches - RSC-1336
rpokorny Jan 11, 2023
fc624fd
Fix existing visual/functional tests - RSC-1342
rpokorny Jan 11, 2023
f16e26b
Remove redundant parts from NxCombobox tests - RSC-1336
rpokorny Jan 11, 2023
cdd34a3
Merge branch 'main' into RSC-1336_always_fake_timers
rpokorny Jan 11, 2023
667027f
Version bump - RSC-1336
rpokorny Jan 11, 2023
94a4c8f
Fix NxLoadError tests after merge - RSC-1336
rpokorny Jan 11, 2023
78a4936
added describe blocks
Serhii-Bondarchuk Jan 12, 2023
9f117ca
Merge pull request #893 from sonatype/RSC-1336_always_fake_timers
rpokorny Jan 12, 2023
5eed414
Merge branch 'main' into RSC-1234_NxTransferListHalf_rtl_conversion
Jan 12, 2023
61e13d4
remove reduncies after merge- RSC-1234
Jan 12, 2023
e8d0404
change NxAccordion to NxStatefulAccordion- RSC-1285
Jan 12, 2023
18e6fec
remove unnecessary NxAccordion.Header tests- RSC-1285
Jan 12, 2023
b62a343
Merge branch 'main' into RSC-1285_stateful_accordion_RTL
Jan 12, 2023
9ac9267
import proper userEvent from rtlUtils - RSC-1285
Jan 12, 2023
5cced29
version bump - RSC-1285
Jan 12, 2023
ef7faff
replace waitFor with updrunTimers - RSC-1234
Jan 12, 2023
919d1a3
Prevent focus styles when active - RSC-1341
rpokorny Jan 12, 2023
909ca32
Fix primary hover color - RSC-1341
rpokorny Jan 12, 2023
93218ee
Avoid breaking global sidebar button - RSC-1341
rpokorny Jan 12, 2023
9fb1d8c
Update visual tests - RSC-1341
rpokorny Jan 12, 2023
d36a544
Version bump - RSC-1341
rpokorny Jan 12, 2023
c5c2389
updated branch
Serhii-Bondarchuk Jan 13, 2023
611ef5f
changed import for userEvent
Serhii-Bondarchuk Jan 13, 2023
8c08d91
changed from describe() to it()
Serhii-Bondarchuk Jan 13, 2023
2f1572f
changed test to check alert role
Serhii-Bondarchuk Jan 13, 2023
c89e56f
added more cases to test
Serhii-Bondarchuk Jan 13, 2023
d80043b
updated version
Serhii-Bondarchuk Jan 13, 2023
ec2260a
Stabilize visual test snapshots - RSC-1341
rpokorny Jan 13, 2023
cc1f10f
Use image from main for actually-unchanged visual test - RSC-1341
rpokorny Jan 13, 2023
50f3130
Merge pull request #879 from sonatype/RSC-1285_stateful_accordion_RTL
EmilyBermudez88 Jan 13, 2023
d730b34
Merge branch 'main' into RSC-1234_NxTransferListHalf_rtl_conversion
Jan 13, 2023
65925b1
version bump - RSC-1234
Jan 13, 2023
9a30725
Merge branch 'main' into RSC-1342_tree_scroll_on_click
rpokorny Jan 13, 2023
a1e0434
Merge branch 'main' into RSC-1341_button_focus_and_active_states
rpokorny Jan 13, 2023
d01c3df
Version bump - RSC-1341
rpokorny Jan 13, 2023
eaea770
Version bump - RSC-1342
rpokorny Jan 13, 2023
61dce5c
Merge pull request #880 from sonatype/RSC-1234_NxTransferListHalf_rtl…
EmilyBermudez88 Jan 13, 2023
0849456
Merge branch 'main' into RSC-1341_button_focus_and_active_states
rpokorny Jan 13, 2023
fc1eb92
Version bump - RSC-1341
rpokorny Jan 13, 2023
e789639
Merge branch 'main' into RSC-1342_tree_scroll_on_click
rpokorny Jan 13, 2023
9b50b24
Version bump - RSC-1342
rpokorny Jan 13, 2023
2f12ac5
Merge branches 'RSC-1341_button_focus_and_active_states' and 'RSC-134…
rpokorny Jan 13, 2023
09b03db
Merge branch 'main' into RSC-1226_Load_Wrapper-convert_tests_to_RTL
Serhii-Bondarchuk Jan 13, 2023
ccc1ccf
added more test casess
Serhii-Bondarchuk Jan 13, 2023
74856cc
update version
Serhii-Bondarchuk Jan 13, 2023
56dcc39
Merge pull request #894 from sonatype/RSC-1226_Load_Wrapper-convert_t…
Serhii-Bondarchuk Jan 13, 2023
d753e9e
Testing activedescendant. RSC-989
Jan 16, 2023
907c4c4
Updated with main. - RSC-989
Jan 17, 2023
ca8b2c2
Testing on hold. - RSC-989
Jan 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sonatype/react-shared-components-gallery",
"version": "12.10.3",
"version": "12.10.8",
"description": "Gallery application to demonstrate usage and look of Sonatype shared UI components",
"main": "src/main.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion gallery/src/components/NxTree/NxTreeCollapsibleExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function NxTreeCollapsibleExample() {
onActivate={() => document.getElementById('images-link')?.click()}>
<NxTree.ItemLabel>
<NxFontAwesomeIcon fixedWidth icon={faFolderOpen} />
<NxTextLink id="images-link" onClick={() => { alert('images'); }}>
<NxTextLink href={catImagePath} id="images-link" newTab tabIndex={-1}>
images
</NxTextLink>
</NxTree.ItemLabel>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions gallery/visualtests/nxTransferListHalf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe('NxTransferListHalf', function() {
secondItemSelector = `${itemsSelector}:nth-child(2) .nx-transfer-list__select`,
transferAllSelector = `${complexListSelector} .nx-transfer-list__move-all`,
complexFirstItemSelector = `${complexListSelector} .nx-transfer-list__item:first-child`,
complexSecondItemSelector
= `${complexListSelector} .nx-transfer-list__item:nth-child(2) .nx-transfer-list__select`,
moveUpSelector = `${complexFirstItemSelector} .nx-transfer-list__button-bar > :first-child`,
moveDownSelector = `${complexFirstItemSelector} .nx-transfer-list__button-bar > :last-child`,
filterBoxSelector = `${complexListSelector} .nx-text-input__input`,
Expand Down Expand Up @@ -133,4 +135,11 @@ describe('NxTransferListHalf', function() {
await wait(500);
await a11yTest()();
});

describe('move icons', function() {
it('renders an x icon when onItemChange is provided and isSelected is true', simpleTest(secondItemSelector));
it('renders a plus icon when onItemChange is provided but isSelected is false',
simpleTest(complexSecondItemSelector));
it('doesn\'t render a move icon when onItemChange is not provided', simpleTest(secondDisableTransferItemSelector));
});
});
26 changes: 22 additions & 4 deletions gallery/visualtests/nxTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('NxTree', function() {
waitAndGetElements,
getPage,
isFocused,
scrollPage,
a11yTest
} = setupBrowser('#/pages/Tree');

Expand Down Expand Up @@ -80,6 +81,23 @@ describe('NxTree', function() {
await simpleTest(collapsibleExampleSelector)();
});

// Check for RSC-1342
it('does not scroll when a partially out-of-view tree\'s label is clicked', async function() {
const [tree] = await waitAndGetElements(collapsibleExampleSelector),
images = await itemWithText(tree, 'images');

await scrollPage(0);

const imagesLowerBound = await images.evaluate(e => e.getBoundingClientRect().bottom),
viewportHeight = await getPage().evaluate(() => window.innerHeight),
desiredScroll = imagesLowerBound - viewportHeight - 50;

await scrollPage(desiredScroll);
await (await clickTarget(images)).click();

expect(await getPage().evaluate(() => window.scrollY)).toBe(desiredScroll);
});

describe('keyboard navigation', function() {
it('initially focuses the first item in the tree when reached via tab', async function() {
const [previousFocusableElement, tree] = await waitAndGetElements(
Expand Down Expand Up @@ -637,14 +655,14 @@ describe('NxTree', function() {
expect(await hasClass(images, 'open')).toBe(true);
await imagesClick.click();

const sawAlert = new Promise(resolve => {
page.once('dialog', dialog => {
dialog.dismiss().then(resolve);
const sawSecondPopup = new Promise(resolve => {
page.once('popup', newTab => {
newTab.close().then(resolve);
});
});

await page.keyboard.press('Enter');
await sawAlert;
await sawSecondPopup;

expect(await hasClass(images, 'open')).toBe(true);
});
Expand Down
5 changes: 5 additions & 0 deletions gallery/visualtests/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ module.exports = {
await el.evaluate(e => e.scrollIntoView({ block: 'center' }));
}

async function scrollPage(y) {
await page.evaluate((y) => window.scrollTo(0, y), y);
}

async function moveMouseAway() {
await page.mouse.move(0, 0);
}
Expand Down Expand Up @@ -260,6 +264,7 @@ module.exports = {
disableLoadingSpinnerAnimation,
setupUploadableFiles,
scrollIntoView,
scrollPage,

waitForSelectors,
getElements,
Expand Down
4 changes: 2 additions & 2 deletions lib/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"overrides": [
{
"files": ["*.tsx", "*.js", "*.ts"],
"excludedFiles": ["*.test.tsx"],
"excludedFiles": ["*.test.tsx", "src/__testutils__/*", "src/setupTests.ts"],
"extends": ["plugin:jsx-a11y/recommended"],
"plugins": ["jsx-a11y"],
"rules": {
Expand All @@ -169,7 +169,7 @@
}
},
{
"files": ["*.test.tsx", "*.test.ts"],
"files": ["*.test.tsx", "*.test.ts", "src/__testutils__/*", "src/setupTests.ts"],
"globals": {
"jest": true,
"it": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sonatype/react-shared-components",
"version": "12.10.3",
"version": "12.10.8",
"description": "Sonatype shared UI components and utilities written in React",
"main": "index.js",
"repository": {
Expand Down
19 changes: 18 additions & 1 deletion lib/src/__testutils__/rtlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/.
*/
import React, { ComponentType } from 'react';
import { render, RenderResult } from '@testing-library/react';
import { act, render, RenderResult } from '@testing-library/react';

import '@testing-library/jest-dom';
import realUserEvent from '@testing-library/user-event';
import { path, pipe } from 'ramda';
import { within } from '@testing-library/dom';
import { Options } from '@testing-library/user-event/dist/types/options';

export function rtlRender<P>(Component: ComponentType<P>, minimalProps: P) {
return function renderWrapper(additionalProps?: Partial<P>): RenderResult {
Expand All @@ -27,3 +29,18 @@ type RenderElementRetval<P> = (additionalProps?: Partial<P>) => HTMLElement | un
export function rtlRenderElement<P>(Component: ComponentType<P>, minimalProps: P): RenderElementRetval<P> {
return pipe(rtlRender(Component, minimalProps), path(['container', 'firstElementChild']));
}

export async function runTimers() {
await act(async () => { await jest.runAllTimers(); });
}

export async function advanceTimers(time: number) {
await act(async () => { await jest.advanceTimersByTime(time); });
}

export const userEvent = {
...realUserEvent,
setup(options?: Options) {
return realUserEvent.setup({ advanceTimers, ...options });
}
};
6 changes: 3 additions & 3 deletions lib/src/base-styles/_nx-btn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
background-color: var(--nx-swatch-blue-90);
}

&:focus {
border: 1px solid var(--nx-color-interactive-border-focus);
&:focus:not(:active) {
border-color: var(--nx-color-interactive-border-focus);
box-shadow: var(--nx-box-shadow-focus);
outline: 0;
}
Expand All @@ -55,7 +55,7 @@
color: var(--nx-swatch-white);

&:hover, &:focus {
background-color: var(--nx-swatch-blue-20);
background-color: var(--nx-swatch-blue-30);
}

&:active {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';

import * as enzymeUtils from '../../../__testutils__/enzymeUtils';
import 'jest-enzyme';
import AbstractNxPageHeader, { Props, HeaderLink, HeaderLinkProps } from '../AbstractNxPageHeader';

describe('AbstractNxPageHeader', function() {
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/Counter/__tests__/Counter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/.
*/
import {getShallowComponent} from '../../../__testutils__/enzymeUtils';
import 'jest-enzyme';
import Counter, {Props} from '../Counter';

describe('Counter', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';

import {getShallowComponent} from '../../../__testutils__/enzymeUtils';
import 'jest-enzyme';
import MultiSelectCounter, {Props} from '../MultiSelectCounter';
import Counter from '../Counter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/.
*/
import React from 'react';
import userEvent from '@testing-library/user-event';
import { userEvent } from '../../../__testutils__/rtlUtils';

import { rtlRender, rtlRenderElement } from '../../../__testutils__/rtlUtils';

Expand Down
Loading