dify/web/service/console-router-loader.spec.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

36 lines
1.5 KiB
TypeScript

import { agent } from '@dify/contracts/api/console/agent/orpc.gen'
import { apps } from '@dify/contracts/api/console/apps/orpc.gen'
import { explore } from '@dify/contracts/api/console/explore/orpc.gen'
import { installedApps } from '@dify/contracts/api/console/installed-apps/orpc.gen'
import { notification } from '@dify/contracts/api/console/notification/orpc.gen'
import { tags } from '@dify/contracts/api/console/tags/orpc.gen'
import { workspaces } from '@dify/contracts/api/console/workspaces/orpc.gen'
import { contract as enterpriseContract } from '@dify/contracts/enterprise/orpc.gen'
import { describe, expect, it } from 'vitest'
import { loadConsoleContractForSegment } from './console-router-loader'
describe('loadConsoleContractForSegment', () => {
it.each([
['agent', 'agent', agent],
['apps', 'apps', apps],
['explore', 'explore', explore],
['installedApps', 'installedApps', installedApps],
['notification', 'notification', notification],
['tags', 'tags', tags],
['workspaces', 'workspaces', workspaces],
] as const)(
'loads the generated %s contract when generated types are usable',
async (segment, contractKey, generatedContract) => {
const contract = await loadConsoleContractForSegment(segment)
expect(contract).toHaveProperty(contractKey, generatedContract)
},
)
it('loads the generated enterprise contract independently', async () => {
const contract = await loadConsoleContractForSegment('enterprise')
expect(contract).toHaveProperty('enterprise', enterpriseContract)
})
})