Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.3 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import { resolveMessengerInstallHref } from './installHref';

describe('resolveMessengerInstallHref', () => {
  it('keeps official cloud installs on the app login origin', () => {
    expect(resolveMessengerInstallHref('discord', 'https://lobehub.com')).toBe(
      'https://app.lobehub.com/api/agent/messenger/discord/install',
    );
    expect(resolveMessengerInstallHref('slack', 'https://lobehub.com/')).toBe(
      'https://app.lobehub.com/api/agent/messenger/slack/install',
    );
  });

  it('preserves the configured self-hosted install origin and path prefix', () => {
    expect(resolveMessengerInstallHref('slack', 'https://chat.example.com/lobe/')).toBe(
      'https://chat.example.com/lobe/api/agent/messenger/slack/install',
    );
  });

  it('builds against the desktop remote server URL and tolerates trailing slashes', () => {
    expect(resolveMessengerInstallHref('slack', 'https://app.lobehub.com/')).toBe(
      'https://app.lobehub.com/api/agent/messenger/slack/install',
    );
  });

  it('returns undefined while the origin is not resolved yet', () => {
    expect(resolveMessengerInstallHref('discord', undefined)).toBeUndefined();
    expect(resolveMessengerInstallHref('discord', '')).toBeUndefined();
  });
});