test(tencent-meeting): cover the account, the Plugins page, and the skills session

Specs drive a scripted tmeet through each auth status text, a sign-in with trusted and untrusted links, cancellation, and sign-out, and check the cache link and the one-entry skill. The Web E2E runs a stand-in tmeet through a failed and a successful sign-in and a confirmed sign-out; it needs the scaffold to resolve every selected bundle's dependencies, as the other CLI app plugins' do. The tencent-meeting-skills snapshot pins the skill catalog and a tmeet call on the private PATH.
This commit is contained in:
gengruilin committed 2026-10-19 12:04:19 +08:00
1 parent e6f2f2cfd1
commit de82f1ea97
18 files changed
+1140 -1

No files matched your search

@@ -0,0 +1,146 @@
// @vitest-environment jsdom
/** The account section, title tag, activation guidance, and notices render the Host view the page mirrors. */
import type { ComponentProps } from 'react'
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
import { bindSnapshotSelector, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import type { PluginPackageRef, PluginsSubject } from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
import type { TencentMeetingState } from '@deepseek-ai/dsh-tencent-meeting-cli/types'
import { afterEach, expect, it, vi } from 'vitest'
import type { ConnectionSnapshot } from '../src/client/connection.ts'
import { en, zh } from '../src/client/locales.ts'
import {
TencentMeetingConnectionActivation, TencentMeetingConnectionBadge, TencentMeetingConnectionSection, TencentMeetingConnectionToast,
} from '../src/client/TencentMeetingConnection.tsx'
afterEach(cleanup)
const OP = 'op' as CliOperationId
const LINK = 'https://meeting.tencent.com/marketplace/tencentmeeting-cli-auth.html?code=fixture'
const SIGNED_OUT: TencentMeetingState = { account: { state: 'signed-out' } }
const CONNECTED: TencentMeetingState = { account: { state: 'connected', userName: '测试用户' } }
function fixture(view?: TencentMeetingState, copy: typeof zh = zh) {
const state = createSnapshotStore<ConnectionSnapshot>({ view, linked: true, stopped: false, busy: false, notice: undefined })
const face = {
useTencentMeetingConnection: bindSnapshotSelector(state),
check: vi.fn(), signIn: vi.fn(), signOut: vi.fn(), cancel: vi.fn(),
openAuthorization: vi.fn(), retry: vi.fn(), dismissNotice: vi.fn(),
t: makeTranslate(copy),
}
return { face, set: (change: Partial<ConnectionSnapshot>) => { act(() => { state.set({ ...state.getSnapshot(), ...change }) }) } }
}
const button = (name: string) => screen.getByRole('button', { name })
it('offers the next step while signing in', () => {
const b = fixture(SIGNED_OUT)
render(<TencentMeetingConnectionSection {...b.face} />)
expect(screen.getByText(zh['detail.disconnected'])).toBeTruthy()
expect(screen.getByText(zh.hint)).toBeTruthy()
fireEvent.click(button(zh['action.connect']))
expect(b.face.signIn).toHaveBeenCalledOnce()
b.set({ view: { ...SIGNED_OUT, operation: { id: OP, kind: 'sign-in', phase: 'authorizing', cancellable: true } } })
expect(screen.getByText(zh['step.authorizing'])).toBeTruthy()
expect(screen.queryByRole('button', { name: zh['action.open'] })).toBeNull()
b.set({ view: { ...SIGNED_OUT, operation: { id: OP, kind: 'sign-in', phase: 'authorizing', cancellable: true, authorizationUrl: LINK } } })
expect(screen.getByText(zh['detail.authorizing'])).toBeTruthy()
fireEvent.click(button(zh['action.open']))
fireEvent.click(button(zh['action.cancel']))
expect(b.face.openAuthorization).toHaveBeenCalledOnce()
expect(b.face.cancel).toHaveBeenCalledOnce()
b.set({ view: { ...SIGNED_OUT, operation: { id: OP, kind: 'sign-in', phase: 'checking', cancellable: false } } })
expect(screen.getByText(zh['step.connecting'])).toBeTruthy()
expect(screen.queryAllByRole('button')).toHaveLength(0)
b.set({ view: undefined })
expect(screen.getByText(zh['status.checking'])).toBeTruthy()
expect(screen.queryAllByRole('button')).toHaveLength(0)
})
it('names the signed-in user and signs out only after confirmation', () => {
const b = fixture(CONNECTED)
render(<TencentMeetingConnectionSection {...b.face} />)
expect(screen.getByText(zh['detail.connected'].replace('{name}', '测试用户'))).toBeTruthy()
fireEvent.click(button(zh['action.signOut']))
const dialog = screen.getByRole('dialog')
expect(within(dialog).getByText(zh['signOut.body'])).toBeTruthy()
fireEvent.click(within(dialog).getByRole('button', { name: zh['action.cancel'] }))
expect(b.face.signOut).not.toHaveBeenCalled()
fireEvent.click(button(zh['action.signOut']))
fireEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: zh['action.signOut'] }))
expect(b.face.signOut).toHaveBeenCalledOnce()
b.set({ view: { ...CONNECTED, operation: { id: OP, kind: 'sign-out', phase: 'signing-out', cancellable: false } } })
expect(screen.getByText(zh['step.signing-out'])).toBeTruthy()
expect(screen.queryAllByRole('button')).toHaveLength(0)
})
it.each([['zh', zh], ['en', en]] as const)('reports a failed sign-in with its command and exit code in %s', (_locale, copy) => {
const b = fixture({ ...SIGNED_OUT, result: { id: OP, kind: 'sign-in', outcome: 'failed', failure: { command: 'auth-login', exitCode: 1 } } }, copy)
render(<TencentMeetingConnectionSection {...b.face} />)
const details = copy['failure.details'].replace('{details}', `auth-login · ${copy['failure.exitCode'].replace('{code}', '1')}`)
expect(screen.getByRole('alert').textContent).toBe(`${copy.failed} ${details}`)
expect(button(copy['action.connect'])).toBeTruthy()
b.set({ view: { ...SIGNED_OUT, result: { id: OP, kind: 'sign-in', outcome: 'cancelled' } } })
expect(screen.queryByRole('alert')).toBeNull()
})
it('retries an unconfirmed sign-in by checking again', () => {
const b = fixture({ account: { state: 'unverified' } })
render(<TencentMeetingConnectionSection {...b.face} />)
expect(screen.getByText(zh['detail.unavailable'])).toBeTruthy()
fireEvent.click(button(zh['action.retry']))
expect(b.face.check).toHaveBeenCalledOnce()
})
it('explains a stopped Host component and retries even while the stream is offline', () => {
const b = fixture(undefined)
render(<TencentMeetingConnectionSection {...b.face} />)
b.set({ linked: false, stopped: true })
expect(screen.getByText(zh['status.stopped'])).toBeTruthy()
expect(screen.getByText(zh['detail.stopped'])).toBeTruthy()
fireEvent.click(button(zh['action.retry']))
expect(b.face.retry).toHaveBeenCalledOnce()
})
it('tags only the enabled Tencent Meeting bundle', () => {
const b = fixture(CONNECTED)
const pkg = (name: string, enabled = true): PluginPackageRef => ({ name, installed: true, availability: 'profile', official: false, enabled, rows: [] })
const badge = (subject: PluginsSubject) =>
<TencentMeetingConnectionBadge {...{ ...b.face, subject } as ComponentProps<typeof TencentMeetingConnectionBadge>} />
const { rerender } = render(badge({ kind: 'bundle', pkg: pkg('@deepseek-ai/dsh-tencent-meeting') }))
expect(screen.getByText(zh['badge.connected'])).toBeTruthy()
b.set({ view: SIGNED_OUT })
expect(screen.getByText(zh['badge.disconnected'])).toBeTruthy()
rerender(badge({ kind: 'bundle', pkg: pkg('@acme/other') }))
expect(document.body.textContent).toBe('')
})
it('guides a newly enabled bundle to sign in, and steps aside once connected', () => {
const b = fixture()
const onDismiss = vi.fn(), onOpenDetails = vi.fn()
const props = { ...b.face, packageName: '@deepseek-ai/dsh-tencent-meeting', onDismiss, onOpenDetails } as ComponentProps<typeof TencentMeetingConnectionActivation>
render(<TencentMeetingConnectionActivation {...props} />)
expect(screen.queryByText(zh['activation.body'])).toBeNull()
b.set({ view: SIGNED_OUT })
fireEvent.click(button(zh['action.connect']))
expect(onOpenDetails).toHaveBeenCalledOnce()
expect(b.face.signIn).toHaveBeenCalledOnce()
b.set({ view: CONNECTED })
expect(onDismiss).toHaveBeenCalledOnce()
})
it('reports the latest notice', () => {
const b = fixture()
render(<TencentMeetingConnectionToast {...b.face} />)
expect(document.body.textContent).toBe('')
b.set({ notice: { seq: 1, kind: 'signed-out' } })
expect(screen.getByText(zh['notice.signed-out'])).toBeTruthy()
})
@@ -0,0 +1,134 @@
// @vitest-environment jsdom
/** The page derives the Tencent Meeting account from the Host's view and drives operations through its Remote. */
import { Context } from '@deepseek-ai/cordis'
import type { RemoteStreamOptions } from '@deepseek-ai/dsh-api-gateway/client'
import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types'
import type { TencentMeetingState } from '@deepseek-ai/dsh-tencent-meeting-cli/types'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import { expect, it, onTestFinished, vi } from 'vitest'
import { createConnection, presentConnection, type ConnectionPresentation } from '../src/client/connection.ts'
type Operation = NonNullable<TencentMeetingState['operation']>
const OP = 'op-1' as CliOperationId
const LINK = 'https://meeting.tencent.com/marketplace/tencentmeeting-cli-auth.html?code=fixture'
const SIGNED_OUT: TencentMeetingState = { account: { state: 'signed-out' } }
const CONNECTED: TencentMeetingState = { account: { state: 'connected', userName: '测试用户' } }
const FAILED_SIGN_IN: NonNullable<TencentMeetingState['result']> = { id: OP, kind: 'sign-in', outcome: 'failed', failure: { command: 'auth-login', exitCode: 1 } }
const FAILED_CHECK: NonNullable<TencentMeetingState['result']> = { id: OP, kind: 'check', outcome: 'failed', failure: { command: 'auth-status', exitCode: 1 } }
function operation(kind: Operation['kind'], phase: Operation['phase'], cancellable = false, authorizationUrl?: string): Operation {
return { id: OP, kind, phase, cancellable, ...authorizationUrl === undefined ? {} : { authorizationUrl } }
}
it.each<[string, TencentMeetingState | undefined, ConnectionPresentation]>([
['a stopped stream', SIGNED_OUT, { phase: 'stopped', failed: undefined }],
['no view yet', undefined, { phase: 'checking', failed: undefined }],
['an unchecked account', { account: { state: 'unchecked' } }, { phase: 'checking', failed: undefined }],
['a check', { ...SIGNED_OUT, operation: operation('check', 'checking') }, { phase: 'checking', failed: undefined }],
['a first check that failed', { account: { state: 'unchecked' }, result: FAILED_CHECK }, { phase: 'unavailable', failed: FAILED_CHECK }],
['no sign-in', SIGNED_OUT, { phase: 'disconnected', failed: undefined }],
['a failed sign-in', { ...SIGNED_OUT, result: FAILED_SIGN_IN }, { phase: 'disconnected', failed: FAILED_SIGN_IN }],
['a cancelled sign-in', { ...SIGNED_OUT, result: { id: OP, kind: 'sign-in', outcome: 'cancelled' } }, { phase: 'disconnected', failed: undefined }],
['an unconfirmed sign-in', { account: { state: 'unverified' } }, { phase: 'unavailable', failed: undefined }],
['a signed-in user', CONNECTED, { phase: 'connected', userName: '测试用户', failed: undefined }],
['an authorization', { ...SIGNED_OUT, operation: operation('sign-in', 'authorizing', true, LINK) },
{ phase: 'connecting', step: 'authorizing', url: LINK, cancellable: true }],
['a confirmation', { ...SIGNED_OUT, operation: operation('sign-in', 'checking') }, { phase: 'connecting', step: 'connecting', url: undefined, cancellable: false }],
['cancellation', { ...SIGNED_OUT, operation: operation('sign-in', 'cancelling') }, { phase: 'connecting', step: 'connecting', url: undefined, cancellable: false }],
['a sign-out', { ...CONNECTED, operation: operation('sign-out', 'signing-out') }, { phase: 'connecting', step: 'signing-out', url: undefined, cancellable: false }],
])('presents %s', (name, view, expected) => {
expect(presentConnection({ view, stopped: name === 'a stopped stream' })).toEqual(expected)
})
function fixture() {
const queue: TencentMeetingState[] = []
let wake: (() => void) | undefined, closed = false, accepted = 0
let options!: RemoteStreamOptions<TencentMeetingState>
const ok = <T>(value: T): RemoteResult<T> => ({ ok: true, value })
const remote = {
follow: vi.fn(),
check: vi.fn(async () => ok(OP)),
signIn: vi.fn(async () => ok(OP)),
signOut: vi.fn(async () => ok(OP)),
cancel: vi.fn(async (_id: CliOperationId) => ok(undefined)),
}
const ctx = new Context()
ctx.provide('remote', {
tencentMeeting: remote,
$stream: (value: typeof options) => {
options = value
return {
async *[Symbol.asyncIterator]() {
for (;;) {
if (closed) return
const next = queue.shift()
if (next === undefined) { await new Promise<void>((resolve) => { wake = resolve }); continue }
yield { value: next, accept: () => { accepted++ } }
}
},
dispose: async () => { closed = true; wake?.() },
}
},
})
const windowOpen = vi.spyOn(window, 'open').mockReturnValue(null)
const { connection, face } = createConnection(ctx)
onTestFinished(async () => { await connection.dispose(); windowOpen.mockRestore(); await ctx.fiber.dispose() })
return {
face, remote, open: windowOpen, options: () => options,
snapshot: () => connection.state.getSnapshot(),
async publish(view: TencentMeetingState) {
const target = accepted + 1
queue.push(view)
wake?.()
await vi.waitFor(() => { expect(accepted).toBe(target) })
},
}
}
const settle = async (b: ReturnType<typeof fixture>) => { await vi.waitFor(() => { expect(b.snapshot().busy).toBe(false) }) }
it('follows the tencentMeeting Remote and exposes the mirror to the page', async () => {
const b = fixture()
const signal = new AbortController().signal
b.options().open(signal)
expect(b.remote.follow).toHaveBeenCalledWith(signal)
await b.publish(SIGNED_OUT)
expect(b.face.hooks.tencentMeetingConnection.getSnapshot()).toMatchObject({ view: SIGNED_OUT, linked: true, busy: false })
})
it('signs in through the Remote, opens the authorization page once, and reports the connection', async () => {
const b = fixture()
await b.publish(SIGNED_OUT)
b.face.signIn()
await settle(b)
expect(b.remote.signIn).toHaveBeenCalledOnce()
await b.publish({ ...SIGNED_OUT, operation: operation('sign-in', 'authorizing', true, LINK) })
await b.publish({ ...SIGNED_OUT, operation: operation('sign-in', 'authorizing', true, LINK) })
expect(b.open.mock.calls.map(call => call[0])).toEqual([LINK])
b.face.cancel()
await settle(b)
expect(b.remote.cancel).toHaveBeenCalledWith(OP)
await b.publish({ ...CONNECTED, result: { id: OP, kind: 'sign-in', outcome: 'succeeded' } })
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'connected' })
})
it('signs out through the Remote and reports it', async () => {
const b = fixture()
await b.publish(CONNECTED)
b.face.signOut()
await settle(b)
expect(b.remote.signOut).toHaveBeenCalledOnce()
await b.publish({ ...SIGNED_OUT, result: { id: OP, kind: 'sign-out', outcome: 'succeeded' } })
expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'signed-out' })
})
it('checks again without a notice', async () => {
const b = fixture()
await b.publish({ account: { state: 'unverified' } })
b.face.check()
await settle(b)
expect(b.remote.check).toHaveBeenCalledOnce()
await b.publish({ ...CONNECTED, result: { id: OP, kind: 'check', outcome: 'succeeded' } })
expect(b.snapshot().notice).toBeUndefined()
})
@@ -0,0 +1,80 @@
/** The browser half mounts the Tencent Meeting Remote, registers its surfaces, and withdraws both on disposal or failure. */
import { Context, Service } from '@deepseek-ai/cordis'
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'
import { expect, it, vi } from 'vitest'
import { apply as hostApply } from '../src/index.ts'
import { TencentMeetingConnectionActivation, TencentMeetingConnectionBadge, TencentMeetingConnectionSection, TencentMeetingConnectionToast } from '../src/client/TencentMeetingConnection.tsx'
const REMOTE: TypertRemoteContribution = { package: '@deepseek-ai/dsh-tencent-meeting-cli', descriptors: [] }
const SLOTS = [
['plugins.bundle.config', TencentMeetingConnectionSection],
['plugins.bundle.activation', TencentMeetingConnectionActivation],
['plugins.detail.badge', TencentMeetingConnectionBadge],
['shell.overlay', TencentMeetingConnectionToast],
] as const
async function fixture() {
const ctx = new Context()
const unmount = vi.fn(async () => {})
const dispose = vi.fn(async () => {})
class Remote extends Service {
constructor() { super(ctx, 'remote') }
async $mount(contribution: TypertRemoteContribution) {
expect(contribution).toBe(REMOTE)
ctx.provide('remote.tencentMeeting', { follow: vi.fn() })
return unmount
}
$stream() {
return { async *[Symbol.asyncIterator]() { /* the Host reports nothing in this composition */ }, dispose }
}
}
new Remote()
ctx.provide('locale', new LocaleRuntime(ctx))
await ctx.plugin(SlotRegistry)
ctx.slots.register({ name: 'root', children: {
'plugins.bundle.activation': { kind: 'keyed', scope: 'root' },
'plugins.bundle.config': { kind: 'keyed', scope: 'root' },
'plugins.detail.badge': { kind: 'list', scope: 'root' },
'shell.overlay': { kind: 'list', scope: 'root' },
} } as never, () => null)
vi.doMock('@deepseek-ai/dsh-tencent-meeting-cli/remote', () => ({ default: REMOTE }))
const browser = await import('../src/client/index.ts')
return { ctx, unmount, dispose, browser }
}
it('registers the connection surfaces with one shared face, then withdraws them and the Remote', async () => {
hostApply()
const b = await fixture()
try {
const fiber = b.ctx.plugin({ inject: [...b.browser.inject], apply: b.browser.apply })
await fiber
const faces = SLOTS.map(([slot, component]) => {
const [entry] = b.ctx.slots.entries(slot)
expect(entry).toMatchObject({ locale: 'tencent-meeting', component })
return entry!.inject!()
})
expect(new Set(faces.map(face => face.hooks)).size).toBe(1)
expect(b.ctx.slots.entries('plugins.bundle.config')[0]!.options.key).toBe('@deepseek-ai/dsh-tencent-meeting')
await fiber.dispose()
for (const [slot] of SLOTS) expect(b.ctx.slots.entries(slot)).toHaveLength(0)
expect(b.dispose).toHaveBeenCalledOnce()
expect(b.unmount).toHaveBeenCalledOnce()
} finally {
await b.ctx.fiber.dispose()
vi.doUnmock('@deepseek-ai/dsh-tencent-meeting-cli/remote')
}
})
it('withdraws the Remote when the surfaces fail to register', async () => {
const b = await fixture()
vi.spyOn(b.ctx.slots, 'inject').mockImplementationOnce(() => { throw new Error('slot failed') })
try {
await expect(b.browser.apply(b.ctx)).rejects.toThrow('slot failed')
expect(b.unmount).toHaveBeenCalledOnce()
} finally {
await b.ctx.fiber.dispose()
vi.doUnmock('@deepseek-ai/dsh-tencent-meeting-cli/remote')
}
})