@@ -14,8 +14,8 @@ import { ensureAssigned, ensureOutboxIsEmpty, selectAction } from '../../utils'
1414test . describe . serial ( 'Approval of late birth registration' , ( ) => {
1515 let page : Page
1616 const childName = {
17- firstNames : faker . person . firstName ( 'male ' ) ,
18- familyName : faker . person . lastName ( 'male ' )
17+ firstNames : faker . person . firstName ( 'female ' ) ,
18+ familyName : faker . person . lastName ( 'female ' )
1919 }
2020
2121 const childNameFormatted = formatName ( childName )
@@ -41,7 +41,7 @@ test.describe.serial('Approval of late birth registration', () => {
4141 await page . locator ( '#firstname' ) . fill ( childName . firstNames )
4242 await page . locator ( '#surname' ) . fill ( childName . familyName )
4343 await page . locator ( '#child____gender' ) . click ( )
44- await page . getByText ( 'Male ' , { exact : true } ) . click ( )
44+ await page . getByText ( 'Female ' , { exact : true } ) . click ( )
4545
4646 await page . getByPlaceholder ( 'dd' ) . fill ( '12' )
4747 await page . getByPlaceholder ( 'mm' ) . fill ( '05' )
@@ -137,7 +137,6 @@ test.describe.serial('Approval of late birth registration', () => {
137137 ) . toBeVisible ( )
138138 } )
139139
140- // @TODO : This test should be added after action conditionals are implemented
141140 test . skip ( 'RA should not have the option to Approve' , async ( ) => {
142141 await page . getByRole ( 'button' , { name : 'Action' , exact : true } ) . click ( )
143142 await expect ( page . getByText ( 'Approve' , { exact : true } ) ) . not . toBeVisible ( )
@@ -151,6 +150,15 @@ test.describe.serial('Approval of late birth registration', () => {
151150 await page . getByRole ( 'button' , { name : childNameFormatted } ) . click ( )
152151 } )
153152
153+ test ( 'Unassign' , async ( ) => {
154+ await page . getByRole ( 'button' , { name : 'Action' , exact : true } ) . click ( )
155+ await page . getByText ( 'Unassign' , { exact : true } ) . click ( )
156+ await page . getByRole ( 'button' , { name : 'Unassign' , exact : true } ) . click ( )
157+ await expect (
158+ page . getByText ( 'Not assigned' , { exact : true } )
159+ ) . toBeVisible ( )
160+ } )
161+
154162 test ( 'Approve action should be disabled before assignment' , async ( ) => {
155163 await page . getByRole ( 'button' , { name : 'Action' , exact : true } ) . click ( )
156164 const approveButton = page . getByText ( 'Approve' , { exact : true } )
@@ -203,6 +211,11 @@ test.describe.serial('Approval of late birth registration', () => {
203211 ) . not . toBeVisible ( )
204212 } )
205213
214+ test ( "Validate that the 'Approve' action is no longer available" , async ( ) => {
215+ await page . getByRole ( 'button' , { name : 'Action' , exact : true } ) . click ( )
216+ await expect ( page . getByText ( 'Approve' , { exact : true } ) ) . not . toBeVisible ( )
217+ } )
218+
206219 test ( 'Validate that action and form field value appearing in audit trail' , async ( ) => {
207220 await switchEventTab ( page , 'Audit' )
208221 await page . getByRole ( 'button' , { name : 'Approved' , exact : true } ) . click ( )
@@ -212,3 +225,130 @@ test.describe.serial('Approval of late birth registration', () => {
212225 } )
213226 } )
214227} )
228+
229+ test . describe ( 'Birth with non-late registration will not have flag or Approve-action available' , ( ) => {
230+ let page : Page
231+ const childName = {
232+ firstNames : faker . person . firstName ( 'female' ) ,
233+ familyName : faker . person . lastName ( 'female' )
234+ }
235+
236+ const childNameFormatted = formatName ( childName )
237+
238+ test . beforeAll ( async ( { browser } ) => {
239+ page = await browser . newPage ( )
240+ } )
241+
242+ test . afterAll ( async ( ) => {
243+ await page . close ( )
244+ } )
245+
246+ test . describe . serial ( 'Declaration started by FA' , async ( ) => {
247+ test . beforeAll ( async ( ) => {
248+ await login ( page , CREDENTIALS . FIELD_AGENT )
249+ await page . click ( '#header-new-event' )
250+ await page . getByLabel ( 'Birth' ) . click ( )
251+ await page . getByRole ( 'button' , { name : 'Continue' } ) . click ( )
252+ await page . getByRole ( 'button' , { name : 'Continue' } ) . click ( )
253+ } )
254+
255+ test ( 'Fill child details with birth date from over a year ago' , async ( ) => {
256+ await page . locator ( '#firstname' ) . fill ( childName . firstNames )
257+ await page . locator ( '#surname' ) . fill ( childName . familyName )
258+ await page . locator ( '#child____gender' ) . click ( )
259+ await page . getByText ( 'Female' , { exact : true } ) . click ( )
260+
261+ await page . getByPlaceholder ( 'dd' ) . fill ( '12' )
262+ await page . getByPlaceholder ( 'mm' ) . fill ( '05' )
263+ await page . getByPlaceholder ( 'yyyy' ) . fill ( '2019' )
264+ await page . locator ( '#child____reason' ) . fill ( 'Late registration reason' )
265+
266+ await page . locator ( '#child____placeOfBirth' ) . click ( )
267+ await page . getByText ( 'Health Institution' , { exact : true } ) . click ( )
268+ await page
269+ . locator ( '#child____birthLocation' )
270+ . fill ( 'Golden Valley Rural Health Centre' . slice ( 0 , 3 ) )
271+ await page . getByText ( 'Golden Valley Rural Health Centre' ) . click ( )
272+
273+ await continueForm ( page )
274+ } )
275+
276+ test ( 'Fill informant details' , async ( ) => {
277+ await page . locator ( '#informant____relation' ) . click ( )
278+ await page . getByText ( 'Mother' , { exact : true } ) . click ( )
279+
280+ await page . locator ( '#informant____email' ) . fill ( '[email protected] ' ) 281+
282+ await continueForm ( page )
283+ } )
284+
285+ test ( "Fill mother's details" , async ( ) => {
286+ await page . locator ( '#firstname' ) . fill ( faker . person . firstName ( 'female' ) )
287+ await page . locator ( '#surname' ) . fill ( faker . person . lastName ( 'female' ) )
288+
289+ await page . getByPlaceholder ( 'dd' ) . fill ( '25' )
290+ await page . getByPlaceholder ( 'mm' ) . fill ( '11' )
291+ await page . getByPlaceholder ( 'yyyy' ) . fill ( '2025' )
292+
293+ await page . locator ( '#mother____idType' ) . click ( )
294+ await page . getByText ( 'None' , { exact : true } ) . click ( )
295+
296+ await continueForm ( page )
297+ } )
298+
299+ test ( "Fill father's details" , async ( ) => {
300+ await page . locator ( '#firstname' ) . fill ( faker . person . firstName ( 'male' ) )
301+ await page . locator ( '#surname' ) . fill ( faker . person . lastName ( 'male' ) )
302+
303+ await page . getByPlaceholder ( 'dd' ) . fill ( '12' )
304+ await page . getByPlaceholder ( 'mm' ) . fill ( '05' )
305+ await page . getByPlaceholder ( 'yyyy' ) . fill ( '1985' )
306+
307+ await page . locator ( '#father____idType' ) . click ( )
308+ await page . getByText ( 'None' , { exact : true } ) . click ( )
309+
310+ await page . locator ( '#father____nationality' ) . click ( )
311+ await page . getByText ( 'Gabon' , { exact : true } ) . click ( )
312+
313+ await page . locator ( '#father____addressSameAs_YES' ) . click ( )
314+
315+ await page . getByRole ( 'button' , { name : 'Continue' } ) . click ( )
316+ } )
317+
318+ test ( 'Go to review' , async ( ) => {
319+ await goToSection ( page , 'review' )
320+ } )
321+
322+ test ( 'Fill up informant comment & signature' , async ( ) => {
323+ await page . locator ( '#review____comment' ) . fill ( faker . lorem . sentence ( ) )
324+ await page . getByRole ( 'button' , { name : 'Sign' , exact : true } ) . click ( )
325+ await drawSignature ( page , 'review____signature_canvas_element' , false )
326+ await page
327+ . locator ( '#review____signature_modal' )
328+ . getByRole ( 'button' , { name : 'Apply' } )
329+ . click ( )
330+ } )
331+
332+ test ( 'Send for review' , async ( ) => {
333+ await page . getByRole ( 'button' , { name : 'Send for review' } ) . click ( )
334+ await page . getByRole ( 'button' , { name : 'Confirm' } ) . click ( )
335+ await ensureOutboxIsEmpty ( page )
336+ } )
337+
338+ test ( 'Navigate to the record' , async ( ) => {
339+ await page . getByText ( 'Sent for review' ) . click ( )
340+ await page . getByRole ( 'button' , { name : childNameFormatted } ) . click ( )
341+ } )
342+
343+ test ( "Record should not have the 'Approval required for late registration' -flag" , async ( ) => {
344+ await expect (
345+ page . getByText ( 'Approval required for late registration' )
346+ ) . not . toBeVisible ( )
347+ } )
348+
349+ test ( 'Record should not have the "Approve"-action available' , async ( ) => {
350+ await page . getByRole ( 'button' , { name : 'Action' , exact : true } ) . click ( )
351+ await expect ( page . getByText ( 'Approve' , { exact : true } ) ) . not . toBeVisible ( )
352+ } )
353+ } )
354+ } )
0 commit comments