remoteNodeFiles.test.ts 1.1 KB

1234567891011121314151617181920212223
  1. import { describe, expect, it } from 'vitest'
  2. import { rewriteRemoteNodeFiles } from '@/components/workspace/viewModels'
  3. describe('remote node file links', () => {
  4. it('routes remote images and files through the source node', () => {
  5. const node = '11111111-1111-4111-8111-111111111111'
  6. const content = [
  7. '![图](</Users/remote/Agents/result one.png>)',
  8. '[报告](/Users/remote/Agents/report.pdf)',
  9. '[日志](file:///Users/remote/Agents/run.log)',
  10. ].join('\n')
  11. const rewritten = rewriteRemoteNodeFiles(content, node)
  12. expect(rewritten).toContain(`/api/plugins/yaoyao/v1/nodes/${node}/files?path=%2FUsers%2Fremote%2FAgents%2Fresult%20one.png`)
  13. expect(rewritten).toContain('path=%2FUsers%2Fremote%2FAgents%2Freport.pdf')
  14. expect(rewritten).toContain('path=%2FUsers%2Fremote%2FAgents%2Frun.log')
  15. expect(rewritten).not.toContain('](</Users/remote')
  16. })
  17. it('does not rewrite web URLs or local-agent content', () => {
  18. expect(rewriteRemoteNodeFiles('[官网](https://example.com/a.png)', 'local'))
  19. .toBe('[官网](https://example.com/a.png)')
  20. })
  21. })