Skip to content

Commit b0bd20b

Browse files
test(signature-stamp): add regression for dimension field min and API error display
Verify that width/height NcTextField components bind min=1 (not 0.1) matching SIGNATURE_DIMENSION_MINIMUM on the backend. Verify that a 400 response error message is pushed to errorMessageTemplate and rendered to the user. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent d1c1c2f commit b0bd20b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/tests/views/Settings/SignatureStamp.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,41 @@ describe('SignatureStamp.vue', () => {
316316
expect(wrapper.vm.signatureWidth).toBe(180)
317317
expect(wrapper.vm.signatureHeight).toBe(90)
318318
})
319+
320+
it('regression: signature dimension fields bind min="1" matching the backend SIGNATURE_DIMENSION_MINIMUM', () => {
321+
const wrapper = createWrapper()
322+
323+
const textFields = wrapper.findAllComponents({ name: 'NcTextField' })
324+
const widthField = textFields.find(c => c.props('label') === 'Default signature width')
325+
const heightField = textFields.find(c => c.props('label') === 'Default signature height')
326+
327+
expect(widthField).toBeDefined()
328+
expect(heightField).toBeDefined()
329+
expect(widthField!.attributes('min')).toBe('1')
330+
expect(heightField!.attributes('min')).toBe('1')
331+
})
332+
333+
it('regression: shows API error when saveTemplate receives a 400 for invalid signature box size', async () => {
334+
axiosPostMock.mockRejectedValue({
335+
response: {
336+
data: {
337+
ocs: {
338+
data: {
339+
error: 'Invalid signature box size. Width and height must be at least 1.',
340+
},
341+
},
342+
},
343+
},
344+
})
345+
const wrapper = createWrapper()
346+
347+
await wrapper.vm.saveTemplate()
348+
await flushPromises()
349+
350+
expect(wrapper.vm.errorMessageTemplate).toContain(
351+
'Invalid signature box size. Width and height must be at least 1.',
352+
)
353+
expect(wrapper.vm.parsed).toBe('')
354+
expect(wrapper.vm.templateSaved).toBe(false)
355+
})
319356
})

0 commit comments

Comments
 (0)