@@ -21,7 +21,7 @@ import {
2121 generateEventDocument ,
2222 generateWorkqueues ,
2323 tennisClubMembershipEvent ,
24- field
24+ never
2525} from '@opencrvs/commons/client'
2626import { tennisClubMembershipEventDocument } from '@client/v2-events/features/events/fixtures'
2727import { ROUTES , routesConfig } from '@client/v2-events/routes'
@@ -47,6 +47,94 @@ const tRPCMsw = createTRPCMsw<AppRouter>({
4747 transformer : { input : superjson , output : superjson }
4848} )
4949
50+ export const NoTemplateAvailable : Story = {
51+ parameters : {
52+ chromatic : { disableSnapshot : true } ,
53+ reactRouter : {
54+ router : routesConfig ,
55+ initialPath : ROUTES . V2 . EVENTS . PRINT_CERTIFICATE . PAGES . buildPath ( {
56+ eventId : tennisClubMembershipEventDocument . id ,
57+ pageId : 'collector'
58+ } )
59+ } ,
60+ test : {
61+ // Ignoring the failed font request
62+ dangerouslyIgnoreUnhandledErrors : true
63+ } ,
64+ msw : {
65+ handlers : {
66+ config : [
67+ http . get (
68+ '/api/countryconfig/certificates/simple-certificate.svg' ,
69+ ( ) => {
70+ return HttpResponse . text (
71+ `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100"><text x="10" y="20">Simple Certificate</text></svg>`
72+ )
73+ }
74+ ) ,
75+ http . get ( 'http://localhost:2021/config' , ( ) => {
76+ return HttpResponse . json ( {
77+ systems : [ ] ,
78+ config : mockOfflineData . config ,
79+ certificates : [
80+ {
81+ id : 'simple-certificate' ,
82+ isV2Template : true ,
83+ event : 'tennis-club-membership' ,
84+ label : {
85+ id : 'certificates.simple.certificate.copy' ,
86+ defaultMessage : 'Simple Certificate copy' ,
87+ description : 'The label for a simple certificate'
88+ } ,
89+ conditionals : [
90+ {
91+ type : 'SHOW' ,
92+ conditional : never ( )
93+ }
94+ ] ,
95+ isDefault : false ,
96+ fee : {
97+ onTime : 7 ,
98+ late : 10.6 ,
99+ delayed : 18
100+ } ,
101+ svgUrl :
102+ '/api/countryconfig/certificates/simple-certificate.svg'
103+ }
104+ ]
105+ } )
106+ } )
107+ ] ,
108+ events : [
109+ tRPCMsw . event . config . get . query ( ( ) => {
110+ return [ tennisClubMembershipEvent ]
111+ } ) ,
112+ tRPCMsw . event . get . query ( ( ) => {
113+ return tennisClubMembershipEventDocument
114+ } )
115+ ]
116+ }
117+ }
118+ } ,
119+ play : async ( { canvasElement, step } ) => {
120+ const canvas = within ( canvasElement )
121+
122+ await step (
123+ 'Click Certification Type and find no options message' ,
124+ async ( ) => {
125+ await userEvent . click (
126+ await canvas . findByTestId ( 'select__certificateTemplateId' )
127+ )
128+ await expect (
129+ await canvas . findByText (
130+ 'No template available for this event, contact Admin'
131+ )
132+ ) . toBeVisible ( )
133+ }
134+ )
135+ }
136+ }
137+
50138export const ContinuingAndGoingBack : Story = {
51139 parameters : {
52140 chromatic : { disableSnapshot : true } ,
@@ -289,107 +377,3 @@ export const RedirectAfterPrint: Story = {
289377 } )
290378 }
291379}
292-
293- export const NoTemplateAvailable : Story = {
294- parameters : {
295- chromatic : { disableSnapshot : true } ,
296- reactRouter : {
297- router : routesConfig ,
298- initialPath : ROUTES . V2 . EVENTS . PRINT_CERTIFICATE . PAGES . buildPath ( {
299- eventId : tennisClubMembershipEventDocument . id ,
300- pageId : 'collector'
301- } )
302- } ,
303- test : {
304- // Ignoring the failed font request
305- dangerouslyIgnoreUnhandledErrors : true
306- } ,
307- msw : {
308- handlers : {
309- events : [
310- tRPCMsw . event . config . get . query ( ( ) => {
311- return [ tennisClubMembershipEvent ]
312- } ) ,
313- tRPCMsw . event . get . query ( ( ) => {
314- return tennisClubMembershipEventDocument
315- } )
316- ] ,
317- config : [
318- http . get (
319- '/api/countryconfig/certificates/simple-certificate.svg' ,
320- ( ) => {
321- return HttpResponse . text (
322- `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100"><text x="10" y="20">Simple Certificate</text></svg>`
323- )
324- }
325- ) ,
326- http . get ( 'http://localhost:2021/config' , ( ) => {
327- return HttpResponse . json ( {
328- systems : [ ] ,
329- config : mockOfflineData . config ,
330- certificates : [
331- {
332- id : 'simple-certificate' ,
333- isV2Template : true ,
334- event : 'tennis-club-membership' ,
335- label : {
336- id : 'certificates.simple.certificate.copy' ,
337- defaultMessage : 'Simple Certificate copy' ,
338- description : 'The label for a simple certificate'
339- } ,
340- conditionals : [
341- {
342- type : 'SHOW' ,
343- conditional : field ( 'applicant.dob' )
344- . isBefore ( )
345- . date ( '2007-01-01' )
346- }
347- ] ,
348- isDefault : false ,
349- fee : {
350- onTime : 7 ,
351- late : 10.6 ,
352- delayed : 18
353- } ,
354- svgUrl :
355- '/api/countryconfig/certificates/simple-certificate.svg'
356- }
357- ]
358- } )
359- } )
360- ]
361- }
362- }
363- } ,
364- play : async ( { canvasElement, step } ) => {
365- const canvas = within ( canvasElement )
366-
367- await step ( 'Try continuing without filling the form' , async ( ) => {
368- await expect (
369- await canvas . findByText ( 'Print certified copy' )
370- ) . toBeInTheDocument ( )
371-
372- const continueButton = await canvas . findByRole ( 'button' , {
373- name : 'Continue'
374- } )
375- await userEvent . click ( continueButton )
376- const requiredErrors = await canvas . findAllByText ( 'Required' )
377-
378- await expect ( requiredErrors . length ) . toBe ( 2 )
379- } )
380-
381- await step (
382- 'Click Certification Type and find no options message' ,
383- async ( ) => {
384- await userEvent . click (
385- await canvas . findByTestId ( 'select__certificateTemplateId' )
386- )
387- await expect (
388- await canvas . findByText (
389- 'No template available for this event, contact Admin'
390- )
391- ) . toBeVisible ( )
392- }
393- )
394- }
395- }
0 commit comments