test(36-02): update test fixtures for granular scopes and rebuild embedded admin dist
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Smoke tests of the MCP consent card (Phase 32.2 UI-SPEC C1): a signed-in
|
||||
// administrator opens /connect?request=…, keeps the ticks and clicks Allow,
|
||||
// and the browser leaves for the server-issued redirect_uri through
|
||||
// window.location.assign, never through the router. Fixtures are neutral.
|
||||
// Smoke tests of the MCP consent card (Phase 32.2 UI-SPEC C1 + Phase 36 C4):
|
||||
// a signed-in administrator opens /connect?request=…, keeps the safe Read-only
|
||||
// default and clicks Allow, and the browser leaves for the server-issued
|
||||
// redirect_uri through window.location.assign, never through the router.
|
||||
// Fixtures are neutral.
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { enableAutoUnmount, flushPromises } from '@vue/test-utils'
|
||||
import type { MCPConsent } from '../../src/api/types'
|
||||
@@ -15,8 +16,24 @@ function consentView(overrides: Partial<MCPConsent> = {}): MCPConsent {
|
||||
client: { id: 'client-1', name: 'Acme Agent', redirect_host: 'agent.example.test', logo_url: '' },
|
||||
admin: { login: 'dev', name: 'Dana Dev', email: 'dev@example.test' },
|
||||
scopes: [
|
||||
{ name: 'admin:read', label: 'Read the admin', description: 'Read every admin list.', read_only: true, known: true },
|
||||
{ name: 'acme', label: 'Acme', description: 'Use the acme tools.', read_only: false, known: true },
|
||||
{
|
||||
name: 'admin:read',
|
||||
label: 'Read the admin',
|
||||
description: 'Read every admin list.',
|
||||
read_only: true,
|
||||
known: true,
|
||||
plugin_id: '',
|
||||
group: '',
|
||||
},
|
||||
{
|
||||
name: 'acme',
|
||||
label: 'Acme',
|
||||
description: 'Use the acme tools.',
|
||||
read_only: false,
|
||||
known: true,
|
||||
plugin_id: 'acme.blog',
|
||||
group: 'Acme',
|
||||
},
|
||||
],
|
||||
offline_access: true,
|
||||
consent_required: true,
|
||||
@@ -47,8 +64,8 @@ afterEach(() => {
|
||||
|
||||
enableAutoUnmount(afterEach)
|
||||
|
||||
describe('consent card (UI-SPEC C1)', () => {
|
||||
it('Allow posts the ticked scopes and Stay connected, then leaves for redirect_uri without the router', async () => {
|
||||
describe('consent card (UI-SPEC C1 / Phase 36 C4)', () => {
|
||||
it('Allow defaults to Read-only (admin:read) and Stay connected, then leaves for redirect_uri without the router', async () => {
|
||||
const { wrapper, calls, router } = await mountApp('/connect?request=req1', consentRoutes())
|
||||
const push = vi.spyOn(router, 'push')
|
||||
const replace = vi.spyOn(router, 'replace')
|
||||
@@ -60,9 +77,8 @@ describe('consent card (UI-SPEC C1)', () => {
|
||||
expect(wrapper.find('nav[aria-label="backend::lang.nav.plugins"]').exists()).toBe(false)
|
||||
expect(card.find('[data-connect-host]').text()).toBe('agent.example.test')
|
||||
|
||||
const scopeBoxes = card.findAll('[data-scope] input[type="checkbox"]')
|
||||
expect(scopeBoxes).toHaveLength(2)
|
||||
expect(scopeBoxes.map((box) => (box.element as HTMLInputElement).checked)).toEqual([true, true])
|
||||
expect(card.find('[data-access-tier="read_only"]').attributes('data-state')).toBe('checked')
|
||||
expect(card.find('[data-scope-summary]').text()).toContain('admin:read')
|
||||
const offline = card.find('[data-connect-offline] input[type="checkbox"]')
|
||||
expect((offline.element as HTMLInputElement).checked).toBe(true)
|
||||
|
||||
@@ -75,7 +91,7 @@ describe('consent card (UI-SPEC C1)', () => {
|
||||
const posts = requestsTo(calls, 'POST', `${API}/mcp/consent/req1`)
|
||||
expect(posts).toHaveLength(1)
|
||||
expect(posts[0]!.headers.get('X-Requested-With')).toBe('XMLHttpRequest')
|
||||
expect(await posts[0]!.json()).toEqual({ decision: 'allow', scopes: ['admin:read', 'acme'], offline_access: true })
|
||||
expect(await posts[0]!.json()).toEqual({ decision: 'allow', scopes: ['admin:read'], offline_access: true })
|
||||
expect(assign).toHaveBeenCalledWith(REDIRECT)
|
||||
for (const spy of [push, replace]) {
|
||||
expect(spy).not.toHaveBeenCalledWith(REDIRECT)
|
||||
|
||||
Reference in New Issue
Block a user