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.

2.7 KB
Raw Blame
import { mailProjectionCapsules } from '../../../src/lib/graphql-cache/worker/browser-test/mail-projection-capsules';
import type { MailAccountFieldsFragment } from '../../../src/lib/service-clients/service-storage/graphql/generated/graphql';

export const USER_ID = 'macro|[email protected]';
export const EMAIL = '[email protected]';
export const fixtureId = (n: number) =>
  `00000000-0000-0000-0000-${String(n).padStart(12, '0')}`;
const timestamp = '2025-01-04T00:00:00Z';

export function fixtureMailAccount(
  id: string,
  emailAddress: string,
  isPrimary: boolean
): MailAccountFieldsFragment {
  return {
    id,
    macroId: USER_ID,
    provider: 'GMAIL',
    emailAddress,
    photoUrl: null,
    isPrimary,
    needsReauth: false,
    draftIsSignal: false,
    settings: { signature: null, signatureOnRepliesForwards: false },
  };
}

export const accounts = [fixtureMailAccount(fixtureId(1000), EMAIL, true)];

/** Subset of the canonical Rust-encoded Mail fixtures. These are API records,
 * not cache writes or precomputed filter results. Keep the capsule facts intact. */
export const mail = [4, 6, 8, 9, 10, 12].map((n) => {
  const preview = (offset: number, subject: string, isDraft: boolean) => ({
    id: fixtureId(n + offset),
    subject,
    snippet: subject,
    isDraft,
    senderEmail: '[email protected]',
    senderName: 'Fixture sender',
    senderPhotoUrl: null,
  });
  return {
    __typename: 'GraphqlSoupEmailThread',
    id: fixtureId(n),
    entityType: 'EMAIL_THREAD',
    name: `Email ${n}`,
    displayName: `Email ${n}`,
    ownerId: USER_ID,
    linkId: accounts[0].id,
    cacheProjection: mailProjectionCapsules[n - 1],
    mailAllPreview: preview(10000, `Email ${n}`, false),
    mailDraftPreview: n % 3 === 0 ? preview(20000, `Draft ${n}`, true) : null,
    mailSentPreview: n % 4 === 0 ? preview(30000, `Sent ${n}`, false) : null,
    inboxVisible: n % 2 === 0,
    isRead: n % 4 === 0,
    isSignal: n % 3 === 0,
    isImportant: n % 3 === 0,
    isDraft: false,
    hasReceivedMail: true,
    snippet: `Fixture message ${n}`,
    senderEmail: '[email protected]',
    senderName: 'Fixture sender',
    senderPhotoUrl: null,
    latestInboundMessageTs: '2025-01-02T00:00:00Z',
    sortTs: timestamp,
    createdAt: timestamp,
    updatedAt: timestamp,
    viewedAt: null,
    notifications: [],
    participants: [],
    senders: [],
    attachments: [],
    labels: [],
    properties: [],
    messages: [],
    isFavorited: false,
  };
});

export const identity = {
  userId: USER_ID,
  email: EMAIL,
  name: 'Offline Fixture',
  permissions: [],
  licenseStatus: 'Active',
  tutorialComplete: true,
  hasChromeExt: false,
  hasTrialed: true,
  aiDataConsent: true,
  referralCode: 'offline-fixture',
};