Skip to content

Commit 52bfd63

Browse files
committed
test(policy-workbench): add signature footer model serialization spec
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent a8842f2 commit 52bfd63

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 LibreSign contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { describe, expect, it } from 'vitest'
7+
8+
import {
9+
getDefaultSignatureFooterPolicyConfig,
10+
normalizeSignatureFooterPolicyConfig,
11+
serializeSignatureFooterPolicyConfig,
12+
} from '../../../../views/Settings/PolicyWorkbench/settings/signature-footer/model'
13+
14+
describe('signature-footer model', () => {
15+
it('normalizes legacy boolean values', () => {
16+
expect(normalizeSignatureFooterPolicyConfig(true)).toEqual({
17+
enabled: true,
18+
writeQrcodeOnFooter: true,
19+
validationSite: '',
20+
customizeFooterTemplate: false,
21+
})
22+
23+
expect(normalizeSignatureFooterPolicyConfig('0')).toEqual({
24+
enabled: false,
25+
writeQrcodeOnFooter: true,
26+
validationSite: '',
27+
customizeFooterTemplate: false,
28+
})
29+
})
30+
31+
it('normalizes structured JSON payload', () => {
32+
const payload = '{"enabled":true,"writeQrcodeOnFooter":false,"validationSite":"https://validation.example","customizeFooterTemplate":true}'
33+
expect(normalizeSignatureFooterPolicyConfig(payload)).toEqual({
34+
enabled: true,
35+
writeQrcodeOnFooter: false,
36+
validationSite: 'https://validation.example',
37+
customizeFooterTemplate: true,
38+
})
39+
})
40+
41+
it('serializes canonical payload from config object', () => {
42+
const serialized = serializeSignatureFooterPolicyConfig({
43+
enabled: true,
44+
writeQrcodeOnFooter: true,
45+
validationSite: '',
46+
customizeFooterTemplate: false,
47+
})
48+
49+
expect(serialized).toBe('{"enabled":true,"writeQrcodeOnFooter":true,"validationSite":"","customizeFooterTemplate":false}')
50+
})
51+
52+
it('returns defaults when payload is empty', () => {
53+
expect(normalizeSignatureFooterPolicyConfig('')).toEqual(getDefaultSignatureFooterPolicyConfig())
54+
})
55+
})

0 commit comments

Comments
 (0)