Adapt to two contract changes master introduced: - The generated Remote face now wraps every business result in RemoteResult, folding carrier failures into an ok:false branch instead of rejecting. The controller reads that envelope at its three call sites and maps a carrier failure onto the same settled shape the controls already render; three specs cover the new branch. - Client packages split their tsconfig into host and client halves, and the host aggregate now compiles any test not named *.client.spec.*. Rename this package's specs to the client convention and drop the ../connection project reference, which pointed at a solution file that no longer carries the client sources. Keep master's mount loop with its rollback-on-failure in api-remotes and add messageFeedbackRemote to it.
39 lines
2.0 KiB
TypeScript
39 lines
2.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it } from 'vitest'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { apply as nodeApply } from '@deepseek-ai/dsh-client-locale'
|
|
import { apply as clientApply, COMMON_NS, LocaleService, inject } from '@deepseek-ai/dsh-client-locale/client'
|
|
import * as LocaleInvariant from '@deepseek-ai/dsh-client-locale/invariant'
|
|
import { SlotsService } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import InvariantService from '@deepseek-ai/dsh-invariants'
|
|
import { stubSettingsScope } from '@deepseek-ai/dsh-client-test-runtime'
|
|
|
|
describe('invariant companion', () => {
|
|
it('registers under the package name with an empty installer', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
await expect(ctx.plugin(LocaleInvariant).await()).resolves.toBeDefined()
|
|
})
|
|
|
|
it('node-half apply tolerates a Host without settings', () => {
|
|
nodeApply(new Context())
|
|
})
|
|
|
|
it('client apply provides ctx.locale seeded with the zh/en common namespace', async () => {
|
|
// The feature registers its own Language settings row, hence the slots edge.
|
|
expect(inject).toEqual(['slots', 'connection', 'remote', 'settingsScope'])
|
|
const ctx = new Context()
|
|
new SlotsService(ctx)
|
|
ctx.provide('connection', { api: { settings: {} }, isLoopback: false } as never)
|
|
// The settings row's transport and the forwarded-event port.
|
|
ctx.provide('remote', { $on: () => () => {} } as never)
|
|
ctx.provide('settingsScope', { bind: () => stubSettingsScope().scope } as never)
|
|
await ctx.plugin({ inject, apply: clientApply }).await()
|
|
const locale = ctx.get('locale')
|
|
expect(locale).toBeInstanceOf(LocaleService)
|
|
// Seeded dictionaries occupy the (ns, locale) seats even while empty.
|
|
expect(() => (locale as LocaleService).register(COMMON_NS, 'zh', {})).toThrow('already has locale')
|
|
expect(() => (locale as LocaleService).register(COMMON_NS, 'en', {})).toThrow('already has locale')
|
|
})
|
|
})
|