dify/web/service/console-router-loader.spec.ts
Stephen Zhou 3ad06bebd9
refactor(web): migrate console contracts to generated types (#38231)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-01 01:40:12 +00:00

22 lines
1017 B
TypeScript

import { agent } from '@dify/contracts/api/console/agent/orpc.gen'
import { apps } from '@dify/contracts/api/console/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 { describe, expect, it } from 'vitest'
import { loadConsoleContractForSegment } from './console-router-loader'
describe('loadConsoleContractForSegment', () => {
it.each([
['agent', 'agent', agent],
['apps', 'apps', apps],
['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 as Record<string, unknown>)[contractKey]).toBe(generatedContract)
})
})