# Syncable Entity Testing

Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for...

- Repository: https://github.com/twentyhq/twenty (60258 stars)
- Category: Testing
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add twentyhq/twenty --skill syncable-entity-testing -g -a claude-code -y`
Codex: `npx skills add twentyhq/twenty --skill syncable-entity-testing -g -a codex -y`
Cursor: `npx skills add twentyhq/twenty --skill syncable-entity-testing -g -a cursor -y`
Gemini CLI: `npx skills add twentyhq/twenty --skill syncable-entity-testing -g -a gemini-cli -y`

## Description

Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for building apps on top of Twenty. Create comprehensive integration tests for syncable entities in Twenty. Use when writing integration tests for metadata entities, covering validator exceptions, input transpilation errors, and CRUD operations. Tests are MANDATORY for all syncable entities.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Syncable Entity: Integration Testing (Step 6/6 - MANDATORY)

**Purpose**: Create comprehensive test suite covering all validation scenarios, input transpilation exceptions, and successful use cases.

**When to use**: After completing Steps 1-5. Integration tests are **REQUIRED** for all syncable entities.

---

## Quick Start

Tests must cover:
1. **Failing scenarios** - All validator exceptions and input transpilation errors
2. **Successful scenarios** - All CRUD operations and edge cases
3. **Test utilities** - Reusable query factories and helper functions

**Test pattern**: Two-file pattern (query factory + wrapper) for each operation.

---

## Step 1: Create Test Utilities

### Pattern: Query Factory

**File**: `test/integration/metadata/suites/my-entity/utils/create-my-entity-query-factory.util.ts`

```typescript
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { type CreateMyEntityInput } from 'src/engine/metadata-modules/my-entity/dtos/create-my-entity.input';

export type CreateMyEntityFactoryInput = CreateMyEntityInput;

const DEFAULT_MY_ENTITY_GQL_FIELDS = `
  id
  name
  label
  description
  isCustom
  createdAt
  updatedAt
`;

export const createMyEntityQueryFactory = ({
  input,
  gqlFields = DEFAULT_MY_ENTITY_GQL_FIELDS,
}: PerformMetadataQueryParams<CreateMyEntityFactoryInput>) => ({
  query: gql`
    mutation CreateMyEntity($input: CreateMyEntityInput!) {
      createMyEntity(input: $input) {
        ${gqlFields}
      }
    }
  `,
  variables: {
    input,
  },
});
```

### Pattern: Wrapper Utility

**File**: `test/integration/metadata/suites/my-entity/utils/create-my-entity.util.ts`

The rest: https://github.com/twentyhq/twenty/blob/HEAD/.claude/skills/syncable-entity-testing/SKILL.md
