Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.2 KB
Raw Blame
import type { DifyWorld } from '../features/support/world.ts'
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
import { requireAgentBackendRuntime } from '../features/agent-v2/support/fixtures/agent-backend.ts'

describe('requireAgentBackendRuntime', () => {
  afterEach(() => {
    vi.unstubAllEnvs()
    vi.unstubAllGlobals()
  })

  it('keeps runtime scenarios runnable when the Go shellctl health endpoint is available', async () => {
    vi.stubEnv('E2E_AGENT_BACKEND_URL', 'http://agent-backend.test/')
    vi.stubEnv('E2E_SHELLCTL_URL', 'http://shellctl.test/')
    const fetchMock = vi.fn<typeof fetch>(async (input) => {
      const url = input.toString()
      if (
        url === 'http://agent-backend.test/openapi.json' ||
        url === 'http://shellctl.test/healthz'
      ) {
        return new Response()
      }

      return new Response(null, { status: 404, statusText: 'Not Found' })
    })
    vi.stubGlobal('fetch', fetchMock)
    const attach = vi.fn()
    const world = { attach } as unknown as DifyWorld

    await expect(requireAgentBackendRuntime(world)).resolves.toBe('http://agent-backend.test')
    expect(fetchMock).toHaveBeenCalledTimes(2)
    expect(attach).not.toHaveBeenCalled()
  })
})