feat(32.2-02): every consent card state, account switch and login hint
- Loading skeleton (aria-busy, no buttons), Expired (404 or no request, no call), Load error with Try again, No grantable scope (Deny only), Returning with the continue link for http(s) redirects - 422 shows scopes_required under the scopes; 5xx, network, 400 and a javascript:/data:/vbscript: redirect show decide_failed; ticks kept - 401 hands over to expireSession; focus follows the state heading - Use another account: logout() without the router, then login with the /connect?request= redirect - LoginView shows mcp_connect.login_hint when the redirect is /connect
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { enableAutoUnmount, flushPromises } from '@vue/test-utils'
|
||||
import type { MCPConsent } from '../../src/api/types'
|
||||
import { API, mountApp, requestsTo, resetState, type Route } from '../helpers'
|
||||
import { API, mountApp, notFound, requestsTo, resetState, type Route } from '../helpers'
|
||||
|
||||
const REDIRECT = 'https://agent.example.test/callback?code=abc123&state=xyz'
|
||||
|
||||
@@ -84,4 +84,34 @@ describe('consent card (UI-SPEC C1)', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('shows the Expired state when the request is unknown (404 on load)', async () => {
|
||||
const { wrapper, calls } = await mountApp('/connect?request=req1', {
|
||||
[`GET ${API}/mcp/consent/req1`]: { status: 404, body: notFound },
|
||||
})
|
||||
|
||||
const card = wrapper.find('[data-connect-state="expired"]')
|
||||
expect(card.exists()).toBe(true)
|
||||
expect(card.find('h1').text()).toBe('backend::lang.mcp_connect.expired_heading')
|
||||
expect(card.find('[data-action="open-admin"]').attributes('href')).toBe('/')
|
||||
expect(wrapper.find('[data-action="allow"]').exists()).toBe(false)
|
||||
expect(requestsTo(calls, 'POST', `${API}/mcp/consent/req1`)).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('Use another account signs out and returns through login to the same request', async () => {
|
||||
const { wrapper, calls, router } = await mountApp('/connect?request=req1', {
|
||||
...consentRoutes(),
|
||||
[`POST ${API}/auth/logout`]: { body: { data: {}, meta: {} } },
|
||||
})
|
||||
|
||||
await wrapper.find('[data-action="switch-account"]').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(requestsTo(calls, 'POST', `${API}/auth/logout`)).toHaveLength(1)
|
||||
expect(requestsTo(calls, 'POST', `${API}/mcp/consent/req1`)).toHaveLength(0)
|
||||
expect(router.currentRoute.value.name).toBe('login')
|
||||
expect(router.currentRoute.value.query.redirect).toBe('/connect?request=req1')
|
||||
expect(wrapper.find('[data-login-hint]').text()).toBe('backend::lang.mcp_connect.login_hint')
|
||||
expect(assign).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user