Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

2.1 KB
Raw Blame
import { getMonitoringAgent, getMonitoringAgentPrompt } from '~/data/monitoring-agents.utils'
import { fromMarkdown } from 'mdast-util-from-markdown'
import { describe, expect, it } from 'vitest'

import { AgentSetup } from './AgentSetup'

describe('AgentSetup markdown schema', () => {
  it.each(['health', 'security', 'performance', 'usage'])(
    'preserves the complete %s prompt in one code block',
    (id) => {
      const markdown = AgentSetup({ props: { id } })
      const codeBlocks = fromMarkdown(markdown).children.filter((node) => node.type === 'code')
      expect(codeBlocks).toHaveLength(1)
      expect(codeBlocks[0]).toMatchObject({
        lang: 'text',
        value: getMonitoringAgentPrompt(getMonitoringAgent(id)),
      })
    }
  )

  it('serializes the prompt and harness setup for a registered agent', () => {
    const markdown = AgentSetup({ props: { id: 'health' } })

    expect(markdown).toContain('**Step 1: Copy the prompt**')
    expect(markdown).toContain('**Step 2: Schedule it in your agent**')
    expect(markdown).toContain('You are "Health monitor"')
    expect(markdown).toContain('```text')
    expect(markdown).toContain('**Claude**')
    expect(markdown).toContain('**Codex**')
    expect(markdown).toContain('**Cursor**')
    expect(markdown).toContain('claude.ai/code/routines')
    expect(markdown).toContain('`0 * * * *`')
    expect(markdown).toContain('Paste the prompt.')
    expect(markdown).not.toContain('](#')
    expect(markdown).toContain('[Claude docs](https://code.claude.com/docs/en/routines)')
    expect(markdown).toContain('[Codex docs](https://developers.openai.com/codex/app/automations)')
    expect(markdown).toContain('[Cursor docs](https://cursor.com/docs/cloud-agent/automations)')
  })

  it('points hourly agents at Claude cloud routines', () => {
    const markdown = AgentSetup({ props: { id: 'performance' } })

    expect(markdown).toContain('claude.ai/code/routines')
    expect(markdown).not.toContain('Desktop scheduled task')
  })

  it('fails clearly for an unknown agent', () => {
    expect(() => AgentSetup({ props: { id: 'missing' } })).toThrow(
      'Unknown monitoring agent id: missing'
    )
  })
})