refactor(breadcrumbs): convert to TypeScript and RTL tests#3948
refactor(breadcrumbs): convert to TypeScript and RTL tests#3948devin-ai-integration[bot] wants to merge 23 commits intomasterfrom
Conversation
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
| @@ -1,31 +1 @@ | |||
| // @ts-nocheck override setImmediate to use setTimeout | |||
| import '@testing-library/jest-dom'; | |||
There was a problem hiding this comment.
restore the change made in jest-setup.ts file
| "workerDirectory": [ | ||
| ".storybook/public" | ||
| ] | ||
| } |
| import { PointerChevronRight } from '@box/blueprint-web-assets/icons/Fill'; | ||
| import { Size3 } from '@box/blueprint-web-assets/tokens/tokens'; | ||
| import type { Delimiter } from '../../../common/types/core'; | ||
| import { DELIMITER_CARET, COLOR_999 } from '../../../constants'; |
There was a problem hiding this comment.
switch from COLOR_999 back to blueprint's token Gray50.
| delimiter === DELIMITER_CARET ? ( | ||
| <PointerChevronRight | ||
| className="be-breadcrumb-seperator" | ||
| style={{ color: COLOR_999, width: Size3, height: Size3 }} |
There was a problem hiding this comment.
blueprint's component has its own prop. switch back to following code
color={Gray50}
height={Size3}
role="presentation"
width={Size3}
| import type { Crumb } from '../../../common/types/core'; | ||
|
|
||
| export interface BreadcrumbDropdownProps { | ||
| className?: string; |
| export * from './BreadcrumbDelimiter'; | ||
| export * from './BreadcrumbDropdown'; | ||
| export { default as InlineBreadcrumbs } from './InlineBreadcrumbs'; | ||
| export * from './InlineBreadcrumbs'; |
| @@ -1,3 +0,0 @@ | |||
| // @flow | |||
| export { default as Breadcrumbs } from './Breadcrumbs'; | |||
| export { default as InlineBreadcrumbs } from './InlineBreadcrumbs'; | |||
There was a problem hiding this comment.
restore this file back
| @@ -0,0 +1,40 @@ | |||
| import * as React from 'react'; | |||
| import { render, screen } from '../../../../test-utils/testing-library'; | |||
| import '@testing-library/jest-dom'; | |||
| const renderComponent = (props = {}) => { | ||
| const defaultProps = { | ||
| crumbs: [{ id: '0', name: 'All Files' }] as Crumb[], | ||
| delimiter: 'caret' as const, |
There was a problem hiding this comment.
update above two lines to
crumbs: [{ id: '0', name: 'All Files' }],
delimiter: 'caret',
|
|
||
| test('should call onCrumbClick when clicking a breadcrumb', () => { | ||
| const onCrumbClick = jest.fn(); | ||
| const crumbs = [{ id: '0', name: 'All Files' }] as Crumb[]; |
There was a problem hiding this comment.
update to const crumbs = [{ id: '0', name: 'All Files' }];
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
package.json
Outdated
| "@types/react-measure": "^2.0.6", | ||
| "@types/react-router-dom": "^5.1.3", | ||
| "@types/sinon": "^7.5.1", | ||
| "@types/testing-library__jest-dom": "^6.0.0", |
There was a problem hiding this comment.
do not update @testing-library/jest-dom and @types/testing-library__jest-dom dependency
| @@ -1,31 +1 @@ | |||
| // @ts-nocheck override setImmediate to use setTimeout | |||
| import '@testing-library/jest-dom'; | |||
There was a problem hiding this comment.
restore the change made in jest-setup.ts file
- Restore original functions in Breadcrumbs.tsx - Remove unnecessary props from BreadcrumbDropdown - Fix TypeScript errors and improve type safety - Restore jest-setup.ts and package.json to original state Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Co-Authored-By: tjiang@box.com <tjiang@box.com>
Convert Breadcrumbs Components to TypeScript and RTL Tests
This PR converts the breadcrumbs components from JavaScript/Flow to TypeScript and updates the tests to use React Testing Library (RTL) instead of Enzyme.
Changes
Testing
Link to Devin run: https://app.devin.ai/sessions/23615ec335b54806a03da44716e44c27