Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.5 KB
Raw Blame
import { describe, expect, it, vi } from 'vitest';
import {
  getActiveMeetingPath,
  getMeetingPath,
  getMeetingShareToken,
  getMeetingUrl,
} from '../call-link';

vi.mock('@core/util/webOrigin', () => ({
  getWebOrigin: () => 'https://macro.com',
}));

const token = '01955c94-2576-7f3a-9d60-173d74b7f812';

describe('meeting paths', () => {
  it('shares a setup URL and uses a separate path for the active call', () => {
    expect(getMeetingPath(token)).toBe(`/meet/join/${token}`);
    expect(getMeetingUrl(token)).toBe(
      `https://macro.com/app/meet/join/${token}`
    );
    expect(getActiveMeetingPath(token)).toBe(`/meet/${token}`);
  });

  it.each([
    `/meet/join/${token}`,
    `https://macro.com/app/meet/join/${token}/?source=calendar#setup`,
    `/meet/${token}`,
    `https://macro.com/app/meet/${token}/?join=true`,
  ])('reads the invitation token from current and legacy URLs: %s', (url) => {
    expect(getMeetingShareToken(url)).toBe(token);
  });

  it.each([
    '/meet/new',
    '/app/meet/join',
    '/meet/join/new',
    '/meet/join/join',
    '/meet/%invalid',
  ])('does not interpret reserved routes as invitation tokens: %s', (url) =>
    expect(getMeetingShareToken(url)).toBeUndefined()
  );

  it('encodes and decodes a token as one path segment', () => {
    expect(getMeetingShareToken(getMeetingPath('token with space'))).toBe(
      'token with space'
    );
    expect(getActiveMeetingPath('token with space')).toBe(
      '/meet/token%20with%20space'
    );
  });
});