@@ -8,6 +8,7 @@ import type { MockedFunction } from 'vitest'
88import { mount } from '@vue/test-utils'
99import type { VueWrapper } from '@vue/test-utils'
1010import type { TranslationFunction } from '../../test-types'
11+ import type { components } from '../../../types/openapi/openapi'
1112
1213type SigningProgressComponent = typeof import ( '../../../components/validation/SigningProgress.vue' ) . default
1314type StatusMeta = {
@@ -16,20 +17,8 @@ type StatusMeta = {
1617 [ key : string ] : unknown
1718}
1819
19- type ProgressFile = {
20- id : number
21- name ?: string
22- status ?: number
23- error ?: { message ?: string } | null
24- }
25-
26- type ProgressState = {
27- signed ?: number
28- inProgress ?: number
29- pending ?: number
30- total ?: number
31- files : ProgressFile [ ]
32- }
20+ type ProgressFile = components [ 'schemas' ] [ 'ProgressFile' ]
21+ type ProgressState = components [ 'schemas' ] [ 'ProgressPayload' ]
3322
3423type SigningProgressVm = {
3524 progress : ProgressState | null
@@ -95,6 +84,7 @@ vi.mock('../../../utils/fileStatus.js', () => ({
9584 '0' : { label : 'Draft' } ,
9685 '1' : { label : 'Ready to sign' } ,
9786 '3' : { label : 'Signed' } ,
87+ '5' : { label : 'Signing' } ,
9888 } ) ) ,
9989} ) )
10090
@@ -155,7 +145,7 @@ describe('SigningProgress', () => {
155145 pending : 1 ,
156146 total : 2 ,
157147 files : [
158- { id : 1 , name : 'file1.pdf' , error : { message : 'Error' } } ,
148+ { id : 1 , name : 'file1.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error' } } ,
159149 ] ,
160150 }
161151 await wrapper . vm . $nextTick ( )
@@ -181,7 +171,7 @@ describe('SigningProgress', () => {
181171 pending : 1 ,
182172 total : 2 ,
183173 files : [
184- { id : 1 , name : 'file1.pdf' , error : { message : 'Error' } } ,
174+ { id : 1 , name : 'file1.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error' } } ,
185175 ] ,
186176 }
187177 await wrapper . vm . $nextTick ( )
@@ -251,8 +241,8 @@ describe('SigningProgress', () => {
251241 pending : 0 ,
252242 total : 2 ,
253243 files : [
254- { id : 1 , error : null } ,
255- { id : 2 , error : null } ,
244+ { id : 1 , name : 'file1.pdf' , status : 3 , statusText : 'Signed' , error : undefined } ,
245+ { id : 2 , name : 'file2.pdf' , status : 3 , statusText : 'Signed' , error : undefined } ,
256246 ] ,
257247 }
258248
@@ -269,8 +259,8 @@ describe('SigningProgress', () => {
269259 pending : 0 ,
270260 total : 2 ,
271261 files : [
272- { id : 1 , error : { message : 'Error 1' } } ,
273- { id : 2 , error : { message : 'Error 2' } } ,
262+ { id : 1 , name : 'file1.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error 1' } } ,
263+ { id : 2 , name : 'file2.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error 2' } } ,
274264 ] ,
275265 }
276266
@@ -282,9 +272,13 @@ describe('SigningProgress', () => {
282272 it ( 'collects file errors' , ( ) => {
283273 wrapper = createWrapper ( )
284274 wrapper . vm . progress = {
275+ total : 2 ,
276+ signed : 0 ,
277+ inProgress : 0 ,
278+ pending : 2 ,
285279 files : [
286- { id : 1 , name : 'file1.pdf' , error : { message : 'Error 1' } } ,
287- { id : 2 , name : 'file2.pdf' , error : null } ,
280+ { id : 1 , name : 'file1.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error 1' } } ,
281+ { id : 2 , name : 'file2.pdf' , status : 0 , statusText : 'Draft' , error : undefined } ,
288282 ] ,
289283 }
290284
@@ -302,7 +296,7 @@ describe('SigningProgress', () => {
302296 '3' : { label : 'Signed' , icon : 'check' } ,
303297 }
304298
305- const meta = wrapper . vm . getFileStatusMeta ( { status : 3 } )
299+ const meta = wrapper . vm . getFileStatusMeta ( { id : 1 , name : 'file.pdf' , status : 3 , statusText : 'Signed' } )
306300
307301 expect ( meta . label ) . toBe ( 'Signed' )
308302 expect ( meta . icon ) . toBeTruthy ( )
@@ -312,7 +306,10 @@ describe('SigningProgress', () => {
312306 wrapper = createWrapper ( )
313307
314308 const meta = wrapper . vm . getFileStatusMeta ( {
309+ id : 1 ,
310+ name : 'file.pdf' ,
315311 status : 0 ,
312+ statusText : 'Draft' ,
316313 error : { message : 'Error' } ,
317314 } )
318315
@@ -367,8 +364,12 @@ describe('SigningProgress', () => {
367364 wrapper = createWrapper ( )
368365 wrapper . vm . isPolling = true
369366 wrapper . vm . progress = {
367+ total : 1 ,
368+ signed : 0 ,
369+ inProgress : 0 ,
370+ pending : 1 ,
370371 files : [
371- { id : 1 , error : { message : 'Error' } } ,
372+ { id : 1 , name : 'file.pdf' , status : 0 , statusText : 'Draft' , error : { message : 'Error' } } ,
372373 ] ,
373374 }
374375
@@ -441,4 +442,47 @@ describe('SigningProgress', () => {
441442 expect ( wrapper . vm . isPolling ) . toBe ( false )
442443 } )
443444 } )
445+
446+ describe ( 'RULE: buildProgressFromValidation returns OpenAPI-compatible progress payloads' , ( ) => {
447+ it ( 'builds file progress with required status text for envelope validation data' , ( ) => {
448+ wrapper = createWrapper ( )
449+
450+ const progress = wrapper . vm . buildProgressFromValidation ( {
451+ nodeType : 'envelope' ,
452+ files : [
453+ { id : 1 , name : 'contract.pdf' , status : 5 } ,
454+ { id : 2 , name : 'signed.pdf' , status : 3 } ,
455+ ] ,
456+ } )
457+
458+ expect ( progress ) . toEqual ( {
459+ total : 2 ,
460+ signed : 1 ,
461+ inProgress : 1 ,
462+ pending : 0 ,
463+ files : [
464+ { id : 1 , name : 'contract.pdf' , status : 5 , statusText : 'Signing' } ,
465+ { id : 2 , name : 'signed.pdf' , status : 3 , statusText : 'Signed' } ,
466+ ] ,
467+ } )
468+ } )
469+
470+ it ( 'builds signer progress with explicit inProgress field' , ( ) => {
471+ wrapper = createWrapper ( )
472+
473+ const progress = wrapper . vm . buildProgressFromValidation ( {
474+ signers : [
475+ { signed : true } ,
476+ { signed : false } ,
477+ ] ,
478+ } )
479+
480+ expect ( progress ) . toEqual ( {
481+ total : 2 ,
482+ signed : 1 ,
483+ inProgress : 0 ,
484+ pending : 1 ,
485+ } )
486+ } )
487+ } )
444488} )
0 commit comments