@@ -9,56 +9,25 @@ describe('Håndtering av notater', () => {
9
9
} )
10
10
11
11
it ( 'skal kunne opprette et internt notat med tittel og tekst' , ( ) => {
12
- plukkSak ( 'Søknad' )
13
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } ) . click ( )
14
- cy . findByRole ( 'radio' , { name : / i n t e r n t a r b e i d s n o t a t / i } ) . click ( { force : true } )
15
-
16
- cy . get ( 'form[name="internt-notat-form"]' ) . within ( ( ) => {
17
- cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på internt notat' )
18
- cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i det interne notatet' )
19
- } )
12
+ åpnetNotatTab ( )
13
+ lagInterntNotat ( )
20
14
21
- cy . findByRole ( 'button' , { name : / o p p r e t t i n t e r n t n o t a t / i } ) . click ( )
22
-
23
- cy . findAllByTestId ( / n o t a t - c a r d / i)
24
- . should ( 'have.length.at.least' , 2 ) // Fordi det allerede ligger et ferdig notat der i testdatane
25
- . first ( )
26
- . should ( 'contain.text' , 'Tittel på internt notat' )
27
- . and ( 'contain.text' , 'Tekst i det interne notatet' )
15
+ assertNotatInnholdEr ( 'Tittel på internt notat' , 'Tekst i det interne notatet' )
28
16
} )
29
17
30
18
it ( 'skal kunne opprette et forvaltningsnotat interne saksopplysninger med tittel og tekst' , ( ) => {
31
- plukkSak ( 'Søknad' )
32
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } ) . click ( )
33
- cy . findByRole ( 'radio' , { name : / f o r v a l t n i n g s n o t a t / i } ) . click ( { force : true } )
19
+ åpnetNotatTab ( )
20
+ lagForvaltningsNotat ( 'Interne saksopplysninger' )
34
21
35
- cy . get ( 'form[name="forvaltningsnotat-form"]' ) . within ( ( ) => {
36
- cy . findByRole ( 'radio' , { name : / I n t e r n e s a k s o p p l y s n i n g e r / i } ) . check ( )
37
- cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på forvaltningsnotat' )
38
- cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i forvaltningsnotat' )
39
- } )
40
-
41
- cy . findByRole ( 'button' , { name : / j o u r n a l f ø r n o t a t / i } ) . click ( )
42
-
43
- cy . findAllByTestId ( / n o t a t - c a r d / i)
44
- . should ( 'have.length.at.least' , 2 ) // Fordi det allerede ligger et ferdig notat der i testdatane
45
- . first ( )
46
- . should ( 'contain.text' , 'Tittel på forvaltningsnotat' )
47
- . and ( 'contain.text' , 'Tekst i forvaltningsnotat' )
22
+ assertNotatInnholdEr ( 'Tittel på forvaltningsnotat' , 'Tekst i forvaltningsnotat' )
48
23
} )
49
24
50
25
it ( 'skal kunne opprette et forvaltningsnotat eksterne saksopplysninger med tittel og tekst' , ( ) => {
51
- plukkSak ( 'Søknad' )
52
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } ) . click ( )
26
+ åpnetNotatTab ( )
53
27
cy . findByRole ( 'radio' , { name : / f o r v a l t n i n g s n o t a t / i } ) . click ( { force : true } )
54
28
55
- cy . get ( 'form[name="forvaltningsnotat-form"]' ) . within ( ( ) => {
56
- cy . findByRole ( 'radio' , { name : / E k s t e r n e s a k s o p p l y s n i n g e r / i } ) . check ( )
57
- cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på forvaltningsnotat' )
58
- cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i forvaltningsnotat' )
59
- } )
29
+ lagForvaltningsNotat ( 'Eksterne saksopplysninger' )
60
30
61
- cy . findByRole ( 'button' , { name : / j o u r n a l f ø r n o t a t / i } ) . click ( )
62
31
const bekreftModal = cy
63
32
. findByRole ( 'dialog' , {
64
33
name : / e r d u s i k k e r p å a t d u v i l j o u r n a l f ø r e n o t a t e t / i,
@@ -70,81 +39,45 @@ describe('Håndtering av notater', () => {
70
39
cy . findByRole ( 'button' , { name : / J a , j o u r n a l f ø r n o t a t e t / i } ) . click ( )
71
40
} )
72
41
73
- cy . findAllByTestId ( / n o t a t - c a r d / i)
74
- . should ( 'have.length.at.least' , 2 ) // Fordi det allerede ligger et ferdig notat der i testdatane
75
- . first ( )
76
- . should ( 'contain.text' , 'Tittel på forvaltningsnotat' )
77
- . and ( 'contain.text' , 'Synlig for bruker' )
78
- . and ( 'contain.text' , 'Tekst i forvaltningsnotat' )
42
+ assertNotatInnholdEr ( 'Tittel på forvaltningsnotat' , 'Tekst i forvaltningsnotat' )
43
+ cy . findAllByTestId ( / n o t a t - c a r d / i) . should ( 'contain.text' , 'Synlig for bruker' )
79
44
} )
80
45
81
46
it ( 'skal kunne feilregistrere notat' , ( ) => {
82
- plukkSak ( 'Søknad' )
83
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } ) . click ( )
84
-
85
- cy . findAllByTestId ( / n o t a t - c a r d / i)
86
- . first ( )
87
- . within ( ( ) => {
88
- cy . findByRole ( 'button' ) . click ( )
89
- } )
90
- cy . findByRole ( 'menuitem' , { name : / f e i l r e g i s t r e r / i } )
91
- . should ( 'be.visible' )
92
- . click ( )
47
+ åpnetNotatTab ( )
93
48
94
- cy . findByRole ( 'dialog' , {
95
- name : / E r d u s i k k e r p å a t d u v i l f e i l r e g i s t r e r e f o r v a l t n i n g s n o t a t e t / i,
96
- } )
97
- . should ( 'be.visible' )
98
- . within ( ( ) => {
99
- cy . findAllByRole ( 'radio' ) . first ( ) . check ( )
100
- cy . findByRole ( 'button' , { name : / j a , f e i l r e g i s t r e r f o r v a l t n i n g s n o t a t e t / i } ) . click ( )
101
- } )
49
+ feilregistrerNotat ( )
102
50
cy . findAllByTestId ( / n o t a t - c a r d / i) . should ( 'have.length' , 0 )
103
51
} )
104
52
105
53
it ( 'skal lagre utkast når tittel eller tekst endres' , ( ) => {
106
- plukkSak ( 'Søknad' )
107
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } )
108
- . should ( 'be.visible' )
109
- . click ( )
54
+ åpnetNotatTab ( )
110
55
cy . findByRole ( 'radio' , { name : / i n t e r n t a r b e i d s n o t a t / i } ) . click ( { force : true } )
111
56
112
- cy . findByTestId ( 'utkast-lagret' ) . should ( 'not.exist' )
113
- cy . findByTestId ( 'utkast-badge' ) . should ( 'not.exist' )
114
- cy . findByTestId ( 'notatteller' ) . should ( 'contain.text' , '1' )
57
+ assertUtkastEr ( 'ikke synlig' )
58
+ assertNotattellerEr ( '1' )
115
59
116
60
cy . get ( 'form[name="internt-notat-form"]' ) . within ( ( ) => {
117
61
cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på internt notat' )
118
62
} )
119
63
120
- cy . findByTestId ( 'utkast-lagret' ) . should ( 'be.visible' )
121
- cy . findByTestId ( 'utkast-badge' ) . should ( 'be.visible' )
122
- cy . findByTestId ( 'notatteller' ) . should ( 'contain.text' , '2' )
123
-
124
- cy . findByRole ( 'button' , { name : / s l e t t u t k a s t / i } ) . click ( )
125
- cy . findByRole ( 'button' , { name : / j a , s l e t t u t k a s t / i } )
126
- . should ( 'be.visible' )
127
- . click ( )
128
-
129
- cy . findByTestId ( 'utkast-lagret' ) . should ( 'not.exist' )
130
- cy . findByTestId ( 'utkast-badge' ) . should ( 'not.exist' )
131
- cy . findByTestId ( 'notatteller' ) . should ( 'contain.text' , '1' )
64
+ assertUtkastEr ( 'synlig' )
65
+ assertNotattellerEr ( '2' )
66
+ slettUtkast ( )
67
+ assertUtkastEr ( 'ikke synlig' )
68
+ assertNotattellerEr ( '1' )
132
69
133
70
cy . findByRole ( 'radio' , { name : / f o r v a l t n i n g s n o t a t / i } ) . click ( { force : true } )
134
71
cy . get ( 'form[name="forvaltningsnotat-form"]' ) . within ( ( ) => {
135
72
cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i forvaltningsnotatet' )
136
73
} )
137
74
138
- cy . findByTestId ( 'utkast-lagret' ) . should ( 'be.visible' )
139
- cy . findByTestId ( 'utkast-badge' ) . should ( 'be.visible' )
140
- cy . findByTestId ( 'notatteller' ) . should ( 'contain.text' , '2' )
75
+ assertUtkastEr ( 'synlig' )
76
+ assertNotattellerEr ( '2' )
141
77
} )
142
78
143
79
it ( 'innvilgelse av søknad stoppes hvis saken har aktive notatutkast' , ( ) => {
144
- plukkSak ( 'Søknad' )
145
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } )
146
- . should ( 'be.visible' )
147
- . click ( )
80
+ åpnetNotatTab ( )
148
81
cy . findByRole ( 'radio' , { name : / i n t e r n t a r b e i d s n o t a t / i } ) . click ( { force : true } )
149
82
150
83
cy . get ( 'form[name="internt-notat-form"]' ) . within ( ( ) => {
@@ -156,20 +89,17 @@ describe('Håndtering av notater', () => {
156
89
. next ( 'ul' )
157
90
. should ( 'contain.text' , 'Du har et utkast til notat som må ferdigstilles eller slettes' )
158
91
159
- cy . findByRole ( 'button' , { name : / s l e t t u t k a s t / i } ) . click ( )
160
- cy . findByRole ( 'button' , { name : / j a , s l e t t u t k a s t / i } )
92
+ slettUtkast ( )
93
+ assertUtkastEr ( 'ikke synlig' )
94
+
95
+ cy . findByRole ( 'button' , { name : / i n n v i l g s ø k n a d e n / i } )
161
96
. should ( 'be.visible' )
162
97
. click ( )
163
-
164
- cy . findByRole ( 'button' , { name : / i n n v i l g s ø k n a d e n / i } ) . click ( )
165
98
cy . findByRole ( 'dialog' , { name : / v i l d u i n n v i l g e s ø k n a d e n / i } ) . should ( 'be.visible' )
166
99
} )
167
100
168
- it . only ( 'overføring av søknad til gosys stoppes hvis saken har aktive notatutkast' , ( ) => {
169
- plukkSak ( 'Søknad' )
170
- cy . findByRole ( 'tab' , { name : / n o t a t e r / i } )
171
- . should ( 'be.visible' )
172
- . click ( )
101
+ it ( 'overføring av søknad til gosys stoppes hvis saken har aktive notatutkast' , ( ) => {
102
+ åpnetNotatTab ( )
173
103
cy . findByRole ( 'radio' , { name : / i n t e r n t a r b e i d s n o t a t / i } ) . click ( { force : true } )
174
104
175
105
cy . get ( 'form[name="internt-notat-form"]' ) . within ( ( ) => {
@@ -182,14 +112,97 @@ describe('Håndtering av notater', () => {
182
112
. should ( 'contain.text' , 'Du har et utkast til notat som må ferdigstilles eller slettes' )
183
113
cy . findByRole ( 'dialog' , { name : / v i l d u o v e r f ø r e s a k e n t i l g o s y s / i } ) . should ( 'not.exist' )
184
114
185
- cy . findByRole ( 'button' , { name : / s l e t t u t k a s t / i } ) . click ( )
186
- cy . findByRole ( 'button' , { name : / j a , s l e t t u t k a s t / i } )
187
- . should ( 'be.visible' )
188
- . click ( )
115
+ slettUtkast ( )
116
+ assertUtkastEr ( 'ikke synlig' )
189
117
190
118
cy . findByRole ( 'button' , { name : / o v e r f ø r t i l g o s y s / i } )
191
119
. should ( 'be.visible' )
192
120
. click ( )
193
121
cy . findByRole ( 'dialog' , { name : / v i l d u o v e r f ø r e s a k e n t i l g o s y s / i } ) . should ( 'be.visible' )
194
122
} )
195
123
} )
124
+
125
+ function lagInterntNotat ( ) {
126
+ cy . findByRole ( 'radio' , { name : / i n t e r n t a r b e i d s n o t a t / i } ) . click ( { force : true } )
127
+ cy . get ( 'form[name="internt-notat-form"]' ) . within ( ( ) => {
128
+ cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på internt notat' )
129
+ cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i det interne notatet' )
130
+ } )
131
+
132
+ cy . findByRole ( 'button' , { name : / o p p r e t t i n t e r n t n o t a t / i } ) . click ( )
133
+ }
134
+
135
+ function assertNotatInnholdEr ( tittel : string , tekst : string ) {
136
+ cy . findAllByTestId ( / n o t a t - c a r d / i)
137
+ . should ( 'have.length.at.least' , 2 ) // Fordi det allerede ligger et ferdig notat der i testdatane
138
+ . first ( )
139
+ . should ( 'contain.text' , tittel )
140
+ . and ( 'contain.text' , tekst )
141
+ }
142
+
143
+ function feilregistrerNotat ( ) {
144
+ cy . findAllByTestId ( / n o t a t - c a r d / i)
145
+ . first ( )
146
+ . within ( ( ) => {
147
+ cy . findByRole ( 'button' ) . click ( )
148
+ } )
149
+ cy . findByRole ( 'menuitem' , { name : / f e i l r e g i s t r e r / i } )
150
+ . should ( 'be.visible' )
151
+ . click ( )
152
+
153
+ cy . findByRole ( 'dialog' , {
154
+ name : / E r d u s i k k e r p å a t d u v i l f e i l r e g i s t r e r e f o r v a l t n i n g s n o t a t e t / i,
155
+ } )
156
+ . should ( 'be.visible' )
157
+ . within ( ( ) => {
158
+ cy . findAllByRole ( 'radio' ) . first ( ) . check ( )
159
+ cy . findByRole ( 'button' , { name : / j a , f e i l r e g i s t r e r f o r v a l t n i n g s n o t a t e t / i } ) . click ( )
160
+ } )
161
+ }
162
+
163
+ function assertUtkastEr ( synlig : 'synlig' | 'ikke synlig' ) {
164
+ if ( synlig === 'synlig' ) {
165
+ cy . findByTestId ( 'utkast-lagret' ) . should ( 'be.visible' )
166
+ cy . findByTestId ( 'utkast-badge' ) . should ( 'be.visible' )
167
+ } else {
168
+ cy . findByTestId ( 'utkast-lagret' ) . should ( 'not.exist' )
169
+ cy . findByTestId ( 'utkast-badge' ) . should ( 'not.exist' )
170
+ }
171
+ }
172
+
173
+ function assertNotattellerEr ( antall : string ) {
174
+ cy . findByTestId ( 'notatteller' ) . should ( 'contain.text' , antall )
175
+ }
176
+
177
+ function åpnetNotatTab ( ) {
178
+ plukkSak ( 'Søknad' )
179
+ cy . findByRole ( 'tab' , { name : / n o t a t e r / i } ) . click ( )
180
+ }
181
+
182
+ function lagForvaltningsNotat ( klassifisering : 'Interne saksopplysninger' | 'Eksterne saksopplysninger' ) {
183
+ cy . findByRole ( 'radio' , { name : / f o r v a l t n i n g s n o t a t / i } ) . click ( { force : true } )
184
+
185
+ cy . get ( 'form[name="forvaltningsnotat-form"]' ) . within ( ( ) => {
186
+ cy . findByRole ( 'radio' , { name : new RegExp ( klassifisering , 'i' ) } ) . check ( )
187
+ cy . findAllByRole ( 'textbox' ) . eq ( 0 ) . type ( 'Tittel på forvaltningsnotat' )
188
+ cy . findAllByRole ( 'textbox' ) . eq ( 1 ) . type ( 'Tekst i forvaltningsnotat' )
189
+
190
+ cy . findByRole ( 'button' , { name : / j o u r n a l f ø r n o t a t / i } ) . click ( )
191
+ } )
192
+ }
193
+
194
+ function slettUtkast ( ) {
195
+ cy . findByRole ( 'button' , { name : / s l e t t u t k a s t / i } ) . click ( )
196
+ cy . findByRole ( 'dialog' , {
197
+ name : / e r d u s i k k e r p å a t d u v i l s l e t t e / i,
198
+ } )
199
+ . should ( 'be.visible' )
200
+ . within ( ( ) => {
201
+ cy . findByRole ( 'button' , { name : / j a , s l e t t u t k a s t / i } )
202
+ . should ( 'be.visible' )
203
+ . click ( )
204
+ } )
205
+ cy . findByRole ( 'dialog' , {
206
+ name : / e r d u s i k k e r p å a t d u v i l s l e t t e / i,
207
+ } ) . should ( 'not.exist' )
208
+ }
0 commit comments