-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2366] Add sidebar to the production location page #900
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
Changes from all commits
03f15da
82532dd
4fba537
d1137fa
6914fda
fa67417
eb62e66
4c5ea7d
1b22ca3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import React from 'react'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { screen, fireEvent } from '@testing-library/react'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import NavBar from '../../components/ProductionLocation/Sidebar/NavBar/NavBar'; | ||
|
|
||
| const renderNavBar = () => | ||
| renderWithProviders( | ||
| <MemoryRouter> | ||
| <NavBar /> | ||
| </MemoryRouter>, | ||
| ); | ||
|
|
||
| describe('NavBar', () => { | ||
| test('renders the "Jump to" heading', () => { | ||
| renderNavBar(); | ||
|
|
||
| expect(screen.getByText('Jump to')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders all three navigation items', () => { | ||
| renderNavBar(); | ||
|
|
||
| expect(screen.getByText('Overview')).toBeInTheDocument(); | ||
| expect(screen.getByText('General Information')).toBeInTheDocument(); | ||
| expect(screen.getByText('Operational Details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('clicking a link scrolls to the matching section', () => { | ||
| renderNavBar(); | ||
|
|
||
| const scrollIntoView = jest.fn(); | ||
| const target = document.createElement('div'); | ||
| target.id = 'overview'; | ||
| target.scrollIntoView = scrollIntoView; | ||
| document.body.appendChild(target); | ||
|
|
||
| fireEvent.click(screen.getByText('Overview')); | ||
|
|
||
| expect(scrollIntoView).toHaveBeenCalledWith({ | ||
| behavior: 'smooth', | ||
| block: 'start', | ||
| }); | ||
|
|
||
| document.body.removeChild(target); | ||
|
Check warning on line 45 in src/react/src/__tests__/components/NavBar.test.js
|
||
| }); | ||
|
|
||
| test('clicking a link does nothing when the target element is missing', () => { | ||
| renderNavBar(); | ||
|
|
||
| expect(() => { | ||
| fireEvent.click(screen.getByText('General Information')); | ||
| }).not.toThrow(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import React from 'react'; | ||
| import { fireEvent } from '@testing-library/react'; | ||
| import ProductionLocationDetailsBackToSearch from '../../components/ProductionLocation/Sidebar/BackToSearch/BackToSearch'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import { setupStore } from '../../configureStore'; | ||
|
|
||
| describe('ProductionLocationDetailsBackToSearch component', () => { | ||
| const mockPush = jest.fn(); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('renders the back to search link', () => { | ||
| const { getByText } = renderWithProviders( | ||
| <ProductionLocationDetailsBackToSearch | ||
| history={{ push: mockPush }} | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText('Back to search results')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders a link pointing to the facilities route', () => { | ||
| const { container } = renderWithProviders( | ||
| <ProductionLocationDetailsBackToSearch | ||
| history={{ push: mockPush }} | ||
| />, | ||
| ); | ||
|
|
||
| const link = container.querySelector('a'); | ||
| expect(link).toHaveAttribute('href', '/facilities'); | ||
| }); | ||
|
|
||
| it('renders the back arrow icon', () => { | ||
| const { container } = renderWithProviders( | ||
| <ProductionLocationDetailsBackToSearch | ||
| history={{ push: mockPush }} | ||
| />, | ||
| ); | ||
|
|
||
| const svg = container.querySelector('svg'); | ||
| expect(svg).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('dispatches resetSingleFacility when clicked', () => { | ||
| const reduxStore = setupStore({}); | ||
| const dispatchSpy = jest.spyOn(reduxStore, 'dispatch'); | ||
|
|
||
| const { getByText } = renderWithProviders( | ||
| <ProductionLocationDetailsBackToSearch | ||
| history={{ push: mockPush }} | ||
| />, | ||
| { reduxStore }, | ||
| ); | ||
|
|
||
| fireEvent.click(getByText('Back to search results')); | ||
|
|
||
| expect(dispatchSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ type: 'RESET_SINGLE_FACILITY' }), | ||
| ); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react'; | ||
|
|
||
| export default function GeneralInformation(props) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={props.width || '24'} | ||
|
Check warning on line 7 in src/react/src/components/Icons/GeneralInformation.jsx
|
||
| height={props.height || '24'} | ||
|
Check warning on line 8 in src/react/src/components/Icons/GeneralInformation.jsx
|
||
| viewBox={props.viewBox || '0 0 24 24'} | ||
|
Check warning on line 9 in src/react/src/components/Icons/GeneralInformation.jsx
|
||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className="lucide lucide-map-pin w-4 h-4" | ||
| {...props} | ||
| > | ||
| <path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" /> | ||
| <circle cx="12" cy="10" r="3" /> | ||
| </svg> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react'; | ||
|
|
||
| export default function OperationalDetails(props) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={props.width || '24'} | ||
|
Check warning on line 7 in src/react/src/components/Icons/OperationalDetails.jsx
|
||
| height={props.height || '24'} | ||
|
Check warning on line 8 in src/react/src/components/Icons/OperationalDetails.jsx
|
||
| viewBox={props.viewBox || '0 0 24 24'} | ||
|
Check warning on line 9 in src/react/src/components/Icons/OperationalDetails.jsx
|
||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className="lucide lucide-shield-check w-5 h-5 text-verified" | ||
| {...props} | ||
| > | ||
| <path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" /> | ||
| <path d="m9 12 2 2 4-4" /> | ||
| </svg> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import React from 'react'; | ||
|
|
||
| export default function Overview(props) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={props.width || '24'} | ||
|
Check warning on line 7 in src/react/src/components/Icons/Overview.jsx
|
||
| height={props.height || '24'} | ||
|
Check warning on line 8 in src/react/src/components/Icons/Overview.jsx
|
||
| viewBox={props.viewBox || '0 0 24 24'} | ||
|
Check warning on line 9 in src/react/src/components/Icons/Overview.jsx
|
||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className="lucide lucide-building2 w-5 h-5" | ||
| {...props} | ||
| > | ||
| <path d="M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z" /> | ||
| <path d="M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" /> | ||
| <path d="M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2" /> | ||
| <path d="M10 6h4" /> | ||
| <path d="M10 10h4" /> | ||
| <path d="M10 14h4" /> | ||
| <path d="M10 18h4" /> | ||
| </svg> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,25 @@ | ||
| export default theme => ({ | ||
| buttonContainer: { | ||
| alignItems: 'center', | ||
| backgroundColor: 'white', | ||
| marginBottom: theme.spacing.unit, | ||
| marginBottom: theme.spacing.unit * 2, | ||
| }, | ||
| backButton: { | ||
| backLink: { | ||
| fontSize: `1.25rem`, | ||
| textTransform: 'none', | ||
| width: '100%', | ||
| fontWeight: 700, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| textDecoration: 'none', | ||
| }, | ||
| icon: { | ||
| transform: 'rotate(180deg)', | ||
| fontSize: `1.75rem`, | ||
| }, | ||
| text: { | ||
| fontSize: `1.25rem`, | ||
| fontWeight: 700, | ||
| display: 'inline-block', | ||
| marginBottom: theme.spacing.unit / 2, | ||
| marginLeft: theme.spacing.unit / 2, | ||
| }, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.