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.2 KB
Raw Blame
import { ChannelDetailSoupDocument } from '@service-storage/graphql/generated/graphql';
import { type FieldNode, Kind, print, visit } from 'graphql';
import { describe, expect, it } from 'vitest';

describe('channel detail document', () => {
  it('selects only unread notifications, never the read history', () => {
    const edges: FieldNode[] = [];
    visit(ChannelDetailSoupDocument, {
      Field(node) {
        if (node.name.value === 'notifications') edges.push(node);
      },
    });
    expect(edges).toHaveLength(2);
    for (const edge of edges) {
      const filter = edge.arguments?.find(
        (argument) => argument.name.value === 'filter'
      );
      expect(filter?.value.kind).toBe(Kind.OBJECT);
      expect(filter && print(filter.value)).toContain('states: [UNSEEN]');
    }
    const complete = edges.filter((edge) => !edge.alias);
    expect(complete).toHaveLength(1);
    expect(
      complete[0].arguments?.some((argument) => argument.name.value === 'limit')
    ).toBe(false);
    const filter = complete[0].arguments?.find(
      (argument) => argument.name.value === 'filter'
    );
    expect(filter?.value.kind).toBe(Kind.OBJECT);
    expect(filter && print(filter.value)).toBe('{states: [UNSEEN]}');
  });
});