feat: mirror v-can guard chains

This commit is contained in:
stanig2106
2025-11-14 19:23:18 +01:00
parent 2c4fe3f353
commit 7d823307fa
16 changed files with 573 additions and 138 deletions

21
test/chains.test.ts Normal file
View File

@@ -0,0 +1,21 @@
import { fileURLToPath } from 'node:url'
import { describe, it, expect } from 'vitest'
import { setup, $fetch } from '@nuxt/test-utils/e2e'
describe('chains fixture', async () => {
await setup({
rootDir: fileURLToPath(new URL('./fixtures/chains', import.meta.url)),
})
it('hides every branch when permission is missing and falls back to v-cannot', async () => {
const html = await $fetch('/')
expect(html).not.toContain('id="branch-pending"')
expect(html).toContain('id="branch-denied"')
})
it('renders explicit v-cannot blocks even when detached from the chain', async () => {
const html = await $fetch('/')
expect(html).toContain('id="explicit-denied"')
expect(html).not.toContain('id="approve-action"')
})
})