test(36-04): add Vitest unit and component tests covering all 7 scope picker backstops

This commit is contained in:
Jakub Zych
2026-11-24 20:08:24 +01:00
parent 782f4dc19d
commit 2661e0f363
5 changed files with 1072 additions and 0 deletions

View File

@@ -353,6 +353,129 @@ describe('ApiTokenCreateDialog step 1', () => {
})
})
describe('ApiTokenCreateDialog Phase 36 scope picker backstops (#1, #3, #5)', () => {
const pluginScopes = [
...scopes,
{
name: 'journal',
label: 'Journal',
description: 'Create and edit posts.',
read_only: false,
known: true,
plugin_id: 'acme.journal',
group: 'Journal',
},
{
name: 'journal:read',
label: 'Journal, read-only',
description: 'Read posts.',
read_only: true,
known: true,
plugin_id: 'acme.journal',
group: 'Journal',
},
{
name: 'seo',
label: 'SEO',
description: 'Manage SEO metadata.',
read_only: false,
known: true,
plugin_id: 'acme.seo',
group: 'SEO',
},
]
it('falls back to Full (*) when admin:read is absent from catalog (backstop #1, D-08)', async () => {
const withoutAdminRead = pluginScopes.filter((s) => s.name !== 'admin:read')
await openCreate({ [`GET ${SCOPES}`]: envelope(withoutAdminRead) })
expect(dialog()!.querySelector('[data-access-tier="read_only"]')).toBeNull()
expect(dialog()!.querySelector('[data-access-tier="full"]')!.getAttribute('data-state')).toBe('checked')
})
it('swaps view in place with zero second overlay, keeps max-w-[560px], preserves name/expires on Escape, and suppresses mod+s in picker view (backstop #5, D-02, D-13, T-36-06)', async () => {
const { calls } = await openCreate({ [`GET ${SCOPES}`]: envelope(pluginScopes) })
// Fill name and select 365d expiry before opening ScopePicker.
await fillName('Editorial bot')
const seg365 = [...dialog()!.querySelectorAll<HTMLElement>('[data-expiry-segment]')].find((el) =>
el.textContent?.includes('365 dni'),
)!
seg365.click()
await flushPromises()
expect(dialog()!.textContent).toContain(`Wygasa ${localDatePlus(365)}.`)
// Clicking Custom when empty auto-opens ScopePicker in place inside the same dialog.
await click('[data-access-tier="custom"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeTruthy()
expect(document.body.querySelectorAll('[data-dialog-overlay]')).toHaveLength(1)
expect(dialog()!.className).toContain('max-w-[560px]')
// mod+s / mod+enter submit button hotkey is unmounted while in ScopePicker view.
expect(dialog()!.querySelector('[data-hotkey]')).toBeNull()
expect(dialog()!.querySelector('[data-action="create-token-submit"]')).toBeNull()
dialog()!.dispatchEvent(new KeyboardEvent('keydown', { key: 's', ctrlKey: true, bubbles: true }))
await flushPromises()
expect(requestsTo(calls, 'POST', TOKENS)).toHaveLength(0)
// Tick a scope in draft, then press Escape: discards draft, reverts auto-opened Custom back to Read-only,
// stays inside the open dialog (does not close it), and preserves name and 365d expiry.
const journalBox = dialog()!.querySelector<HTMLInputElement>('[data-scope="journal"] input[type="checkbox"]')!
journalBox.checked = true
journalBox.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
keydown(dialog()!, 'Escape')
await flushPromises()
expect(dialog()).toBeTruthy()
expect(dialog()!.querySelector('[data-scope-picker]')).toBeNull()
expect(dialog()!.querySelector('[data-access-tier="read_only"]')!.getAttribute('data-state')).toBe('checked')
expect(dialog()!.querySelector<HTMLInputElement>('#api-token-name')!.value).toBe('Editorial bot')
expect(dialog()!.textContent).toContain(`Wygasa ${localDatePlus(365)}.`)
})
it('remembers applied Custom selection across tier switches and submits exact scopes without admin:read unless opted in (backstop #3, D-09, D-11)', async () => {
const { calls } = await openCreate({ [`GET ${SCOPES}`]: envelope(pluginScopes) })
await fillName('Journal writer')
// Auto-open empty Custom, pick journal, apply.
await click('[data-access-tier="custom"]', dialog()!)
const journalBox = dialog()!.querySelector<HTMLInputElement>('[data-scope="journal"] input[type="checkbox"]')!
journalBox.checked = true
journalBox.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
await click('[data-action="scope-picker-apply"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeNull()
expect(dialog()!.querySelector('[data-access-tier="custom"]')!.getAttribute('data-state')).toBe('checked')
expect(dialog()!.querySelector('[data-summary-chip="journal"]')).toBeTruthy()
expect(dialog()!.querySelector('[data-summary-chip="admin:read"]')).toBeNull()
// Switch to Read-only and back to Custom -> restores saved selection without reopening ScopePicker.
await click('[data-access-tier="read_only"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeNull()
await click('[data-access-tier="custom"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeNull()
expect(dialog()!.querySelector('[data-summary-chip="journal"]')).toBeTruthy()
// Customize scopes button opens in-place swap with zero second overlay; Cancel returns without losing saved selection.
await click('[data-action="customize-scopes"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeTruthy()
expect(document.body.querySelectorAll('[data-dialog-overlay]')).toHaveLength(1)
await click('[data-action="scope-picker-discard"]', dialog()!)
expect(dialog()!.querySelector('[data-scope-picker]')).toBeNull()
expect(dialog()!.querySelector('[data-summary-chip="journal"]')).toBeTruthy()
// Submit posts ['journal'] (omitting admin:read).
await click('[data-action="create-token-submit"]', dialog()!)
const [post] = requestsTo(calls, 'POST', TOKENS)
expect(await post!.clone().json()).toEqual({
name: 'Journal writer',
expires: '90d',
scopes: ['journal'],
})
})
})
describe('ApiTokenCreateDialog step 2', () => {
it('copy success flashes for two seconds and announces politely', async () => {
vi.useFakeTimers()

View File

@@ -0,0 +1,280 @@
// Pure unit tests for admin/src/app/scopeCatalog.ts (Phase 36 backstops #1, #2, #4, #7).
import { describe, expect, it } from 'vitest'
import type { AdminAPITokenScope } from '../../src/api/types'
import {
buildSummaryModel,
computeDefaultExpanded,
computeSubmittedScopes,
groupPluginScopes,
isEffectivelySelected,
matchesScopeQuery,
partitionCatalog,
resolveInitialState,
} from '../../src/app/scopeCatalog'
function scope(overrides: Partial<AdminAPITokenScope> & Pick<AdminAPITokenScope, 'name'>): AdminAPITokenScope {
return {
label: overrides.name,
description: `Description for ${overrides.name}`,
read_only: overrides.name.endsWith(':read'),
known: true,
plugin_id: 'acme.demo',
group: 'Demo',
...overrides,
}
}
const STAR = scope({ name: '*', label: 'Full access', read_only: false, plugin_id: '', group: '' })
const ADMIN_READ = scope({ name: 'admin:read', label: 'Read-only, whole admin', read_only: true, plugin_id: '', group: '' })
describe('partitionCatalog', () => {
it('splits *, admin:read, and plugin scopes preserving catalog order', () => {
const blog = scope({ name: 'blog', plugin_id: 'acme.blog', group: 'Blog' })
const blogRead = scope({ name: 'blog:read', plugin_id: 'acme.blog', group: 'Blog' })
const seo = scope({ name: 'seo', plugin_id: 'acme.seo', group: 'SEO' })
const result = partitionCatalog([STAR, ADMIN_READ, blog, blogRead, seo])
expect(result.fullScope).toEqual(STAR)
expect(result.adminReadScope).toEqual(ADMIN_READ)
expect(result.pluginScopes).toEqual([blog, blogRead, seo])
})
it('handles missing framework scopes cleanly', () => {
const blog = scope({ name: 'blog', plugin_id: 'acme.blog', group: 'Blog' })
const result = partitionCatalog([blog])
expect(result.fullScope).toBeNull()
expect(result.adminReadScope).toBeNull()
expect(result.pluginScopes).toEqual([blog])
})
})
describe('groupPluginScopes', () => {
it('keys groups by (plugin_id, group) to prevent collisions and tie-breaks by plugin_id (D-01, D-17)', () => {
const zetaWrite = scope({ name: 'zeta:write', plugin_id: 'zeta.blog', group: 'Blog' })
const zetaRead = scope({ name: 'zeta:read', plugin_id: 'zeta.blog', group: 'Blog' })
const alphaWrite = scope({ name: 'alpha:write', plugin_id: 'alpha.blog', group: 'Blog' })
const alphaRead = scope({ name: 'alpha:read', plugin_id: 'alpha.blog', group: 'Blog' })
const groups = groupPluginScopes([zetaWrite, zetaRead, alphaWrite, alphaRead], 'en', 'Other')
expect(groups).toHaveLength(2)
expect(groups.map((g) => g.key)).toEqual(['alpha.blog\0Blog', 'zeta.blog\0Blog'])
expect(groups.map((g) => g.label)).toEqual(['Blog', 'Blog'])
// Intra-group declared scope order is preserved verbatim.
expect(groups[0]!.scopes.map((s) => s.name)).toEqual(['alpha:write', 'alpha:read'])
expect(groups[1]!.scopes.map((s) => s.name)).toEqual(['zeta:write', 'zeta:read'])
})
it('sorts groups alphabetically using locale collation (pl vs en) and applies fallback label', () => {
const a = scope({ name: 's1', plugin_id: 'acme.l1', group: 'Lampa' })
const b = scope({ name: 's2', plugin_id: 'acme.l2', group: 'Łódź' })
const c = scope({ name: 's3', plugin_id: 'acme.l3', group: 'Mapa' })
const fallback = scope({ name: 's4', plugin_id: '', group: '' })
const plGroups = groupPluginScopes([c, b, a], 'pl', 'Inne')
expect(plGroups.map((g) => g.label)).toEqual(['Lampa', 'Łódź', 'Mapa'])
const withFallback = groupPluginScopes([fallback], 'en', 'Other')
expect(withFallback[0]!.label).toBe('Other')
})
})
describe('matchesScopeQuery', () => {
const s = scope({
name: 'journal:write',
label: 'Publish articles',
description: 'Create and update blog entries.',
plugin_id: 'golem15.journal',
group: 'Editorial',
})
it('matches case-insensitively across name, label, description, plugin_id, and groupLabel', () => {
expect(matchesScopeQuery(s, 'Editorial', '')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', ' ')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'JOURNAL:WRITE')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'publish')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'blog entries')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'golem15.journal')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'editor')).toBe(true)
expect(matchesScopeQuery(s, 'Editorial', 'sitemap')).toBe(false)
})
})
describe('isEffectivelySelected and computeDefaultExpanded', () => {
function makeLargeGroups(groupCount: number, scopesPerGroup: number) {
const items: AdminAPITokenScope[] = []
for (let g = 1; g <= groupCount; g++) {
for (let i = 1; i <= scopesPerGroup; i++) {
items.push(
scope({
name: `p${g}:s${i}`,
read_only: i % 2 === 0,
plugin_id: `acme.p${g}`,
group: `Plugin ${g}`,
}),
)
}
}
return { items, groups: groupPluginScopes(items, 'en', 'Other') }
}
it('marks read_only scopes effectively selected when admin:read is ON', () => {
const rw = scope({ name: 'blog', read_only: false })
const ro = scope({ name: 'blog:read', read_only: true })
expect(isEffectivelySelected(ro, { adminRead: true, scopes: new Set() })).toBe(true)
expect(isEffectivelySelected(rw, { adminRead: true, scopes: new Set() })).toBe(false)
expect(isEffectivelySelected(rw, { adminRead: false, scopes: new Set(['blog']) })).toBe(true)
})
it('expands all groups for small catalogs (<= 3 groups or <= 12 scopes) (D-07)', () => {
// 3 groups x 5 scopes = 15 scopes, <= 3 groups -> expand all
const threeGroups = makeLargeGroups(3, 5)
expect(
computeDefaultExpanded(threeGroups.groups, threeGroups.items.length, { adminRead: false, scopes: new Set() }, false),
).toEqual(new Set(threeGroups.groups.map((g) => g.key)))
// 4 groups x 3 scopes = 12 scopes -> <= 12 scopes -> expand all
const twelveScopes = makeLargeGroups(4, 3)
expect(
computeDefaultExpanded(twelveScopes.groups, twelveScopes.items.length, { adminRead: false, scopes: new Set() }, false),
).toEqual(new Set(twelveScopes.groups.map((g) => g.key)))
})
it('expands only selected groups for large catalogs (> 3 groups and > 12 scopes), or all when searching (D-07)', () => {
// 4 groups x 4 scopes = 16 scopes (> 3 groups AND > 12 scopes)
const large = makeLargeGroups(4, 4)
// None selected -> none expanded
expect(
computeDefaultExpanded(large.groups, large.items.length, { adminRead: false, scopes: new Set() }, false),
).toEqual(new Set())
// One scope in Plugin 2 selected -> only Plugin 2 expanded
expect(
computeDefaultExpanded(large.groups, large.items.length, { adminRead: false, scopes: new Set(['p2:s1']) }, false),
).toEqual(new Set(['acme.p2\0Plugin 2']))
// Searching -> all matching groups expanded regardless of selection
expect(
computeDefaultExpanded(large.groups, large.items.length, { adminRead: false, scopes: new Set() }, true),
).toEqual(new Set(large.groups.map((g) => g.key)))
})
})
describe('buildSummaryModel', () => {
it('orders admin:read first, then write scopes, then read-only scopes, and caps at 6 + overflow (D-06)', () => {
const catalog: AdminAPITokenScope[] = [
STAR,
ADMIN_READ,
scope({ name: 'a:read', label: 'A Read', read_only: true, plugin_id: 'acme.a', group: 'A' }),
scope({ name: 'b:read', label: 'B Read', read_only: true, plugin_id: 'acme.b', group: 'B' }),
scope({ name: 'c:write', label: 'C Write', read_only: false, plugin_id: 'acme.c', group: 'C' }),
scope({ name: 'd:write', label: 'D Write', read_only: false, plugin_id: 'acme.d', group: 'D' }),
scope({ name: 'e:read', label: 'E Read', read_only: true, plugin_id: 'acme.e', group: 'E' }),
scope({ name: 'f:write', label: 'F Write', read_only: false, plugin_id: 'acme.f', group: 'F' }),
scope({ name: 'g:read', label: 'G Read', read_only: true, plugin_id: 'acme.g', group: 'G' }),
scope({ name: 'h:read', label: 'H Read', read_only: true, plugin_id: 'acme.h', group: 'H' }),
]
// Without admin:read: 3 writes first, then 5 reads = 8 total -> 6 visible + overflow 2
const withoutAdminRead = buildSummaryModel(catalog, {
adminRead: false,
scopes: new Set(['a:read', 'b:read', 'c:write', 'd:write', 'e:read', 'f:write', 'g:read', 'h:read']),
})
expect(withoutAdminRead.chips.map((c) => c.name)).toEqual([
'c:write',
'd:write',
'f:write',
'a:read',
'b:read',
'e:read',
'g:read',
'h:read',
])
expect(withoutAdminRead.visible).toHaveLength(6)
expect(withoutAdminRead.overflowCount).toBe(2)
expect(withoutAdminRead.selectedWriteCount).toBe(3)
expect(withoutAdminRead.selectedPluginCount).toBe(8)
expect(withoutAdminRead.distinctPluginCount).toBe(8)
// With admin:read ON: admin:read first, then writes only (redundant :read scopes omitted from chips)
const withAdminRead = buildSummaryModel(catalog, {
adminRead: true,
scopes: new Set(['a:read', 'c:write', 'd:write', 'f:write']),
})
expect(withAdminRead.chips.map((c) => [c.name, c.kind])).toEqual([
['admin:read', 'admin_read'],
['c:write', 'write'],
['d:write', 'write'],
['f:write', 'write'],
])
expect(withAdminRead.selectedWriteCount).toBe(3)
expect(withAdminRead.selectedPluginCount).toBe(3)
expect(withAdminRead.distinctPluginCount).toBe(3)
})
})
describe('computeSubmittedScopes', () => {
const catalog = [
STAR,
ADMIN_READ,
scope({ name: 'blog', read_only: false, plugin_id: 'acme.blog', group: 'Blog' }),
scope({ name: 'blog:read', read_only: true, plugin_id: 'acme.blog', group: 'Blog' }),
scope({ name: 'seo', read_only: false, plugin_id: 'acme.seo', group: 'SEO' }),
]
it('omits admin:read in custom when adminRead is false (T-36-04)', () => {
expect(
computeSubmittedScopes('custom', catalog, { adminRead: false, scopes: new Set(['blog', 'blog:read']) }),
).toEqual(['blog', 'blog:read'])
})
it('emits ["admin:read", ...writes] and strips redundant :read codes when adminRead is true (D-04)', () => {
expect(
computeSubmittedScopes('custom', catalog, { adminRead: true, scopes: new Set(['blog', 'blog:read', 'seo']) }),
).toEqual(['admin:read', 'blog', 'seo'])
})
it('emits ["*"] for full and ["admin:read"] for read_only', () => {
expect(computeSubmittedScopes('full', catalog, { adminRead: false, scopes: new Set() })).toEqual(['*'])
expect(computeSubmittedScopes('read_only', catalog, { adminRead: false, scopes: new Set() })).toEqual(['admin:read'])
})
})
describe('resolveInitialState', () => {
const blog = scope({ name: 'blog', read_only: false, plugin_id: 'acme.blog', group: 'Blog' })
const seo = scope({ name: 'seo', read_only: false, plugin_id: 'acme.seo', group: 'SEO' })
it('resolves ConnectView defaults (D-03): Read-only when grantable, Custom for narrow subset, Full for *-only', () => {
expect(resolveInitialState([STAR, ADMIN_READ, blog], 'connect')).toEqual({
tier: 'read_only',
custom: { adminRead: false, scopes: new Set() },
})
expect(resolveInitialState([blog, seo], 'connect')).toEqual({
tier: 'custom',
custom: { adminRead: false, scopes: new Set(['blog', 'seo']) },
})
expect(resolveInitialState([STAR], 'connect')).toEqual({
tier: 'full',
custom: { adminRead: false, scopes: new Set() },
})
})
it('resolves ApiTokenCreateDialog defaults (D-08): Read-only when grantable, Full (*) fallback when admin:read absent', () => {
expect(resolveInitialState([STAR, ADMIN_READ, blog], 'token')).toEqual({
tier: 'read_only',
custom: { adminRead: false, scopes: new Set() },
})
expect(resolveInitialState([STAR, blog], 'token')).toEqual({
tier: 'full',
custom: { adminRead: false, scopes: new Set() },
})
expect(resolveInitialState([blog], 'token')).toEqual({
tier: 'custom',
custom: { adminRead: false, scopes: new Set() },
})
})
})

View File

@@ -0,0 +1,204 @@
// Component tests for ScopeAccessControl.vue (Phase 36 backstop #7 + tier controls).
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { enableAutoUnmount, mount } from '@vue/test-utils'
import type { AdminAPITokenScope } from '../../src/api/types'
import { setBundle } from '../../src/app/i18n'
import ScopeAccessControl from '../../src/components/scopes/ScopeAccessControl.vue'
import { langFixture } from '../fixtures/typed'
import { resetState } from '../helpers'
const strings = {
'backend::lang.api_tokens.access_level': { other: 'Access level' },
'backend::lang.api_tokens.tier_full': { other: 'Full access' },
'backend::lang.api_tokens.tier_read_only': { other: 'Read-only' },
'backend::lang.api_tokens.tier_custom': { other: 'Custom' },
'backend::lang.api_tokens.read_only': { other: 'Read-only' },
'backend::lang.api_tokens.scope_customize': { other: 'Customize scopes…' },
'backend::lang.api_tokens.scope_summary_empty': { other: 'No scopes selected yet. Choose at least one scope to continue.' },
'backend::lang.api_tokens.scope_more': { other: '+:count more' },
'backend::lang.api_tokens.scope_count': { one: ':count scope', other: ':count scopes' },
'backend::lang.api_tokens.scope_write_count': { one: ':count write scope', other: ':count write scopes' },
'backend::lang.api_tokens.scope_plugin_count': { one: ':count plugin', other: ':count plugins' },
'backend::lang.api_tokens.scope_summary_line': { other: ':scopes across :plugins' },
'backend::lang.api_tokens.scope_summary_admin_read_plus': { other: 'Read-only admin + :scopes across :plugins' },
}
function makeScope(overrides: Partial<AdminAPITokenScope> & Pick<AdminAPITokenScope, 'name'>): AdminAPITokenScope {
return {
label: overrides.name,
description: `Description for ${overrides.name}`,
read_only: overrides.name.endsWith(':read'),
known: true,
plugin_id: 'acme.demo',
group: 'Demo',
...overrides,
}
}
const STAR = makeScope({ name: '*', label: 'Full access', read_only: false, plugin_id: '', group: '' })
const ADMIN_READ = makeScope({ name: 'admin:read', label: 'Read-only admin', read_only: true, plugin_id: '', group: '' })
beforeEach(() => {
resetState()
setBundle({ ...langFixture.data, ...strings }, 'en')
})
afterEach(() => {
document.body.innerHTML = ''
})
enableAutoUnmount(afterEach)
describe('ScopeAccessControl.vue', () => {
it('renders 3-tier RadioGroupRoot, omits missing tiers, and hides RadioGroupRoot when <= 1 tier', () => {
const blog = makeScope({ name: 'blog', label: 'Blog', read_only: false, plugin_id: 'acme.blog', group: 'Blog' })
const allThree = mount(ScopeAccessControl, {
props: {
catalog: [STAR, ADMIN_READ, blog],
availableTiers: ['full', 'read_only', 'custom'],
tier: 'read_only',
custom: { adminRead: false, scopes: new Set<string>() },
idPrefix: 'test-3',
},
attachTo: document.body,
})
expect(allThree.findAll('[data-access-tier]').map((el) => el.attributes('data-access-tier'))).toEqual([
'full',
'read_only',
'custom',
])
const twoTiers = mount(ScopeAccessControl, {
props: {
catalog: [STAR, ADMIN_READ],
availableTiers: ['full', 'read_only'],
tier: 'read_only',
custom: { adminRead: false, scopes: new Set<string>() },
idPrefix: 'test-2',
},
attachTo: document.body,
})
expect(twoTiers.findAll('[data-access-tier]').map((el) => el.attributes('data-access-tier'))).toEqual([
'full',
'read_only',
])
const oneTier = mount(ScopeAccessControl, {
props: {
catalog: [STAR],
availableTiers: ['full'],
tier: 'full',
custom: { adminRead: false, scopes: new Set<string>() },
idPrefix: 'test-1',
},
attachTo: document.body,
})
expect(oneTier.find('[data-access-tiers]').exists()).toBe(false)
expect(oneTier.find('[data-scope-all-note]').exists()).toBe(true)
})
it('renders elevated-first chips capped at 6 + clickable +2 more chip that emits customize (backstop #7, D-06)', async () => {
const catalog: AdminAPITokenScope[] = [
STAR,
ADMIN_READ,
makeScope({ name: 'p1:read', label: 'P1 Read', read_only: true, plugin_id: 'acme.p1', group: 'P1' }),
makeScope({ name: 'p2:read', label: 'P2 Read', read_only: true, plugin_id: 'acme.p2', group: 'P2' }),
makeScope({ name: 'p3:write', label: 'P3 Write', read_only: false, plugin_id: 'acme.p3', group: 'P3' }),
makeScope({ name: 'p4:write', label: 'P4 Write', read_only: false, plugin_id: 'acme.p4', group: 'P4' }),
makeScope({ name: 'p5:read', label: 'P5 Read', read_only: true, plugin_id: 'acme.p5', group: 'P5' }),
makeScope({ name: 'p6:write', label: 'P6 Write', read_only: false, plugin_id: 'acme.p6', group: 'P6' }),
makeScope({ name: 'p7:read', label: 'P7 Read', read_only: true, plugin_id: 'acme.p7', group: 'P7' }),
makeScope({ name: 'p8:read', label: 'P8 Read', read_only: true, plugin_id: 'acme.p8', group: 'P8' }),
]
// 8 selected plugin scopes (3 writes + 5 reads) -> writes sorted before reads, capped at 6 + "+2 more"
const wrapper = mount(ScopeAccessControl, {
props: {
catalog,
availableTiers: ['full', 'read_only', 'custom'],
tier: 'custom',
custom: {
adminRead: false,
scopes: new Set(['p1:read', 'p2:read', 'p3:write', 'p4:write', 'p5:read', 'p6:write', 'p7:read', 'p8:read']),
},
idPrefix: 'cap-test',
},
attachTo: document.body,
})
const chips = wrapper.findAll('[data-summary-chip]')
expect(chips).toHaveLength(6)
expect(chips.map((c) => c.attributes('data-summary-chip'))).toEqual([
'p3:write',
'p4:write',
'p6:write',
'p1:read',
'p2:read',
'p5:read',
])
const moreBtn = wrapper.find('[data-action="customize-scopes-more"]')
expect(moreBtn.exists()).toBe(true)
expect(moreBtn.text()).toBe('+2 more')
await moreBtn.trigger('click')
expect(wrapper.emitted('customize')).toHaveLength(1)
// With admin:read ON + 7 writes -> admin:read chip renders FIRST, capped at 6 + "+2 more"
const writesCatalog: AdminAPITokenScope[] = [
STAR,
ADMIN_READ,
...Array.from({ length: 7 }, (_, i) =>
makeScope({
name: `w${i + 1}`,
label: `Write ${i + 1}`,
read_only: false,
plugin_id: `acme.w${i + 1}`,
group: `W${i + 1}`,
}),
),
]
const adminReadFirst = mount(ScopeAccessControl, {
props: {
catalog: writesCatalog,
availableTiers: ['full', 'read_only', 'custom'],
tier: 'custom',
custom: {
adminRead: true,
scopes: new Set(['w1', 'w2', 'w3', 'w4', 'w5', 'w6', 'w7']),
},
idPrefix: 'admin-read-first',
},
attachTo: document.body,
})
const arChips = adminReadFirst.findAll('[data-summary-chip]')
expect(arChips).toHaveLength(6)
expect(arChips[0]!.attributes('data-summary-chip')).toBe('admin:read')
expect(adminReadFirst.find('[data-action="customize-scopes-more"]').text()).toBe('+2 more')
})
it('renders empty state, invalid styling, and disabled controls accurately', async () => {
const blog = makeScope({ name: 'blog', label: 'Blog', read_only: false, plugin_id: 'acme.blog', group: 'Blog' })
const wrapper = mount(ScopeAccessControl, {
props: {
catalog: [STAR, ADMIN_READ, blog],
availableTiers: ['full', 'read_only', 'custom'],
tier: 'custom',
custom: { adminRead: false, scopes: new Set<string>() },
invalid: true,
disabled: true,
idPrefix: 'state-test',
},
attachTo: document.body,
})
const summary = wrapper.find('[data-scope-summary]')
expect(summary.attributes('aria-invalid')).toBe('true')
expect(summary.classes()).toContain('border-danger')
expect(wrapper.find('[data-scope-summary-count]').text()).toBe(
'No scopes selected yet. Choose at least one scope to continue.',
)
expect(wrapper.find('[data-scope-summary-chips]').exists()).toBe(false)
expect((wrapper.find('[data-action="customize-scopes"]').element as HTMLButtonElement).disabled).toBe(true)
})
})

View File

@@ -0,0 +1,309 @@
// Component tests for ScopePicker.vue (Phase 36 backstops #2, #4).
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { defineComponent, ref } from 'vue'
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
import type { AdminAPITokenScope } from '../../src/api/types'
import { setBundle } from '../../src/app/i18n'
import ScopePicker from '../../src/components/scopes/ScopePicker.vue'
import { langFixture } from '../fixtures/typed'
import { resetState } from '../helpers'
const strings = {
'backend::lang.permissioneditor.other': { other: 'Other' },
'backend::lang.api_tokens.read_only': { other: 'Read-only' },
'backend::lang.api_tokens.via_admin_read': { other: 'via admin:read' },
'backend::lang.api_tokens.scope_search_label': { other: 'Search scopes' },
'backend::lang.api_tokens.scope_search_placeholder': { other: 'Search plugins or scopes…' },
'backend::lang.api_tokens.scope_search_clear': { other: 'Clear search' },
'backend::lang.api_tokens.scope_filter_label': { other: 'Filter scopes' },
'backend::lang.api_tokens.scope_filter_all': { other: 'All (:count)' },
'backend::lang.api_tokens.scope_filter_selected': { other: 'Selected (:count)' },
'backend::lang.api_tokens.scope_filter_read_only': { other: 'Read-only (:count)' },
'backend::lang.api_tokens.scope_filter_reset': { other: 'Show all scopes' },
'backend::lang.api_tokens.scope_also_admin_read': { other: 'Also allow reading everything in admin' },
'backend::lang.api_tokens.scope_also_admin_read_hint': { other: 'Includes all read-only scopes.' },
'backend::lang.api_tokens.group_select_read': { other: 'Read' },
'backend::lang.api_tokens.group_select_all': { other: 'All' },
'backend::lang.api_tokens.group_clear': { other: 'Clear' },
'backend::lang.api_tokens.group_select_read_named': { other: 'Select read-only scopes in :group' },
'backend::lang.api_tokens.group_select_all_named': { other: 'Select all scopes in :group' },
'backend::lang.api_tokens.group_clear_named': { other: 'Clear scopes in :group' },
'backend::lang.api_tokens.scope_empty_search_title': { other: 'No matching scopes' },
'backend::lang.api_tokens.scope_empty_search_body': { other: 'No scopes matched “:query”.' },
'backend::lang.api_tokens.scope_empty_selected_title': { other: 'No scopes selected' },
'backend::lang.api_tokens.scope_empty_selected_body': { other: 'Pick one or more scopes.' },
'backend::lang.api_tokens.scope_empty_readonly_title': { other: 'No read-only scopes' },
'backend::lang.api_tokens.scope_empty_readonly_body': { other: 'None of the available scopes are read-only.' },
'backend::lang.api_tokens.scope_picker_none_selected': { other: 'Select at least one scope to apply.' },
'backend::lang.api_tokens.scope_picker_apply': { other: 'Apply scopes' },
'backend::lang.api_tokens.scope_picker_selected': { other: ':scopes selected' },
'backend::lang.api_tokens.scope_picker_selected_admin_read': { other: 'admin:read + :scopes selected' },
'backend::lang.api_tokens.scope_summary_admin_read_only': { other: 'Read-only admin access' },
'backend::lang.api_tokens.scope_count': { one: ':count scope', other: ':count scopes' },
'backend::lang.api_tokens.scope_write_count': { one: ':count write scope', other: ':count write scopes' },
}
function makeScope(overrides: Partial<AdminAPITokenScope> & Pick<AdminAPITokenScope, 'name'>): AdminAPITokenScope {
return {
label: overrides.name,
description: `Description for ${overrides.name}`,
read_only: overrides.name.endsWith(':read'),
known: true,
plugin_id: 'acme.demo',
group: 'Demo',
...overrides,
}
}
const STAR = makeScope({ name: '*', label: 'Full access', read_only: false, plugin_id: '', group: '' })
const ADMIN_READ = makeScope({ name: 'admin:read', label: 'Read-only admin', read_only: true, plugin_id: '', group: '' })
function mountInteractivePicker(opts: {
catalog: AdminAPITokenScope[]
initialAdminRead?: boolean
initialScopes?: string[]
cancelLabel?: string
}) {
const Harness = defineComponent({
components: { ScopePicker },
setup() {
const draftAdminRead = ref(opts.initialAdminRead ?? false)
const draftScopes = ref<Set<string>>(new Set(opts.initialScopes ?? []))
const applied = ref(0)
const cancelled = ref(0)
return {
catalog: opts.catalog,
draftAdminRead,
draftScopes,
cancelLabel: opts.cancelLabel ?? 'Discard changes',
applied,
cancelled,
}
},
template: `
<ScopePicker
:catalog="catalog"
v-model:draft-admin-read="draftAdminRead"
v-model:draft-scopes="draftScopes"
:cancel-label="cancelLabel"
@apply="applied++"
@cancel="cancelled++"
/>
`,
})
return mount(Harness, { attachTo: document.body })
}
beforeEach(() => {
resetState()
setBundle({ ...langFixture.data, ...strings }, 'en')
})
afterEach(() => {
document.body.innerHTML = ''
})
enableAutoUnmount(afterEach)
describe('ScopePicker.vue', () => {
const smallCatalog: AdminAPITokenScope[] = [
STAR,
ADMIN_READ,
makeScope({
name: 'journal',
label: 'Journal',
description: 'Create and publish posts.',
read_only: false,
plugin_id: 'acme.journal',
group: 'Journal',
}),
makeScope({
name: 'journal:read',
label: 'Journal, read-only',
description: 'View posts and drafts.',
read_only: true,
plugin_id: 'acme.journal',
group: 'Journal',
}),
makeScope({
name: 'seo',
label: 'SEO',
description: 'Edit metadata and redirects.',
read_only: false,
plugin_id: 'acme.seo',
group: 'SEO',
}),
makeScope({
name: 'seo:read',
label: 'SEO, read-only',
description: 'Inspect metadata.',
read_only: true,
plugin_id: 'acme.seo',
group: 'SEO',
}),
]
it('implements admin:read lock semantics, via admin:read badge, disabled Read, selective Clear, and restores prior :read ticks (backstop #2, D-04, D-17)', async () => {
const wrapper = mountInteractivePicker({
catalog: smallCatalog,
initialAdminRead: false,
initialScopes: ['journal', 'journal:read'],
})
await flushPromises()
// Unchecked by default in Custom.
const adminReadCheckbox = wrapper.find('[data-admin-read-checkbox]')
expect((adminReadCheckbox.element as HTMLInputElement).checked).toBe(false)
expect(wrapper.findAll('[data-via-admin-read]')).toHaveLength(0)
// Enable admin:read opt-in toggle.
await adminReadCheckbox.setValue(true)
await flushPromises()
// Every read_only row is locked checked + disabled with via admin:read badge.
for (const roName of ['journal:read', 'seo:read']) {
const row = wrapper.find(`[data-scope="${roName}"]`)
const input = row.find('input[type="checkbox"]').element as HTMLInputElement
expect(input.checked).toBe(true)
expect(input.disabled).toBe(true)
expect(row.find('[data-via-admin-read]').exists()).toBe(true)
expect(row.find('[data-via-admin-read]').text()).toContain('via admin:read')
}
// Write rows remain unlocked.
const journalWriteInput = wrapper.find('[data-scope="journal"] input[type="checkbox"]').element as HTMLInputElement
expect(journalWriteInput.disabled).toBe(false)
expect(journalWriteInput.checked).toBe(true)
// Per-group Read button is disabled while admin:read is ON.
const journalGroup = wrapper.findAll('[data-scope-group]')[0]!
expect((journalGroup.find('[data-group-action="read"]').element as HTMLButtonElement).disabled).toBe(true)
// Per-group Clear unticks ONLY unlocked write scopes, leaving locked read_only scopes checked.
await journalGroup.find('[data-group-action="clear"]').trigger('click')
await flushPromises()
expect((wrapper.find('[data-scope="journal"] input[type="checkbox"]').element as HTMLInputElement).checked).toBe(
false,
)
expect(
(wrapper.find('[data-scope="journal:read"] input[type="checkbox"]').element as HTMLInputElement).checked,
).toBe(true)
// Toggling admin:read OFF restores prior :read ticks from draftScopes memory (journal:read was ticked, seo:read was not).
await adminReadCheckbox.setValue(false)
await flushPromises()
expect(wrapper.findAll('[data-via-admin-read]')).toHaveLength(0)
const journalReadInput = wrapper.find('[data-scope="journal:read"] input[type="checkbox"]')
.element as HTMLInputElement
const seoReadInput = wrapper.find('[data-scope="seo:read"] input[type="checkbox"]').element as HTMLInputElement
expect(journalReadInput.disabled).toBe(false)
expect(journalReadInput.checked).toBe(true)
expect(seoReadInput.disabled).toBe(false)
expect(seoReadInput.checked).toBe(false)
})
it('filters by search across plugin/group/label/code/description, auto-expands, restores expand state on clear, and shows empty search state (backstop #4)', async () => {
// Large catalog: 4 groups x 4 scopes = 16 scopes (> 3 groups AND > 12 scopes) -> all collapsed initially when empty.
const largeCatalog: AdminAPITokenScope[] = [STAR, ADMIN_READ]
for (let g = 1; g <= 4; g++) {
for (let i = 1; i <= 4; i++) {
largeCatalog.push(
makeScope({
name: `grp${g}:s${i}`,
label: `Group ${g} Action ${i}`,
description: g === 3 && i === 2 ? 'Special redirect sync tool' : `Desc ${g}.${i}`,
read_only: i % 2 === 0,
plugin_id: `acme.plug${g}`,
group: `Section ${g}`,
}),
)
}
}
const wrapper = mountInteractivePicker({ catalog: largeCatalog })
await flushPromises()
// Large catalog with 0 selected -> all 4 groups collapsed on mount (D-07).
const initialExpanded = wrapper
.findAll('[data-scope-group-toggle]')
.map((btn) => btn.attributes('aria-expanded'))
expect(initialExpanded).toEqual(['false', 'false', 'false', 'false'])
// Search matching description auto-expands matching group.
const search = wrapper.find('[data-scope-search]')
await search.setValue('redirect sync')
await flushPromises()
expect(wrapper.findAll('[data-scope-group]')).toHaveLength(1)
expect(wrapper.find('[data-scope-group-toggle]').attributes('aria-expanded')).toBe('true')
expect(wrapper.find('[data-scope="grp3:s2"]').exists()).toBe(true)
// Clear search restores pre-search collapsed expand state.
await wrapper.find('[data-action="clear-scope-search"]').trigger('click')
await flushPromises()
expect(wrapper.findAll('[data-scope-group]')).toHaveLength(4)
expect(wrapper.findAll('[data-scope-group-toggle]').map((btn) => btn.attributes('aria-expanded'))).toEqual([
'false',
'false',
'false',
'false',
])
// Search with 0 matches renders dashed empty state naming :query + Clear search button.
await search.setValue('nonexistent-xyz')
await flushPromises()
const empty = wrapper.find('[data-scope-picker-empty]')
expect(empty.exists()).toBe(true)
expect(empty.text()).toContain('No matching scopes')
expect(empty.text()).toContain('nonexistent-xyz')
await wrapper.find('[data-action="reset-scope-search"]').trigger('click')
await flushPromises()
expect(wrapper.findAll('[data-scope-group]')).toHaveLength(4)
})
it('shows live counts on filter pills, specific filter empty states, Show all scopes reset, and empty-draft Apply guard (backstop #4)', async () => {
const writeOnlyCatalog: AdminAPITokenScope[] = [
STAR,
makeScope({ name: 'a:write', label: 'A Write', read_only: false, plugin_id: 'acme.a', group: 'Alpha' }),
makeScope({ name: 'b:write', label: 'B Write', read_only: false, plugin_id: 'acme.b', group: 'Beta' }),
]
const wrapper = mountInteractivePicker({ catalog: writeOnlyCatalog })
await flushPromises()
// Small catalog (2 groups, 2 scopes) -> all expanded on mount.
expect(wrapper.findAll('[data-scope-group-toggle]').map((b) => b.attributes('aria-expanded'))).toEqual([
'true',
'true',
])
// Filter pills show live counts across full catalog.
expect(wrapper.find('[data-scope-filter="all"]').text()).toBe('All (2)')
expect(wrapper.find('[data-scope-filter="selected"]').text()).toBe('Selected (0)')
expect(wrapper.find('[data-scope-filter="read_only"]').text()).toBe('Read-only (0)')
// Empty draft disables Apply and announces none selected.
expect((wrapper.find('[data-action="scope-picker-apply"]').element as HTMLButtonElement).disabled).toBe(true)
expect(wrapper.find('[data-scope-picker-summary]').text()).toBe('Select at least one scope to apply.')
// Selected filter with 0 selected -> empty state + Show all scopes resets to All.
await wrapper.find('[data-scope-filter="selected"]').trigger('click')
await flushPromises()
expect(wrapper.find('[data-scope-picker-empty]').text()).toContain('No scopes selected')
await wrapper.find('[data-action="reset-scope-filter"]').trigger('click')
await flushPromises()
expect(wrapper.find('[data-scope-filter="all"]').attributes('aria-pressed')).toBe('true')
// Read-only filter with 0 read-only scopes -> empty state + Show all scopes.
await wrapper.find('[data-scope-filter="read_only"]').trigger('click')
await flushPromises()
expect(wrapper.find('[data-scope-picker-empty]').text()).toContain('No read-only scopes')
await wrapper.find('[data-action="reset-scope-filter"]').trigger('click')
await flushPromises()
// Ticking a scope updates live count and enables Apply.
await wrapper.find('[data-scope="a:write"] input[type="checkbox"]').setValue(true)
await flushPromises()
expect(wrapper.find('[data-scope-filter="selected"]').text()).toBe('Selected (1)')
expect((wrapper.find('[data-action="scope-picker-apply"]').element as HTMLButtonElement).disabled).toBe(false)
})
})

View File

@@ -243,6 +243,162 @@ describe('the 3-tier access control & Customize modal (UI backstop)', () => {
{ decision: 'allow', scopes: ['admin:read', 'acme'], offline_access: true },
])
})
it('opens narrow plugin-only subset in Custom with subset selected and hides Custom when no plugin scopes exist (backstop #1, D-03)', async () => {
const scopeSeo: AdminAPITokenScope = {
name: 'seo',
label: 'SEO',
description: 'Manage SEO.',
read_only: false,
known: true,
plugin_id: 'acme.seo',
group: 'SEO',
}
const narrow = await open(
'/connect?request=req1',
routes(consentView({ scopes: [SCOPE_ACME, scopeSeo] })),
)
expect(narrow.wrapper.find('[data-access-tiers]').exists()).toBe(false)
expect(narrow.wrapper.findAll('[data-summary-chip]').map((c) => c.attributes('data-summary-chip'))).toEqual([
'acme',
'seo',
])
await narrow.wrapper.find('[data-connect-state="ready"]').trigger('submit')
await flushPromises()
expect(await postedBodies(narrow.calls)).toEqual([
{ decision: 'allow', scopes: ['acme', 'seo'], offline_access: true },
])
narrow.wrapper.unmount()
const noPlugins = await open(
'/connect?request=req1',
routes(consentView({ scopes: [SCOPE_ALL, SCOPE_READ] })),
)
expect(
noPlugins.wrapper.findAll('[data-access-tier]').map((item) => item.attributes('data-access-tier')),
).toEqual(['full', 'read_only'])
expect(noPlugins.wrapper.find('[data-access-tier="custom"]').exists()).toBe(false)
expect(noPlugins.wrapper.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
})
it('reverts auto-opened empty Custom on Discard/Escape and remembers applied Custom across tier switches (backstop #3, D-09, D-11)', async () => {
const { wrapper } = await open(
'/connect?request=req1',
routes(consentView({ scopes: [SCOPE_ALL, SCOPE_READ, SCOPE_ACME] })),
)
expect(wrapper.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
// Auto-open empty Custom -> Discard reverts tier back to Read-only.
await clickTier('custom')
expect(pickerDialog()).toBeTruthy()
await tickPickerScope('acme', true)
pickerDialog()!.querySelector<HTMLButtonElement>('[data-action="scope-picker-discard"]')!.click()
await flushPromises()
expect(pickerDialog()).toBeNull()
expect(wrapper.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
// Auto-open empty Custom -> Escape reverts tier back to Read-only.
await clickTier('custom')
expect(pickerDialog()).toBeTruthy()
pickerDialog()!.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
await flushPromises()
expect(pickerDialog()).toBeNull()
expect(wrapper.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
// Apply Custom selection -> switch to Read-only -> switch back to Custom restores saved selection without reopening modal.
await clickTier('custom')
expect(pickerDialog()).toBeTruthy()
await tickPickerScope('acme', true)
pickerDialog()!.querySelector<HTMLButtonElement>('[data-action="scope-picker-apply"]')!.click()
await flushPromises()
expect(pickerDialog()).toBeNull()
expect(wrapper.find('[data-summary-chip="acme"]').exists()).toBe(true)
await clickTier('read_only')
expect(wrapper.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
await clickTier('custom')
expect(pickerDialog()).toBeNull()
expect(wrapper.find('[data-access-tier="custom"]').attributes('data-state')).toBe('checked')
expect(wrapper.find('[data-summary-chip="acme"]').exists()).toBe(true)
})
it('omits admin:read by default in Custom (PII footgun fix) and renders admin:read chip first when opted in (backstop #2, D-04, T-36-04)', async () => {
const scopeJournal: AdminAPITokenScope = {
name: 'journal',
label: 'Journal',
description: 'Manage posts.',
read_only: false,
known: true,
plugin_id: 'acme.journal',
group: 'Journal',
}
const scopeJournalRead: AdminAPITokenScope = {
name: 'journal:read',
label: 'Journal, read-only',
description: 'Read posts.',
read_only: true,
known: true,
plugin_id: 'acme.journal',
group: 'Journal',
}
// Without admin:read opt-in -> submits ['journal'] only.
const first = await open(
'/connect?request=req1',
routes(consentView({ scopes: [SCOPE_ALL, SCOPE_READ, scopeJournal, scopeJournalRead] })),
)
await clickTier('custom')
expect(pickerDialog()!.querySelector<HTMLInputElement>('[data-admin-read-checkbox]')!.checked).toBe(false)
await tickPickerScope('journal', true)
pickerDialog()!.querySelector<HTMLButtonElement>('[data-action="scope-picker-apply"]')!.click()
await flushPromises()
expect(first.wrapper.findAll('[data-summary-chip]').map((c) => c.attributes('data-summary-chip'))).toEqual([
'journal',
])
await first.wrapper.find('[data-connect-state="ready"]').trigger('submit')
await flushPromises()
expect(await postedBodies(first.calls)).toEqual([
{ decision: 'allow', scopes: ['journal'], offline_access: true },
])
first.wrapper.unmount()
// With admin:read opt-in -> renders admin:read chip first and submits ['admin:read', 'journal'].
const second = await open(
'/connect?request=req1',
routes(consentView({ scopes: [SCOPE_ALL, SCOPE_READ, scopeJournal, scopeJournalRead] })),
)
await clickTier('custom')
const adminRead = pickerDialog()!.querySelector<HTMLInputElement>('[data-admin-read-checkbox]')!
adminRead.checked = true
adminRead.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
await tickPickerScope('journal', true)
pickerDialog()!.querySelector<HTMLButtonElement>('[data-action="scope-picker-apply"]')!.click()
await flushPromises()
expect(second.wrapper.findAll('[data-summary-chip]').map((c) => c.attributes('data-summary-chip'))).toEqual([
'admin:read',
'journal',
])
await second.wrapper.find('[data-connect-state="ready"]').trigger('submit')
await flushPromises()
expect(await postedBodies(second.calls)).toEqual([
{ decision: 'allow', scopes: ['admin:read', 'journal'], offline_access: true },
])
})
it('applies connect-light-surface, mobile 100dvh sheet, and desktop 640px/85dvh classes to portaled Customize modal (backstop #6, D-10, D-12)', async () => {
await open('/connect?request=req1', routes(consentView({ scopes: [SCOPE_ALL, SCOPE_READ, SCOPE_ACME] })))
await clickTier('custom')
const overlay = document.body.querySelector<HTMLElement>('[data-dialog-overlay]')!
const content = pickerDialog()!
expect(overlay).toBeTruthy()
expect(content).toBeTruthy()
expect(overlay.classList.contains('connect-light-surface')).toBe(true)
expect(content.classList.contains('connect-light-surface')).toBe(true)
expect(content.className).toContain('h-[100dvh]')
expect(content.className).toContain('sm:max-w-[640px]')
expect(content.className).toContain('sm:max-h-[85dvh]')
})
})
describe('no auto-allow and the decision navigation (UI backstop)', () => {