-
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 branch 'main' into js-6-frontend-validations
- Loading branch information
Showing
15 changed files
with
166 additions
and
65 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
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
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
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 |
---|---|---|
|
@@ -10,21 +10,31 @@ import UserContext from '../../../UserContext'; | |
import Landing from '../index'; | ||
import activityReports from '../mocks'; | ||
|
||
const renderLanding = (user) => { | ||
render( | ||
<MemoryRouter> | ||
<UserContext.Provider value={{ user }}> | ||
<Landing authenticated /> | ||
</UserContext.Provider> | ||
</MemoryRouter>, | ||
); | ||
}; | ||
|
||
describe('Landing Page', () => { | ||
beforeEach(() => { | ||
fetchMock.get('/api/activity-reports', activityReports); | ||
fetchMock.get('/api/activity-reports/alerts', []); | ||
const user = { | ||
name: '[email protected]', | ||
permissions: [ | ||
{ | ||
scopeId: 3, | ||
regionId: 1, | ||
}, | ||
], | ||
}; | ||
|
||
render( | ||
<MemoryRouter> | ||
<UserContext.Provider value={{ user }}> | ||
<Landing authenticated /> | ||
</UserContext.Provider> | ||
</MemoryRouter>, | ||
); | ||
renderLanding(user); | ||
}); | ||
afterEach(() => fetchMock.restore()); | ||
|
||
|
@@ -156,18 +166,52 @@ describe('Landing Page error', () => { | |
|
||
it('handles errors by displaying an error message', async () => { | ||
fetchMock.get('/api/activity-reports', 500); | ||
render(<MemoryRouter><Landing authenticated /></MemoryRouter>); | ||
const user = { | ||
name: '[email protected]', | ||
permissions: [ | ||
{ | ||
scopeId: 3, | ||
regionId: 1, | ||
}, | ||
], | ||
}; | ||
renderLanding(user); | ||
const alert = await screen.findByRole('alert'); | ||
expect(alert).toBeVisible(); | ||
expect(alert).toHaveTextContent('Unable to fetch reports'); | ||
}); | ||
|
||
it('displays an empty row if there are no reports', async () => { | ||
fetchMock.get('/api/activity-reports', []); | ||
render(<MemoryRouter><Landing authenticated /></MemoryRouter>); | ||
const user = { | ||
name: '[email protected]', | ||
permissions: [ | ||
{ | ||
scopeId: 3, | ||
regionId: 1, | ||
}, | ||
], | ||
}; | ||
renderLanding(user); | ||
const rowCells = await screen.findAllByRole('cell'); | ||
expect(rowCells.length).toBe(8); | ||
const grantee = rowCells[0]; | ||
expect(grantee).toHaveTextContent(''); | ||
}); | ||
|
||
it('does not displays new activity report button without permission', async () => { | ||
fetchMock.get('/api/activity-reports', activityReports); | ||
const user = { | ||
name: '[email protected]', | ||
permissions: [ | ||
{ | ||
scopeId: 2, | ||
regionId: 1, | ||
}, | ||
], | ||
}; | ||
renderLanding(user); | ||
|
||
await expect(screen.findAllByText(/New Activity Report/)).rejects.toThrow(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"auditAdvisory","data":{"resolution":{"id":1603,"path":"react-scripts>react-dev-utils>immer","dev":false,"optional":false,"bundled":false},"advisory":{"findings":[{"version":"1.10.0","paths":["react-scripts>react-dev-utils>immer"]}],"id":1603,"created":"2021-02-19T18:18:20.058Z","updated":"2021-02-19T18:18:32.751Z","deleted":null,"title":"Prototype Pollution","found_by":{"link":"","name":"Anonymous","email":""},"reported_by":{"link":"","name":"Anonymous","email":""},"module_name":"immer","cves":["CVE-2020-28477"],"vulnerable_versions":"<8.0.1","patched_versions":">=8.0.1","overview":"## Overview\n\nAffected versions of `immer` are vulnerable to Prototype Pollution.\n\n## Proof of exploit\n\n```\nconst {applyPatches, enablePatches} = require(\"immer\");\nenablePatches();\nlet obj = {};\nconsole.log(\"Before : \" + obj.polluted);\napplyPatches({}, [ { op: 'add', path: [ \"__proto__\", \"polluted\" ], value: \"yes\" } ]);\n// applyPatches({}, [ { op: 'replace', path: [ \"__proto__\", \"polluted\" ], value: \"yes\" } ]);\nconsole.log(\"After : \" + obj.polluted);\n```\n\n## Remediation\n\nVersion 8.0.1 contains a [fix](https://github.com/immerjs/immer/commit/da2bd4fa0edc9335543089fe7d290d6a346c40c5) for this vulnerability, updating is recommended.","recommendation":"Upgrade to version 8.0.1 or later","references":"- [GitHub Advisory](https://github.com/advisories/GHSA-9qmh-276g-x5pj)\n","access":"public","severity":"high","cwe":"CWE-1321","metadata":{"module_type":"","exploitability":8,"affected_components":""},"url":"https://npmjs.com/advisories/1603"}}} |
Oops, something went wrong.