Skip to content

Commit

Permalink
feat: update dependencies and react to v18 (#1538)
Browse files Browse the repository at this point in the history
* update deps and remove test:flow_coverage

* fix jest dom import

* replace statelesscomponent

* fix useFakeTimers call

* fix compute scroll into view import

* fix id tests

* fix status

* downshift tests acts eslints

* react 18 test resetIdCounter

* downshift environment fix

* tests fixes after lint

* use es 2023 eslint

* update again and remove tl hooks

* finish coverage

* downgrate tl preact

* fix preact test

* fix cypress tests

* increase a timeout

* check environment in hooks

* update import tests

* improve environment checks

* move test cases array
  • Loading branch information
silviuaavram committed Sep 20, 2023
1 parent bc7639c commit 9828365
Show file tree
Hide file tree
Showing 56 changed files with 1,037 additions and 564 deletions.
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:6006',
video: false,
testIsolation: false,
setupNodeEvents(on) {
on(
'file:preprocessor',
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/combobox.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('combobox', () => {
.get('body')
.trigger('touchstart', bodyX, bodyY, {force: true})
.trigger('touchend', bodyX, bodyY, {force: true})
cy.findByTestId('downshift-item-0', {timeout: 10}).should('not.exist')
cy.findByTestId('downshift-item-0', {timeout: 100}).should('not.exist')
})

it('does not reset when swiping outside to scroll a touch screen', () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/useMultipleSelect.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ describe('useMultipleSelect', () => {
it('can select multiple options', () => {
cy.findByRole('combobox').click()
cy.findByRole('option', {name: 'Green'}).click()
cy.findByRole('option', {name: 'Gray'}).click()
cy.findByRole('option', {name: 'Blue'}).click()
cy.findByRole('combobox').click()
cy.findByText('Black').should('be.visible')
cy.findByText('Red').should('be.visible')
cy.findByText('Green').should('be.visible')
cy.findByText('Gray').should('be.visible')
cy.findByText('Blue').should('be.visible')
})
})
47 changes: 24 additions & 23 deletions docusaurus/pages/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,30 @@ export default function ComboBox() {
</button>
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen &&
(inputValue
? colors.filter(i =>
i.toLowerCase().includes(inputValue.toLowerCase()),
)
: colors
).map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))}
{isOpen
? (inputValue
? colors.filter(i =>
i.toLowerCase().includes(inputValue.toLowerCase()),
)
: colors
).map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))
: null}
</ul>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions docusaurus/pages/useCombobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function DropdownCombobox() {
</button>
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen &&
{isOpen ?
inputItems.map((item, index) => (
<li
style={{
Expand All @@ -76,7 +76,7 @@ export default function DropdownCombobox() {
>
{item}
</li>
))}
)) : null}
</ul>
</div>
)
Expand Down
36 changes: 19 additions & 17 deletions docusaurus/pages/useMultipleCombobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,25 @@ export default function DropdownMultipleCombobox() {
</div>
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen &&
items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor: highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))}
{isOpen
? items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))
: null}
</ul>
</div>
)
Expand Down
134 changes: 67 additions & 67 deletions docusaurus/pages/useMultipleSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,79 +67,79 @@ export default function DropdownMultipleSelect() {

return (
<div style={containerStyles}>
<div>
<label
style={{
fontWeight: 'bolder',
color: selectedItem ? selectedItem : 'black',
}}
{...getLabelProps()}
>
Choose an element:
</label>
<div style={selectedItemsContainerSyles}>
{selectedItems.map(function renderSelectedItem(
selectedItemForRender,
index,
) {
return (
<label
style={{
fontWeight: 'bolder',
color: selectedItem ? selectedItem : 'black',
}}
{...getLabelProps()}
>
Choose an element:
</label>
<div style={selectedItemsContainerSyles}>
{selectedItems.map(function renderSelectedItem(
selectedItemForRender,
index,
) {
return (
<span
style={selectedItemStyles}
key={`selected-item-${index}`}
{...getSelectedItemProps({
selectedItem: selectedItemForRender,
index,
})}
>
{selectedItemForRender}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
<span
style={selectedItemStyles}
key={`selected-item-${index}`}
{...getSelectedItemProps({
selectedItem: selectedItemForRender,
index,
})}
style={{padding: '4px', cursor: 'pointer'}}
onClick={e => {
e.stopPropagation()
removeSelectedItem(selectedItemForRender)
}}
>
{selectedItemForRender}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
<span
style={{padding: '4px', cursor: 'pointer'}}
onClick={e => {
e.stopPropagation()
removeSelectedItem(selectedItemForRender)
}}
>
&#10005;
</span>
&#10005;
</span>
)
})}
<div
style={{
padding: '4px',
textAlign: 'center',
border: '1px solid black',
backgroundColor: 'lightgray',
cursor: 'pointer',
}}
type="button"
{...getToggleButtonProps(
getDropdownProps({preventKeyAction: isOpen}),
)}
>
Pick some colors {isOpen ? <>&#8593;</> : <>&#8595;</>}
</div>
</span>
)
})}
<div
style={{
padding: '4px',
textAlign: 'center',
border: '1px solid black',
backgroundColor: 'lightgray',
cursor: 'pointer',
}}
type="button"
{...getToggleButtonProps(
getDropdownProps({preventKeyAction: isOpen}),
)}
>
Pick some colors {isOpen ? <>&#8593;</> : <>&#8595;</>}
</div>
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen &&
items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor: highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))}
{isOpen
? items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))
: null}
</ul>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions docusaurus/pages/useSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function DropdownSelect() {
{isOpen ? <>&#8593;</> : <>&#8595;</>}
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen &&
{isOpen ?
colors.map((item, index) => (
<li
style={{
Expand All @@ -55,7 +55,7 @@ export default function DropdownSelect() {
>
{item}
</li>
))}
)) : null}
</ul>
</div>
)
Expand Down

0 comments on commit 9828365

Please sign in to comment.