Skip to content
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

Incident Notes #5

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b4401e5
feat(lab): link visit to labs
DrewGregory Nov 6, 2020
86b1eaa
feat(incident): add ability to document notes
DrewGregory Dec 14, 2020
e214866
feat(incident):added incident note table
avigpt Dec 18, 2020
87cf4fb
started new note modal work
avigpt Dec 18, 2020
1033f16
feat(incident): note modal generalizations
DrewGregory Dec 18, 2020
296e42c
feat(incident): note modal generalizations
DrewGregory Dec 18, 2020
558f379
finish NewNoteModal refactor, begin react query for incident notes
DrewGregory Dec 21, 2020
06954fb
feat(incident): use react-query to save/view notes
DrewGregory Dec 23, 2020
71ada1a
feat(incident): add no note support
avigpt Dec 23, 2020
8b24012
merge(labrequest): fixed merge conflicts
avigpt Dec 23, 2020
287251e
Merge branch 'master' into incident-notes
avigpt Dec 23, 2020
1fb7464
feat(incident): button formatting
avigpt Dec 23, 2020
1aa28fc
feat(incident): beginnings of editing notes support
DrewGregory Jan 3, 2021
b4e2ca6
feat(incident) editing and deleting notes
avigpt Jan 4, 2021
09998a1
fixed spacing
avigpt Jan 5, 2021
86512a2
feat(incident) moved hooks to top of file
avigpt Jan 5, 2021
bf58189
wip: debug react hooks
DrewGregory Jan 6, 2021
fb875b2
test(incident): fixed view incident test
DrewGregory Jan 6, 2021
52e0f99
test(incident): fixed view incident test
DrewGregory Jan 6, 2021
73606bb
test(incident): NewNoteModal
DrewGregory Jan 7, 2021
064b772
(test) fixed merged conflicts
avigpt Jan 12, 2021
b1907fa
(test) fixed some view incident details tests
avigpt Jan 12, 2021
cda6b51
(test) fixed incident details and migrated some tests to view incident
avigpt Jan 12, 2021
bae04ca
(tests) fixed view incident tests, started fixing new note modal tests
avigpt Jan 14, 2021
3ba517d
(tests) fixed existing tests, skeleton for new ones
avigpt Jan 17, 2021
85280c9
new note modal tests
DrewGregory Jan 22, 2021
de69d9d
beginnings of tests
DrewGregory Jan 24, 2021
14b29b0
Completed NotesTable tests
jameszheng405 Feb 2, 2021
bddaeda
feat(incident): tests, almost done
avigpt Feb 6, 2021
0188b72
tests: fixed merge conflicts
avigpt Feb 6, 2021
802834d
feat(incident) tests: merge resolution
avigpt Feb 6, 2021
3aee48e
test(notes): fix last incident test
DrewGregory Feb 9, 2021
6603ed8
remove dummy validation
DrewGregory Feb 9, 2021
18e8fdf
revert package.json
DrewGregory Feb 9, 2021
25ed56f
test(incident): resolve anthony's comments on PR
avigpt Mar 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": false,
"license": "MIT",
"dependencies": {
"@hospitalrun/components": "~3.1.0",
"@hospitalrun/components": "~3.3.0",
"@reduxjs/toolkit": "~1.5.0",
"@types/escape-string-regexp": "~2.0.1",
"@types/json2csv": "~5.0.1",
Expand Down Expand Up @@ -97,7 +97,7 @@
"eslint-plugin-jest": "~24.1.0",
"eslint-plugin-jsx-a11y": "~6.4.1",
"eslint-plugin-prettier": "~3.3.0",
"eslint-plugin-react": "~7.21.0",
"eslint-plugin-react": "~7.22.0",
"eslint-plugin-react-hooks": "~4.1.0",
"history": "4.10.1",
"husky": "~4.3.0",
Expand All @@ -109,7 +109,7 @@
"redux-mock-store": "~1.5.4",
"rimraf": "~3.0.2",
"source-map-explorer": "^2.2.2",
"standard-version": "~9.0.0"
"standard-version": "~9.1.0"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
Expand Down
92 changes: 92 additions & 0 deletions src/__tests__/incidents/view/NotesTable.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Alert, Table } from '@hospitalrun/components'
import { mount, ReactWrapper } from 'enzyme'
import React from 'react'
import { act } from 'react-dom/test-utils'

import NotesTable from '../../../incidents/view/NotesTable'
import Note from '../../../shared/model/Note'

describe('Notes Table', () => {
const setup = async (notes: Note[]) => {
const onEditSpy = jest.fn()
const onDeleteSpy = jest.fn()

let wrapper: any
await act(async () => {
wrapper = await mount(
<NotesTable onEditNote={onEditSpy} onDeleteNote={onDeleteSpy} notes={notes} />,
)
})
wrapper.update()
return { wrapper: wrapper as ReactWrapper, onEditSpy, onDeleteSpy }
}

it('should render a notes table if at least note is in list.', async () => {
avigpt marked this conversation as resolved.
Show resolved Hide resolved
const { wrapper } = await setup([
{
id: '1234',
date: new Date().toISOString(),
text: 'some text',
givenBy: 'some user',
},
])
expect(wrapper.find(Table)).toHaveLength(1)
})
it('should display edit and delete buttons if notes exist', async () => {
const { wrapper } = await setup([
{
id: '1234',
date: new Date().toISOString(),
text: 'some text',
givenBy: 'some user',
},
])
const notesTable = wrapper.find(Table)
expect(notesTable.prop('actions')).toEqual([
expect.objectContaining({ label: 'actions.edit', buttonColor: 'dark' }),
expect.objectContaining({ label: 'actions.delete', buttonColor: 'danger' }),
])
})
it('should display no notes message if no notes exist', async () => {
const { wrapper } = await setup([])
const alert = wrapper.find(Alert)
expect(alert).toHaveLength(1)
expect(alert.prop('color')).toEqual('warning')
expect(alert.prop('title')).toEqual('patient.notes.warning.noNotes')
expect(wrapper.find(Table)).toHaveLength(0)
})
it('calls on edit note when edit note button clicked', async () => {
const { wrapper, onEditSpy } = await setup([
{
id: '1234',
date: new Date().toISOString(),
text: 'some text',
givenBy: 'some user',
},
])
act(() => {
const table = wrapper.find(Table) as any
const onViewClick = table.prop('actions')[0].action as any
onViewClick()
})

expect(onEditSpy).toHaveBeenCalledTimes(1)
})
it('calls on delete note when edit note button clicked', async () => {
const { wrapper, onDeleteSpy } = await setup([
{
id: '1234',
date: new Date().toISOString(),
text: 'some text',
givenBy: 'some user',
},
])
act(() => {
const table = wrapper.find(Table) as any
const onViewClick = table.prop('actions')[1].action as any
onViewClick()
})

expect(onDeleteSpy).toHaveBeenCalledTimes(1)
})
})
Loading