Skip to content

Commit 8250aa2

Browse files
committed
test(Sign): add regression for envelope multi-file signing
Covers issue #7344 phase 2: when an envelope has multiple child files each with a me=true signer and a distinct sign_request_uuid, the submitSignature method should call signStore.submitSignature once per file with only the elements belonging to that file and the correct UUID. Four cases are covered: - per-file calls with visible elements (canCreateSignature=false) - per-file calls with no visible elements (click-to-sign envelope) - single-file documents remain unaffected (non-envelope baseline) - per-file calls with profileNodeId when canCreateSignature=true Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 63aa01b commit 8250aa2

1 file changed

Lines changed: 189 additions & 0 deletions

File tree

src/tests/views/SignPDF/Sign.spec.ts

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,3 +1473,192 @@ describe('Sign.vue - signWithTokenCode', () => {
14731473
})
14741474
})
14751475
})
1476+
1477+
describe('Sign.vue - envelope multi-file signing (issue #7344 phase 2)', () => {
1478+
let submitSignatureCompatMethod: SubmitSignatureCompatMethod
1479+
1480+
beforeAll(async () => {
1481+
const SignComponent = await import('../../../views/SignPDF/_partials/Sign.vue')
1482+
submitSignatureCompatMethod = (SignComponent.default as any).methods.submitSignature
1483+
})
1484+
1485+
it('calls signStore.submitSignature once per file for envelopes with multiple me=true signers', async () => {
1486+
const storeSubmitMock = vi.fn().mockResolvedValue({ status: 'signed', data: {} })
1487+
1488+
const context = {
1489+
loading: false,
1490+
elements: [
1491+
{ elementId: 100, signRequestId: 10, type: 'signature' },
1492+
{ elementId: 200, signRequestId: 20, type: 'signature' },
1493+
],
1494+
canCreateSignature: false,
1495+
signRequestUuid: 'uuid-file-1',
1496+
signatureElementsStore: { signs: {} },
1497+
actionHandler: { showModal: vi.fn(), closeModal: vi.fn() },
1498+
signStore: {
1499+
document: {
1500+
id: 1,
1501+
nodeType: 'envelope',
1502+
signers: [
1503+
{ signRequestId: 10, me: true, sign_request_uuid: 'uuid-file-1' },
1504+
{ signRequestId: 20, me: true, sign_request_uuid: 'uuid-file-2' },
1505+
],
1506+
},
1507+
clearSigningErrors: vi.fn(),
1508+
setSigningErrors: vi.fn(),
1509+
submitSignature: storeSubmitMock,
1510+
},
1511+
$emit: vi.fn(),
1512+
sidebarStore: { hideSidebar: vi.fn() },
1513+
}
1514+
1515+
await submitSignatureCompatMethod.call(context, { method: 'clickToSign' })
1516+
1517+
expect(storeSubmitMock).toHaveBeenCalledTimes(2)
1518+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1519+
1,
1520+
{ method: 'clickToSign', elements: [{ documentElementId: 100 }] },
1521+
'uuid-file-1',
1522+
{ documentId: 1 },
1523+
)
1524+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1525+
2,
1526+
{ method: 'clickToSign', elements: [{ documentElementId: 200 }] },
1527+
'uuid-file-2',
1528+
{ documentId: 1 },
1529+
)
1530+
})
1531+
1532+
it('submits each file without elements when no visible elements are placed (click-to-sign envelope)', async () => {
1533+
const storeSubmitMock = vi.fn().mockResolvedValue({ status: 'signed', data: {} })
1534+
1535+
const context = {
1536+
loading: false,
1537+
elements: [],
1538+
canCreateSignature: false,
1539+
signRequestUuid: 'uuid-file-1',
1540+
signatureElementsStore: { signs: {} },
1541+
actionHandler: { showModal: vi.fn(), closeModal: vi.fn() },
1542+
signStore: {
1543+
document: {
1544+
id: 1,
1545+
nodeType: 'envelope',
1546+
signers: [
1547+
{ signRequestId: 10, me: true, sign_request_uuid: 'uuid-file-1' },
1548+
{ signRequestId: 20, me: true, sign_request_uuid: 'uuid-file-2' },
1549+
],
1550+
},
1551+
clearSigningErrors: vi.fn(),
1552+
setSigningErrors: vi.fn(),
1553+
submitSignature: storeSubmitMock,
1554+
},
1555+
$emit: vi.fn(),
1556+
sidebarStore: { hideSidebar: vi.fn() },
1557+
}
1558+
1559+
await submitSignatureCompatMethod.call(context, { method: 'clickToSign' })
1560+
1561+
expect(storeSubmitMock).toHaveBeenCalledTimes(2)
1562+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1563+
1,
1564+
{ method: 'clickToSign' },
1565+
'uuid-file-1',
1566+
{ documentId: 1 },
1567+
)
1568+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1569+
2,
1570+
{ method: 'clickToSign' },
1571+
'uuid-file-2',
1572+
{ documentId: 1 },
1573+
)
1574+
})
1575+
1576+
it('preserves single-file behavior when document nodeType is not envelope', async () => {
1577+
const storeSubmitMock = vi.fn().mockResolvedValue({ status: 'signed', data: {} })
1578+
1579+
const context = {
1580+
loading: false,
1581+
elements: [
1582+
{ elementId: 100, signRequestId: 10, type: 'signature' },
1583+
],
1584+
canCreateSignature: false,
1585+
signRequestUuid: 'uuid-file-1',
1586+
signatureElementsStore: { signs: {} },
1587+
actionHandler: { showModal: vi.fn(), closeModal: vi.fn() },
1588+
signStore: {
1589+
document: {
1590+
id: 1,
1591+
nodeType: 'file',
1592+
signers: [
1593+
{ signRequestId: 10, me: true, sign_request_uuid: 'uuid-file-1' },
1594+
],
1595+
},
1596+
clearSigningErrors: vi.fn(),
1597+
setSigningErrors: vi.fn(),
1598+
submitSignature: storeSubmitMock,
1599+
},
1600+
$emit: vi.fn(),
1601+
sidebarStore: { hideSidebar: vi.fn() },
1602+
}
1603+
1604+
await submitSignatureCompatMethod.call(context, { method: 'clickToSign' })
1605+
1606+
expect(storeSubmitMock).toHaveBeenCalledTimes(1)
1607+
expect(storeSubmitMock).toHaveBeenCalledWith(
1608+
{ method: 'clickToSign', elements: [{ documentElementId: 100 }] },
1609+
'uuid-file-1',
1610+
{ documentId: 1 },
1611+
)
1612+
})
1613+
1614+
it('includes profileNodeId per element when canCreateSignature is true for envelope', async () => {
1615+
const storeSubmitMock = vi.fn().mockResolvedValue({ status: 'signed', data: {} })
1616+
1617+
const context = {
1618+
loading: false,
1619+
elements: [
1620+
{ elementId: 100, signRequestId: 10, type: 'signature' },
1621+
{ elementId: 200, signRequestId: 20, type: 'signature' },
1622+
],
1623+
canCreateSignature: true,
1624+
signRequestUuid: 'uuid-file-1',
1625+
signatureElementsStore: {
1626+
signs: {
1627+
signature: { file: { nodeId: 42 } },
1628+
},
1629+
},
1630+
actionHandler: { showModal: vi.fn(), closeModal: vi.fn() },
1631+
signStore: {
1632+
document: {
1633+
id: 1,
1634+
nodeType: 'envelope',
1635+
signers: [
1636+
{ signRequestId: 10, me: true, sign_request_uuid: 'uuid-file-1' },
1637+
{ signRequestId: 20, me: true, sign_request_uuid: 'uuid-file-2' },
1638+
],
1639+
},
1640+
clearSigningErrors: vi.fn(),
1641+
setSigningErrors: vi.fn(),
1642+
submitSignature: storeSubmitMock,
1643+
},
1644+
$emit: vi.fn(),
1645+
sidebarStore: { hideSidebar: vi.fn() },
1646+
}
1647+
1648+
await submitSignatureCompatMethod.call(context, { method: 'clickToSign' })
1649+
1650+
expect(storeSubmitMock).toHaveBeenCalledTimes(2)
1651+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1652+
1,
1653+
{ method: 'clickToSign', elements: [{ documentElementId: 100, profileNodeId: 42 }] },
1654+
'uuid-file-1',
1655+
{ documentId: 1 },
1656+
)
1657+
expect(storeSubmitMock).toHaveBeenNthCalledWith(
1658+
2,
1659+
{ method: 'clickToSign', elements: [{ documentElementId: 200, profileNodeId: 42 }] },
1660+
'uuid-file-2',
1661+
{ documentId: 1 },
1662+
)
1663+
})
1664+
})

0 commit comments

Comments
 (0)