-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #622 from adhocteam/main
add filters and target populations table to grantee record page
- Loading branch information
Showing
67 changed files
with
2,723 additions
and
1,063 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
frontend/src/components/ActivityReportsTable/__tests__/ColumnHeader.js
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 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { | ||
render, screen, act, | ||
} from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import ColumnHeader from '../ColumnHeader'; | ||
|
||
describe('ActivityReportsTable ColumnHeader', () => { | ||
const renderColumnHeader = (onUpdateSort = jest.fn(), sortDirection = 'asc') => { | ||
const name = 'fanciest shoes'; | ||
render( | ||
<div> | ||
<table> | ||
<thead> | ||
<tr> | ||
<ColumnHeader | ||
onUpdateSort={onUpdateSort} | ||
displayName={name} | ||
name="shoes" | ||
sortBy="shoes" | ||
sortDirection={sortDirection} | ||
/> | ||
</tr> | ||
</thead> | ||
</table> | ||
</div>, | ||
); | ||
}; | ||
|
||
it('renders and calls on update sort', async () => { | ||
const onUpdateSort = jest.fn(); | ||
renderColumnHeader(onUpdateSort); | ||
|
||
const shoes = await screen.findByText('fanciest shoes'); | ||
|
||
await act(async () => userEvent.click(shoes)); | ||
expect(onUpdateSort).toHaveBeenCalledWith('shoes'); | ||
}); | ||
|
||
it('sorts on keypress', async () => { | ||
const onUpdateSort = jest.fn(); | ||
renderColumnHeader(onUpdateSort, 'desc'); | ||
|
||
const shoes = await screen.findByText('fanciest shoes'); | ||
|
||
await act(async () => userEvent.type(shoes, '{enter}')); | ||
expect(onUpdateSort).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('displays an unsortable column', async () => { | ||
const onUpdateSort = jest.fn(); | ||
renderColumnHeader(onUpdateSort, ''); | ||
|
||
const shoes = await screen.findByRole('columnheader', { name: /fanciest shoes/i }); | ||
expect(shoes).toHaveAttribute('aria-sort', 'none'); | ||
}); | ||
}); |
55 changes: 55 additions & 0 deletions
55
frontend/src/components/ActivityReportsTable/__tests__/ReportRow.js
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,55 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { | ||
render, screen, | ||
} from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Router } from 'react-router'; | ||
import { createMemoryHistory } from 'history'; | ||
import ReportRow from '../ReportRow'; | ||
import { generateXFakeReports } from '../mocks'; | ||
|
||
const history = createMemoryHistory(); | ||
|
||
const [report] = generateXFakeReports(1); | ||
|
||
describe('ReportRow', () => { | ||
const renderReportRow = () => ( | ||
render( | ||
<Router history={history}> | ||
<ReportRow | ||
report={report} | ||
openMenuUp={false} | ||
handleReportSelect={jest.fn()} | ||
isChecked={false} | ||
/> | ||
</Router>, | ||
) | ||
); | ||
|
||
beforeAll(async () => { | ||
global.navigator.clipboard = jest.fn(); | ||
global.navigator.clipboard.writeText = jest.fn(() => Promise.resolve()); | ||
}); | ||
|
||
afterAll(() => { | ||
delete global.navigator; | ||
}); | ||
|
||
it('the view link works', async () => { | ||
history.push = jest.fn(); | ||
renderReportRow(); | ||
userEvent.click(await screen.findByRole('button', { name: 'Actions for activity report R14-AR-1' })); | ||
userEvent.click(await screen.findByRole('button', { name: /view/i })); | ||
|
||
expect(history.push).toHaveBeenCalled(); | ||
}); | ||
|
||
it('you can copy', async () => { | ||
renderReportRow(); | ||
userEvent.click(await screen.findByRole('button', { name: 'Actions for activity report R14-AR-1' })); | ||
userEvent.click(await screen.findByRole('button', { name: /copy url/i })); | ||
|
||
expect(navigator.clipboard.writeText).toHaveBeenCalled(); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -64,7 +64,7 @@ describe('Table menus & selections', () => { | |
fetchMock.reset(); | ||
fetchMock.get( | ||
defaultBaseUrlWithRegionOne, | ||
{ count: 10, rows: generateXFakeReports(10) }, | ||
{ count: 10, rows: generateXFakeReports(10, ['approved']) }, | ||
); | ||
const user = { | ||
name: '[email protected]', | ||
|
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
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
Oops, something went wrong.