Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

3.2 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import {
  getCompletedFeatureTipIds,
  getOrderedUnseenFeatureTips,
  normalizeFeatureTipIds,
  type FeatureTipId
} from './feature-tips'

describe('feature tips', () => {
  it('orders new unseen tips before older unseen tips', () => {
    const tips = getOrderedUnseenFeatureTips({ seenTipIds: new Set<FeatureTipId>() })

    expect(tips.map((tip) => tip.id)).toEqual([
      'native-chat-upgrade',
      'agent-session-search',
      'orca-cli',
      'cmd-j-palette',
      'voice-dictation'
    ])
  })

  it('treats the native chat upgrade tip as done for every profile outside its audience', () => {
    const base = {
      cliInstalled: true,
      voiceDictationEnabled: true,
      sessionSearchTipCompleted: true
    }
    expect(
      getCompletedFeatureTipIds({ ...base, inNativeChatUpgradeTipAudience: false }).has(
        'native-chat-upgrade'
      )
    ).toBe(true)
    expect(
      getCompletedFeatureTipIds({ ...base, inNativeChatUpgradeTipAudience: true }).has(
        'native-chat-upgrade'
      )
    ).toBe(false)
  })

  it('skips tips the user has already seen', () => {
    const tips = getOrderedUnseenFeatureTips({
      seenTipIds: new Set<FeatureTipId>([
        'native-chat-upgrade',
        'voice-dictation',
        'orca-cli',
        'cmd-j-palette',
        'agent-session-search'
      ])
    })

    expect(tips.map((tip) => tip.id)).toEqual([])
  })

  it('skips tips for features the user has already completed', () => {
    const tips = getOrderedUnseenFeatureTips({
      // cmd-j is a seen-based tip with no feature completion, so mark it seen here.
      seenTipIds: new Set<FeatureTipId>(['cmd-j-palette']),
      completedTipIds: getCompletedFeatureTipIds({
        cliInstalled: true,
        voiceDictationEnabled: true,
        sessionSearchTipCompleted: true,
        inNativeChatUpgradeTipAudience: false
      })
    })

    expect(tips.map((tip) => tip.id)).toEqual([])
  })

  it('skips the CLI tip when the CLI is already installed', () => {
    const tips = getOrderedUnseenFeatureTips({
      seenTipIds: new Set<FeatureTipId>(['voice-dictation', 'cmd-j-palette']),
      completedTipIds: getCompletedFeatureTipIds({
        cliInstalled: true,
        voiceDictationEnabled: false,
        sessionSearchTipCompleted: true,
        inNativeChatUpgradeTipAudience: false
      })
    })

    expect(tips.map((tip) => tip.id)).toEqual([])
  })

  it('skips tips for features the user has already interacted with', () => {
    const tips = getOrderedUnseenFeatureTips({
      seenTipIds: new Set<FeatureTipId>(),
      completedTipIds: getCompletedFeatureTipIds({
        cliInstalled: false,
        voiceDictationEnabled: false,
        sessionSearchTipCompleted: true,
        inNativeChatUpgradeTipAudience: false,
        featureInteractions: {
          'voice-dictation': { firstInteractedAt: 100, interactionCount: 1 }
        }
      })
    })

    expect(tips.map((tip) => tip.id)).toEqual(['orca-cli', 'cmd-j-palette'])
  })

  it('normalizes persisted tip ids', () => {
    expect(
      normalizeFeatureTipIds([
        'feature-tour',
        'orca-cli',
        'bogus',
        'cmd-j-palette',
        'voice-dictation'
      ])
    ).toEqual(['orca-cli', 'cmd-j-palette', 'voice-dictation'])
  })
})