@@ -3,9 +3,12 @@ import PrivateNote from './PrivateNote';
33import { AppContextProvider } from '../../context/AppContext' ;
44import { createMemoryHistory } from 'history' ;
55import { Router } from 'react-router-dom' ;
6+ import { setupServer } from 'msw/node' ;
7+ import { http , HttpResponse } from 'msw' ;
68
79const mockMemberId = '912834091823' ;
810const mockCheckinId = '837465917381' ;
11+ const mockUserId = '8714123864231' ;
912
1013const history = createMemoryHistory (
1114 `/checkins/${ mockMemberId } /${ mockCheckinId } `
@@ -29,19 +32,15 @@ const checkin = {
2932
3033const initialState = {
3134 state : {
35+ csrf : 'fake-csrf' ,
3236 userProfile : {
33- name : 'holmes' ,
34- memberProfile : {
35- id : mockMemberId ,
36- pdlId : '' ,
37- title : 'Tester' ,
38- 39- } ,
40- role : [ 'MEMBER' ] ,
37+ name : 'joe pdl' ,
38+ id : mockUserId ,
39+ role : [ 'PDL' ] ,
4140 permissions : [
4241 {
4342 id : 1 ,
44- permission : 'CAN_ADMINISTER_CHECKIN_DOCUMENTS ' ,
43+ permission : 'CAN_VIEW_PRIVATE_NOTE ' ,
4544 description : ''
4645 }
4746 ] ,
@@ -52,17 +51,41 @@ const initialState = {
5251 {
5352 name : 'holmes' ,
5453 id : mockMemberId ,
55- pdlId : '' ,
54+ pdlId : mockUserId ,
5655 title : 'Tester' ,
575657+ } ,
58+ {
59+ name : 'joe pdl' ,
60+ id : mockUserId ,
61+ pdlId : '' ,
62+ title : 'Tester' ,
63+ 5864 }
5965 ] ,
6066 checkins : [ checkin ]
6167 }
6268} ;
6369
64- it ( 'renders correctly' , ( ) => {
65- snapshot (
70+ const notes = [
71+ {
72+ id : 'note-1' ,
73+ description : 'Some kind of note...'
74+ }
75+ ] ;
76+
77+ const server = setupServer (
78+ http . get ( `http://localhost:8080/services/private-notes?checkinid=${ checkin . id } ` , ( ) => {
79+ return HttpResponse . json ( notes ) ;
80+ } ) ,
81+ ) ;
82+
83+ beforeAll ( ( ) => server . listen ( { onUnhandledRequest ( request , print ) { } } ) ) ;
84+ afterEach ( ( ) => server . resetHandlers ( ) ) ;
85+ afterAll ( ( ) => server . close ( ) ) ;
86+
87+ it ( 'renders correctly' , async ( ) => {
88+ await waitForSnapshot ( 'tiny-mce-checkin-private-notes' ,
6689 < Router history = { history } >
6790 < AppContextProvider value = { initialState } >
6891 < PrivateNote
0 commit comments