Skip to content

Commit fd55d3c

Browse files
test: cover recursive visible element file urls
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent b9761ea commit fd55d3c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/tests/services/visibleElementsService.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,35 @@
66
import { describe, expect, it } from 'vitest'
77
import {
88
getCurrentUserSignRequestIds,
9+
getFileUrl,
910
getVisibleElementsFromDocument,
1011
hasVisibleElementsForCurrentUser,
1112
} from '../../services/visibleElementsService'
1213

1314
describe('visibleElementsService', () => {
15+
describe('getFileUrl', () => {
16+
it('supports nested file objects with url payloads', () => {
17+
const file = {
18+
file: {
19+
url: '/apps/libresign/p/pdf/uuid-123',
20+
},
21+
}
22+
23+
expect(getFileUrl(file)).toBe('/apps/libresign/p/pdf/uuid-123')
24+
})
25+
26+
it('finds the first renderable child file recursively', () => {
27+
const file = {
28+
files: [
29+
{ id: 10, file: null },
30+
{ id: 20, file: { url: '/apps/libresign/p/pdf/uuid-456' } },
31+
],
32+
}
33+
34+
expect(getFileUrl(file)).toBe('/apps/libresign/p/pdf/uuid-456')
35+
})
36+
})
37+
1438
describe('getVisibleElementsFromDocument', () => {
1539
it('includes visible elements from child files (envelope)', () => {
1640
const document = {

0 commit comments

Comments
 (0)