reminder-detection.test.ts2.1 KBView on GitHub
import {
  REMINDER_SENDER_EMAILS,
  isReminderMessage,
} from '@/modules/threads/thread/lib/reminder-detection';
import type { ParsedMessage } from '@/modules/threads/threadList/store/threadSlice';

function buildMessage(senderEmail: string): ParsedMessage {
  return {
    id: 'msg_1',
    sender: { email: senderEmail, name: 'X' },
    receivedOn: new Date('2026-05-21T12:00:00Z').toISOString(),
    isDraft: false,
  } as unknown as ParsedMessage;
}

describe('isReminderMessage', () => {
  it('matches every sender in the Reminders split filter', () => {
    // Kept in sync with apps/mail/modules/threads/components/SplitInboxTabs.tsx
    // and apps/mail/modules/threads/hooks/use-inboxes.ts — adding/removing one
    // here without updating the other paths re-introduces the parity bug.
    expect(REMINDER_SENDER_EMAILS).toEqual(
      new Set([
        '<email>',
        '<email>',
        '<email>',
      ]),
    );
  });

  it('detects the canonical Cedar reminder sender', () => {
    expect(isReminderMessage(buildMessage('<email>'))).toBe(true);
  });

  it('detects the legacy Cedar reminder sender', () => {
    expect(isReminderMessage(buildMessage('<email>'))).toBe(true);
  });

  it('detects Superhuman-sourced reminder messages', () => {
    // Regression test for the sender-list parity bug: Superhuman reminders used
    // to render as plain email cards because isReminderMessage only matched
    // <email>.
    expect(isReminderMessage(buildMessage('<email>'))).toBe(true);
  });

  it('returns false for any other sender', () => {
    expect(isReminderMessage(buildMessage('<email>'))).toBe(false);
    expect(isReminderMessage(buildMessage(''))).toBe(false);
  });

  it('is case-sensitive on the local-part to match Gmail address normalization', () => {
    // Email comparison uses exact equality (Set.has). If we later need
    // case-insensitive matching, normalize at the call site or here.
    expect(isReminderMessage(buildMessage('<email>'))).toBe(false);
  });
});