Skip to content

Commit 4c930db

Browse files
committed
test(signature-flow): cover disabled default option in instance create
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 89b5410 commit 4c930db

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/tests/views/Settings/PolicyWorkbench/SignatureFlowScalarRuleEditor.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,31 @@ describe('SignatureFlowScalarRuleEditor.vue', () => {
8282
const selectedStates = wrapper.findAll('.switch-state').map((node) => node.attributes('data-selected'))
8383
expect(selectedStates).toEqual(['false', 'false', 'false'])
8484
})
85+
86+
it('disables default option and shows helper copy for instance rule creation', async () => {
87+
const wrapper = mount(SignatureFlowScalarRuleEditor, {
88+
props: {
89+
modelValue: 'none',
90+
editorScope: 'system',
91+
editorMode: 'create',
92+
},
93+
global: {
94+
stubs: {
95+
NcCheckboxRadioSwitch: {
96+
props: ['disabled'],
97+
template: '<div class="switch-disabled" :data-disabled="disabled ? \'true\' : \'false\'" @click="!disabled && $emit(\'update:modelValue\', true)"><slot /></div>',
98+
},
99+
},
100+
},
101+
})
102+
103+
expect(wrapper.text()).toContain('already matches the system default')
104+
105+
const switches = wrapper.findAll('.switch-disabled')
106+
expect(switches).toHaveLength(3)
107+
expect(switches[2]?.attributes('data-disabled')).toBe('true')
108+
109+
await switches[2]?.trigger('click')
110+
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
111+
})
85112
})

0 commit comments

Comments
 (0)