test(web): cover onboarding branches

This commit is contained in:
creatixchu
2026-08-13 18:02:25 +08:00
parent fc90114ad9
commit 0f1c29c751
3 changed files with 26 additions and 3 deletions

View File

@@ -41,7 +41,7 @@ export function OnboardingModal({
title={title}
onClose={ignoreImplicitDismiss}
headless
className={css['dialog'] ?? ''}
className={css.dialog as string}
>
<div className={css.content}>
<h2 ref={titleRef} className={css.title} tabIndex={focusTitle ? -1 : undefined}>{title}</h2>

View File

@@ -14,7 +14,7 @@ import { WelcomeNotice } from '../src/client/WelcomeNotice.tsx'
// the shipped Chinese copy, so they state the browser they assume.
usePinnedBrowserLanguages('zh-CN')
async function bench() {
async function bench(isLoopback = true) {
const ctx = new Context()
await ctx.plugin(SlotRegistry).await()
const locale = new LocaleRuntime(ctx)
@@ -24,7 +24,7 @@ async function bench() {
new TestRemote(ctx)
// The apply path only captures the wire face; no call leaves this fake
// until a section actually loads.
ctx.provide('connection', { api: {}, isLoopback: true } as never)
ctx.provide('connection', { api: {}, isLoopback } as never)
return { ctx, slots: ctx.get('slots') as SlotRegistry, locale }
}
@@ -142,6 +142,22 @@ describe('ui-settings-models apply', () => {
expect(() => b.locale.register('settings.models', 'zh', {})).not.toThrow()
expect(() => b.locale.register('settings.models', 'en', {})).not.toThrow()
})
it('keeps remote-browser acknowledgement in process memory', async () => {
const b = await bench(false)
declare(b.slots)
await b.ctx.plugin({ inject: [...inject], apply }).await()
const entry = b.slots.entries('settings.onboarding')
.find(candidate => candidate.options.id === 'welcome-notice')!
const injected = (
entry.inject as unknown as () => import('../src/client/WelcomeNotice.tsx').WelcomeNoticeInjected
)()
await injected.controller.load()
expect(injected.controller.store.getSnapshot()).toEqual({
status: 'ready', acknowledged: false, error: null,
})
})
})
describe('pushed invalidations', () => {

View File

@@ -146,6 +146,13 @@ function harness(options: {
}
describe('DeepSeekOnboardingDialog', () => {
it('renders when the shell root is absent', async () => {
const h = harness()
document.getElementById('root')!.remove()
render(<DeepSeekOnboardingDialog {...h.props} />)
expect(await screen.findByRole('dialog', { name: en.onboardingTitle })).toBeTruthy()
})
it('loads a credential-only modal, inerts the product, and focuses the key', async () => {
const h = harness()
render(<DeepSeekOnboardingDialog {...h.props} />)