Files
knowledge-governance/web/src/DingtalkSpaceRegistrar.test.tsx
T
姚章浩 e60b10256a fix(settings): add DingTalk spaces and render the real login QR
Address two gaps in the first DingTalk-session UI:
- add an explicit admin-only '+ 新增钉钉知识库' action on the data-source
  panel; it accepts an alidocs space URL, resolves the live name/root through
  the authenticated sidecar, writes the inventory root atomically, upserts a
  deterministic source connection, and enqueues its first catalog refresh
- read DingTalk's real QR canvas pixels rather than taking a DOM screenshot;
  select by dark-pixel content, composite onto a white quiet zone, and render
  at 320x320 so the dialog contains a large complete code, not a page thumbnail

The live refresh path resolves registered roots from the connection locator,
while existing name-based DingTalk sources remain compatible.
2026-09-30 10:54:07 +08:00

14 lines
573 B
TypeScript

import { renderToStaticMarkup } from 'react-dom/server'
import { describe,expect,it,vi } from 'vitest'
import { DingtalkSpaceRegistrar } from './DingtalkSpaceRegistrar'
describe('DingtalkSpaceRegistrar',()=>{
it('shows an explicit add-source action without making a request',()=>{
const fetchMock=vi.fn(); vi.stubGlobal('fetch',fetchMock)
const markup=renderToStaticMarkup(<DingtalkSpaceRegistrar onRegistered={()=>undefined}/>)
expect(markup).toContain('新增钉钉知识库')
expect(fetchMock).not.toHaveBeenCalled()
vi.unstubAllGlobals()
})
})