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.7 KB
Raw Blame
import type { Page } from '@playwright/test'
import type { DifyWorld } from '../../support/world.ts'
import { Then, When } from '@cucumber/cucumber'
import { waitForAgentsConsole } from '../../../support/agents.ts'
import { waitForAppsConsole } from '../../../support/apps.ts'
import { waitForConsoleHome } from '../../../support/home.ts'
import { waitForModelProviderIntegrations } from '../../../support/integrations.ts'
import { waitForKnowledgeConsole } from '../../../support/knowledge.ts'

type AccessibilityPageConfig = {
  path: string
  waitUntilReady: (page: Page) => Promise<void>
}

const accessibilityPages = {
  Agents: { path: '/agents', waitUntilReady: waitForAgentsConsole },
  Home: { path: '/', waitUntilReady: waitForConsoleHome },
  Integrations: {
    path: '/integrations/model-provider',
    waitUntilReady: waitForModelProviderIntegrations,
  },
  Knowledge: { path: '/datasets', waitUntilReady: waitForKnowledgeConsole },
  Studio: { path: '/apps', waitUntilReady: waitForAppsConsole },
} satisfies Record<string, AccessibilityPageConfig>

const getAccessibilityPage = (pageName: string): AccessibilityPageConfig => {
  const config = accessibilityPages[pageName as keyof typeof accessibilityPages]
  if (!config)
    throw new Error(
      `Unknown accessibility page "${pageName}". Expected one of: ${Object.keys(accessibilityPages).join(', ')}.`,
    )

  return config
}

When('I open the {string} main page', async function (this: DifyWorld, pageName: string) {
  await this.getPage().goto(getAccessibilityPage(pageName).path)
})

Then('I should be on the {string} main page', async function (this: DifyWorld, pageName: string) {
  await getAccessibilityPage(pageName).waitUntilReady(this.getPage())
})