refactor(sync) : remove restrictedMode and add sync service + confirmation modal
This commit is contained in:
@@ -227,98 +227,6 @@ describe('required checkbox', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Restricted mode
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('restricted mode', () => {
|
||||
it('allows editing name of pre-existing field', () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: {
|
||||
customFields: [{ name: 'Locked Field', type: 'text', required: false, orderIndex: 0 }],
|
||||
products: [],
|
||||
},
|
||||
})
|
||||
|
||||
const nameInput = wrapper.find('input[type="text"]')
|
||||
expect((nameInput.element as HTMLInputElement).disabled).toBe(false)
|
||||
})
|
||||
|
||||
it('disables type select for pre-existing field', () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: {
|
||||
customFields: [{ name: 'Locked', type: 'text', required: false, orderIndex: 0 }],
|
||||
products: [],
|
||||
},
|
||||
})
|
||||
|
||||
const selects = wrapper.findAll('select')
|
||||
const typeSelect = selects[selects.length - 1]
|
||||
expect((typeSelect.element as HTMLSelectElement).disabled).toBe(true)
|
||||
})
|
||||
|
||||
it('disables required checkbox for pre-existing field', () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: {
|
||||
customFields: [{ name: 'Locked', type: 'text', required: false, orderIndex: 0 }],
|
||||
products: [],
|
||||
},
|
||||
})
|
||||
|
||||
const checkbox = wrapper.find('input[type="checkbox"]')
|
||||
expect((checkbox.element as HTMLInputElement).disabled).toBe(true)
|
||||
})
|
||||
|
||||
it('hides delete button for pre-existing field', () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: {
|
||||
customFields: [{ name: 'Locked', type: 'text', required: false, orderIndex: 0 }],
|
||||
products: [],
|
||||
},
|
||||
})
|
||||
|
||||
// btn-error should not exist for locked fields
|
||||
const deleteBtn = wrapper.find('button.btn-error')
|
||||
expect(deleteBtn.exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('allows full editing of newly added field', async () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: {
|
||||
customFields: [],
|
||||
products: [],
|
||||
},
|
||||
})
|
||||
|
||||
await getAddFieldButton(wrapper).trigger('click')
|
||||
await nextTick()
|
||||
|
||||
// New field should have an editable type select (not disabled)
|
||||
const selects = wrapper.findAll('select')
|
||||
const typeSelect = selects[selects.length - 1]
|
||||
expect((typeSelect.element as HTMLSelectElement).disabled).toBe(false)
|
||||
|
||||
// Delete button should exist for new field
|
||||
const deleteBtn = wrapper.find('button.btn-error')
|
||||
expect(deleteBtn.exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('hides product add button in restricted mode', () => {
|
||||
const wrapper = mountEditor({
|
||||
restrictedMode: true,
|
||||
modelValue: { customFields: [], products: [] },
|
||||
})
|
||||
|
||||
const addButtons = wrapper.findAll('button').filter(b => b.text().includes('Ajouter'))
|
||||
// Only the "add field" button should be visible, not the product one
|
||||
expect(addButtons.length).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Add product
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user