Skip to content

Commit c404b44

Browse files
test(vue3): adapt RequestSignatureTab spec for script setup
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 4f1a2e3 commit c404b44

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/tests/components/RightSidebar/RequestSignatureTab.spec.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
7474
await filesStore.addFile({ ...current, ...patch, id: 1 })
7575
await wrapper.vm.$nextTick()
7676
}
77+
const setVmState = async (patch: Record<string, unknown>) => {
78+
Object.entries(patch).forEach(([key, value]) => {
79+
;(wrapper.vm as Record<string, unknown>)[key] = value
80+
})
81+
await wrapper.vm.$nextTick()
82+
}
7783
const updateMethods = async (methods: unknown[]) => {
78-
await wrapper.setData({ methods })
84+
await setVmState({ methods })
7985
}
8086

8187
beforeEach(async () => {
@@ -352,13 +358,13 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
352358

353359
describe('RULE: showSigningProgress when document active', () => {
354360
it('shows when signingProgressStatus is SIGNING_IN_PROGRESS', async () => {
355-
await wrapper.setData({ signingProgressStatus: FILE_STATUS.SIGNING_IN_PROGRESS })
361+
await setVmState({ signingProgressStatus: FILE_STATUS.SIGNING_IN_PROGRESS })
356362

357363
expect(wrapper.vm.showSigningProgress).toBe(true)
358364
})
359365

360366
it('hides when signingProgressStatus is not SIGNING_IN_PROGRESS', async () => {
361-
await wrapper.setData({ signingProgressStatus: FILE_STATUS.DRAFT })
367+
await setVmState({ signingProgressStatus: FILE_STATUS.DRAFT })
362368

363369
expect(wrapper.vm.showSigningProgress).toBe(false)
364370
})
@@ -618,36 +624,36 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
618624
})
619625

620626
it('uses admin flow when file flow is none', async () => {
621-
await wrapper.setData({ adminSignatureFlow: 'ordered_numeric' })
627+
await setVmState({ adminSignatureFlow: 'ordered_numeric' })
622628
await updateFile({ signatureFlow: 'none' })
623629
expect(wrapper.vm.signatureFlow).toBe('ordered_numeric')
624630
})
625631

626632
it('defaults to parallel when both file and admin are none', async () => {
627-
await wrapper.setData({ adminSignatureFlow: 'none' })
633+
await setVmState({ adminSignatureFlow: 'none' })
628634
await updateFile({ signatureFlow: 'none' })
629635
expect(wrapper.vm.signatureFlow).toBe('parallel')
630636
})
631637
})
632638

633639
describe('RULE: isAdminFlowForced detection', () => {
634640
it('returns true when admin flow set to ordered_numeric', async () => {
635-
await wrapper.setData({ adminSignatureFlow: 'ordered_numeric' })
641+
await setVmState({ adminSignatureFlow: 'ordered_numeric' })
636642
expect(wrapper.vm.isAdminFlowForced).toBe(true)
637643
})
638644

639645
it('returns true when admin flow set to parallel', async () => {
640-
await wrapper.setData({ adminSignatureFlow: 'parallel' })
646+
await setVmState({ adminSignatureFlow: 'parallel' })
641647
expect(wrapper.vm.isAdminFlowForced).toBe(true)
642648
})
643649

644650
it('returns false when admin flow is none', async () => {
645-
await wrapper.setData({ adminSignatureFlow: 'none' })
651+
await setVmState({ adminSignatureFlow: 'none' })
646652
expect(wrapper.vm.isAdminFlowForced).toBe(false)
647653
})
648654

649655
it('hides preserve order switch when admin forces flow', async () => {
650-
await wrapper.setData({ adminSignatureFlow: 'ordered_numeric' })
656+
await setVmState({ adminSignatureFlow: 'ordered_numeric' })
651657
await updateFile({
652658
signers: [
653659
{ email: 'test1@example.com' },
@@ -846,7 +852,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
846852
})
847853

848854
it('reverts to parallel when disabling', async () => {
849-
await wrapper.setData({ adminSignatureFlow: 'none' })
855+
await setVmState({ adminSignatureFlow: 'none' })
850856
await updateFile({
851857
signatureFlow: 'ordered_numeric',
852858
signers: [
@@ -859,7 +865,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
859865
})
860866

861867
it('preserves admin flow when disabling user preference', async () => {
862-
await wrapper.setData({ adminSignatureFlow: 'ordered_numeric' })
868+
await setVmState({ adminSignatureFlow: 'ordered_numeric' })
863869
await updateFile({
864870
signatureFlow: 'ordered_numeric',
865871
signers: [
@@ -892,7 +898,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
892898
})
893899

894900
it('disables preserve order when admin forces flow', async () => {
895-
await wrapper.setData({ adminSignatureFlow: 'ordered_numeric' })
901+
await setVmState({ adminSignatureFlow: 'ordered_numeric' })
896902
await updateFile({ signatureFlow: 'ordered_numeric' })
897903
wrapper.vm.syncPreserveOrderWithFile()
898904
expect(wrapper.vm.preserveOrder).toBe(false)
@@ -945,7 +951,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
945951
{ name: 'sms', enabled: true, friendly_name: 'SMS' },
946952
{ name: 'account', enabled: false, friendly_name: 'Account' },
947953
])
948-
await wrapper.setData({ signerToEdit: {} })
954+
await setVmState({ signerToEdit: {} })
949955
expect(wrapper.vm.enabledMethods).toHaveLength(2)
950956
expect(wrapper.vm.enabledMethods.map((m: { name: string }) => m.name)).toContain('email')
951957
expect(wrapper.vm.enabledMethods.map((m: { name: string }) => m.name)).toContain('sms')
@@ -956,7 +962,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
956962
{ name: 'email', enabled: true, friendly_name: 'Email' },
957963
{ name: 'sms', enabled: false, friendly_name: 'SMS' },
958964
])
959-
await wrapper.setData({
965+
await setVmState({
960966
signerToEdit: {
961967
identify: 'test@example.com',
962968
identifyMethods: [{ method: 'sms' }],
@@ -968,7 +974,7 @@ describe('RequestSignatureTab - Critical Business Rules', () => {
968974

969975
it('detects disabled method for edited signer', async () => {
970976
await updateMethods([{ name: 'sms', enabled: false }])
971-
await wrapper.setData({
977+
await setVmState({
972978
signerToEdit: {
973979
identify: 'test@example.com',
974980
identifyMethods: [{ method: 'sms' }],

0 commit comments

Comments
 (0)