Skip to content

Commit 6d5b140

Browse files
committed
test(policy-workbench): show remove and instance create actions in UI
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 4d996ac commit 6d5b140

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,29 @@ describe('RealPolicyWorkbench.vue', () => {
159159
expect(wrapper.text()).not.toContain('← Back')
160160
})
161161

162+
it('shows remove action for instance default rules', async () => {
163+
getPolicy.mockImplementation((key: string) => {
164+
if (key === 'signature_flow') {
165+
return { effectiveValue: 'ordered_numeric', sourceScope: 'global' }
166+
}
167+
168+
return null
169+
})
170+
171+
const wrapper = mountWorkbench()
172+
173+
const openPolicyButton = wrapper.findAll('button').find((button) => button.text().includes('Open policy'))
174+
expect(openPolicyButton).toBeTruthy()
175+
await openPolicyButton?.trigger('click')
176+
177+
const actionsTrigger = wrapper.find('button[aria-label="Rule actions"]')
178+
expect(actionsTrigger.exists()).toBe(true)
179+
await actionsTrigger.trigger('click')
180+
181+
const removeButton = wrapper.findAll('.nc-actions-stub__menu button').find((button) => button.text() === 'Remove')
182+
expect(removeButton).toBeTruthy()
183+
})
184+
162185
it('allows reopening create flow after canceling a draft', async () => {
163186
const wrapper = mountWorkbench()
164187

@@ -188,6 +211,28 @@ describe('RealPolicyWorkbench.vue', () => {
188211
expect(wrapper.find('.policy-workbench__create-scope-dialog').exists()).toBe(true)
189212
})
190213

214+
it('shows instance option in create rule when only system default is active', async () => {
215+
getPolicy.mockImplementation((key: string) => {
216+
if (key === 'signature_flow') {
217+
return { effectiveValue: 'ordered_numeric', sourceScope: 'system' }
218+
}
219+
220+
return null
221+
})
222+
223+
const wrapper = mountWorkbench()
224+
225+
const openPolicyButton = wrapper.findAll('button').find((button) => button.text().includes('Open policy'))
226+
expect(openPolicyButton).toBeTruthy()
227+
await openPolicyButton?.trigger('click')
228+
229+
await wrapper.find('button.policy-workbench__crud-create-cta').trigger('click')
230+
231+
const createScopeDialog = wrapper.find('.policy-workbench__create-scope-dialog')
232+
expect(createScopeDialog.exists()).toBe(true)
233+
expect(createScopeDialog.text()).toContain('Instance')
234+
})
235+
191236
it('shows unified default summary in system default mode', async () => {
192237
getPolicy.mockImplementation((key: string) => {
193238
if (key === 'signature_flow') {

0 commit comments

Comments
 (0)