snapshot of https://github.com/twentyhq/twenty.git (main, 2026-09-17; blobs > 131072B omitted)
Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-17 23:28:13 +05:00
commit e7da97194a
32688 changed files with 4208681 additions and 0 deletions

View File

@@ -0,0 +1,151 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`Skill creation should fail when content is empty string 1`] = `
{
"extensions": {
"code": "METADATA_VALIDATION_FAILED",
"errors": {
"skill": [
{
"errors": [
{
"code": "INVALID_SKILL_INPUT",
"message": "Content cannot be empty",
"userFriendlyMessage": "Content cannot be empty",
},
],
"flatEntityMinimalInformation": {
"name": "emptyContentSkill",
"universalIdentifier": Any<String>,
},
"metadataName": "skill",
"status": "fail",
"type": "create",
},
],
},
"message": "Validation failed for 1 skill",
"summary": {
"skill": 1,
"totalErrors": 1,
},
"userFriendlyMessage": "Content cannot be empty",
},
"message": "Multiple validation errors occurred while creating skill",
"name": "GraphQLError",
}
`;
exports[`Skill creation should fail when content is missing 1`] = `
{
"extensions": {
"code": "BAD_USER_INPUT",
"http": {
"status": 400,
},
"userFriendlyMessage": "An error occurred.",
},
"message": "Field "content" of required type "String!" was not provided.",
"name": "GraphQLError",
}
`;
exports[`Skill creation should fail when label is empty string 1`] = `
{
"extensions": {
"code": "METADATA_VALIDATION_FAILED",
"errors": {
"skill": [
{
"errors": [
{
"code": "INVALID_SKILL_INPUT",
"message": "Label cannot be empty",
"userFriendlyMessage": "Label cannot be empty",
},
],
"flatEntityMinimalInformation": {
"name": "emptyLabelSkill",
"universalIdentifier": Any<String>,
},
"metadataName": "skill",
"status": "fail",
"type": "create",
},
],
},
"message": "Validation failed for 1 skill",
"summary": {
"skill": 1,
"totalErrors": 1,
},
"userFriendlyMessage": "Label cannot be empty",
},
"message": "Multiple validation errors occurred while creating skill",
"name": "GraphQLError",
}
`;
exports[`Skill creation should fail when label is missing 1`] = `
{
"extensions": {
"code": "BAD_USER_INPUT",
"http": {
"status": 400,
},
"userFriendlyMessage": "An error occurred.",
},
"message": "Field "label" of required type "String!" was not provided.",
"name": "GraphQLError",
}
`;
exports[`Skill creation should fail when name already exists 1`] = `
{
"extensions": {
"code": "METADATA_VALIDATION_FAILED",
"errors": {
"skill": [
{
"errors": [
{
"code": "SKILL_ALREADY_EXISTS",
"message": "Skill with name "existingTestSkill" already exists",
"userFriendlyMessage": "A skill with this name already exists",
},
],
"flatEntityMinimalInformation": {
"name": "existingTestSkill",
"universalIdentifier": Any<String>,
},
"metadataName": "skill",
"status": "fail",
"type": "create",
},
],
},
"message": "Validation failed for 1 skill",
"summary": {
"skill": 1,
"totalErrors": 1,
},
"userFriendlyMessage": "A skill with this name already exists",
},
"message": "Multiple validation errors occurred while creating skill",
"name": "GraphQLError",
}
`;
exports[`Skill creation should fail when name is missing 1`] = `
{
"extensions": {
"code": "BAD_USER_INPUT",
"http": {
"status": 400,
},
"userFriendlyMessage": "An error occurred.",
},
"message": "Field "name" of required type "String!" was not provided.",
"name": "GraphQLError",
}
`;

View File

@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Skill deletion should fail should fail when attempting to delete a standard skill 1`] = `
{
"extensions": {
"code": "FORBIDDEN",
"subCode": "SKILL_IS_STANDARD",
"userFriendlyMessage": "Standard skills cannot be modified.",
},
"message": "Cannot delete standard skill",
"name": "ForbiddenError",
}
`;
exports[`Skill deletion should fail when deleting a non-existent skill 1`] = `
{
"extensions": {
"code": "NOT_FOUND",
"subCode": "SKILL_NOT_FOUND",
"userFriendlyMessage": "Skill not found.",
},
"message": "Skill not found",
"name": "NotFoundError",
}
`;

View File

@@ -0,0 +1,95 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Skill update should fail should fail when attempting to update a standard skill 1`] = `
{
"extensions": {
"code": "FORBIDDEN",
"subCode": "SKILL_IS_STANDARD",
"userFriendlyMessage": "Standard skills cannot be modified.",
},
"message": "Cannot update standard skill",
"name": "ForbiddenError",
}
`;
exports[`Skill update should fail should fail when updating a non-existent skill 1`] = `
{
"extensions": {
"code": "NOT_FOUND",
"subCode": "SKILL_NOT_FOUND",
"userFriendlyMessage": "Skill not found.",
},
"message": "Skill not found",
"name": "NotFoundError",
}
`;
exports[`Skill update should fail when updating with empty content 1`] = `
{
"extensions": {
"code": "METADATA_VALIDATION_FAILED",
"errors": {
"skill": [
{
"errors": [
{
"code": "INVALID_SKILL_INPUT",
"message": "Content cannot be empty",
"userFriendlyMessage": "Content cannot be empty",
},
],
"flatEntityMinimalInformation": {
"universalIdentifier": Any<String>,
},
"metadataName": "skill",
"status": "fail",
"type": "update",
},
],
},
"message": "Validation failed for 1 skill",
"summary": {
"skill": 1,
"totalErrors": 1,
},
"userFriendlyMessage": "Content cannot be empty",
},
"message": "Multiple validation errors occurred while updating skill",
"name": "GraphQLError",
}
`;
exports[`Skill update should fail when updating with empty label 1`] = `
{
"extensions": {
"code": "METADATA_VALIDATION_FAILED",
"errors": {
"skill": [
{
"errors": [
{
"code": "INVALID_SKILL_INPUT",
"message": "Label cannot be empty",
"userFriendlyMessage": "Label cannot be empty",
},
],
"flatEntityMinimalInformation": {
"universalIdentifier": Any<String>,
},
"metadataName": "skill",
"status": "fail",
"type": "update",
},
],
},
"message": "Validation failed for 1 skill",
"summary": {
"skill": 1,
"totalErrors": 1,
},
"userFriendlyMessage": "Label cannot be empty",
},
"message": "Multiple validation errors occurred while updating skill",
"name": "GraphQLError",
}
`;

View File

@@ -0,0 +1,126 @@
import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
import { isDefined } from 'twenty-shared/utils';
import { type CreateSkillInput } from 'src/engine/metadata-modules/skill/dtos/create-skill.input';
type TestContext = {
input: CreateSkillInput;
};
type GlobalTestContext = {
existingSkillLabel: string;
existingSkillName: string;
};
const globalTestContext: GlobalTestContext = {
existingSkillLabel: 'Existing Test Skill',
existingSkillName: 'existingTestSkill',
};
type CreateSkillTestingContext = EachTestingContext<TestContext>[];
describe('Skill creation should fail', () => {
let existingSkillId: string | undefined;
beforeAll(async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: globalTestContext.existingSkillName,
label: globalTestContext.existingSkillLabel,
content: 'Existing skill for testing',
},
});
existingSkillId = data.createSkill.id;
});
afterAll(async () => {
if (isDefined(existingSkillId)) {
await deleteSkill({
expectToFail: false,
input: { id: existingSkillId },
});
}
});
const failingSkillCreationTestCases: CreateSkillTestingContext = [
{
title: 'when label is missing',
context: {
input: {
name: 'skillMissingLabel',
content: 'Test content',
} as CreateSkillInput,
},
},
{
title: 'when content is missing',
context: {
input: {
name: 'skillMissingContent',
label: 'Skill Missing Content',
} as CreateSkillInput,
},
},
{
title: 'when name is missing',
context: {
input: {
label: 'Skill Missing Name',
content: 'Test content',
} as CreateSkillInput,
},
},
{
title: 'when label is empty string',
context: {
input: {
name: 'emptyLabelSkill',
label: '',
content: 'Test content',
},
},
},
{
title: 'when content is empty string',
context: {
input: {
name: 'emptyContentSkill',
label: 'Empty Content Skill',
content: '',
},
},
},
{
title: 'when name already exists',
context: {
input: {
name: globalTestContext.existingSkillName,
label: 'Duplicate Name Skill',
content: 'Duplicate skill content',
},
},
},
];
it.each(eachTestingContextFilter(failingSkillCreationTestCases))(
'$title',
async ({ context }) => {
const { errors } = await createSkill({
expectToFail: true,
input: context.input,
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
},
);
});

View File

@@ -0,0 +1,68 @@
import { faker } from '@faker-js/faker';
import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import { findSkills } from 'test/integration/metadata/suites/skill/utils/find-skills.util';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
type TestContext = {
input: () => {
id: string;
};
};
type DeleteSkillTestingContext = EachTestingContext<TestContext>[];
describe('Skill deletion should fail', () => {
const failingSkillDeletionTestCases: DeleteSkillTestingContext = [
{
title: 'when deleting a non-existent skill',
context: {
input: () => ({
id: faker.string.uuid(),
}),
},
},
];
it.each(eachTestingContextFilter(failingSkillDeletionTestCases))(
'$title',
async ({ context }) => {
const { id } = context.input();
const { errors } = await deleteSkill({
expectToFail: true,
input: {
id,
},
});
expectOneNotInternalServerErrorSnapshot({ errors });
},
);
it('should fail when attempting to delete a standard skill', async () => {
const { data } = await findSkills({
expectToFail: false,
input: undefined,
gqlFields: 'id name isCustom',
});
const standardSkill = data.skills.find((skill) => skill.isCustom === false);
if (!standardSkill) {
return;
}
const { errors } = await deleteSkill({
expectToFail: true,
input: {
id: standardSkill.id,
},
});
expectOneNotInternalServerErrorSnapshot({ errors });
});
});

View File

@@ -0,0 +1,163 @@
import { faker } from '@faker-js/faker';
import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import { findSkills } from 'test/integration/metadata/suites/skill/utils/find-skills.util';
import { updateSkill } from 'test/integration/metadata/suites/skill/utils/update-skill.util';
import {
eachTestingContextFilter,
type EachTestingContext,
} from 'twenty-shared/testing';
import { type UpdateSkillInput } from 'src/engine/metadata-modules/skill/dtos/update-skill.input';
type TestContext = {
input: (testSetup: TestSetup) => UpdateSkillInput;
};
type TestSetup = {
testSkillId: string;
existingSkillNameForDuplicate: string;
};
type GlobalTestContext = {
existingSkillNameForDuplicate: string;
};
const globalTestContext: GlobalTestContext = {
existingSkillNameForDuplicate: 'existingSkillForDuplicateTest',
};
type UpdateSkillTestingContext = EachTestingContext<TestContext>[];
describe('Skill update should fail', () => {
let testSkillId: string;
let existingSkillIdForDuplicate: string;
beforeAll(async () => {
const { data: duplicateData } = await createSkill({
expectToFail: false,
input: {
name: globalTestContext.existingSkillNameForDuplicate,
label: 'Existing Skill For Duplicate Test',
content: 'Existing skill for duplicate test',
},
});
existingSkillIdForDuplicate = duplicateData.createSkill.id;
});
beforeEach(async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'testSkillToUpdate',
label: 'Test Skill To Update',
description: 'Original description',
icon: 'IconSparkles',
content: 'Original content',
},
});
testSkillId = data.createSkill.id;
});
afterEach(async () => {
await deleteSkill({
expectToFail: false,
input: { id: testSkillId },
});
});
afterAll(async () => {
await deleteSkill({
expectToFail: false,
input: { id: existingSkillIdForDuplicate },
});
});
const failingSkillUpdateTestCases: UpdateSkillTestingContext = [
{
title: 'when updating with empty label',
context: {
input: (testSetup) => ({
id: testSetup.testSkillId,
label: '',
}),
},
},
{
title: 'when updating with empty content',
context: {
input: (testSetup) => ({
id: testSetup.testSkillId,
content: '',
}),
},
},
];
it.each(eachTestingContextFilter(failingSkillUpdateTestCases))(
'$title',
async ({ context }) => {
const testSetup: TestSetup = {
testSkillId,
existingSkillNameForDuplicate:
globalTestContext.existingSkillNameForDuplicate,
};
const input = context.input(testSetup);
const { errors } = await updateSkill({
expectToFail: true,
input,
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
},
);
it('should fail when updating a non-existent skill', async () => {
const nonExistentSkillId = faker.string.uuid();
const { errors } = await updateSkill({
expectToFail: true,
input: {
id: nonExistentSkillId,
label: 'Updated Label',
},
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
});
it('should fail when attempting to update a standard skill', async () => {
const { data } = await findSkills({
expectToFail: false,
input: undefined,
gqlFields: 'id name isCustom',
});
const standardSkill = data.skills.find((skill) => skill.isCustom === false);
if (!standardSkill) {
return;
}
const { errors } = await updateSkill({
expectToFail: true,
input: {
id: standardSkill.id,
label: 'Attempted Update to Standard Skill',
},
});
expectOneNotInternalServerErrorSnapshot({
errors,
});
});
});

View File

@@ -0,0 +1,113 @@
import { activateSkill } from 'test/integration/metadata/suites/skill/utils/activate-skill.util';
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deactivateSkill } from 'test/integration/metadata/suites/skill/utils/deactivate-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
describe('Skill activation should succeed', () => {
let testSkillId: string;
beforeEach(async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'testSkillForActivation',
label: 'Test Skill For Activation',
content: 'Test content',
},
});
testSkillId = data.createSkill.id;
});
afterEach(async () => {
await deleteSkill({
expectToFail: false,
input: { id: testSkillId },
});
});
it('should create a skill with isActive true by default', async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'activeByDefaultSkill',
label: 'Active By Default Skill',
content: 'Test content',
},
});
const skillId = data.createSkill.id;
expect(data.createSkill).toMatchObject({
id: skillId,
isActive: true,
isCustom: true,
});
await deleteSkill({
expectToFail: false,
input: { id: skillId },
});
});
it('should deactivate a skill', async () => {
const { data } = await deactivateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(data.deactivateSkill).toMatchObject({
id: testSkillId,
isActive: false,
});
});
it('should activate a deactivated skill', async () => {
await deactivateSkill({
expectToFail: false,
input: { id: testSkillId },
});
const { data } = await activateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(data.activateSkill).toMatchObject({
id: testSkillId,
isActive: true,
});
});
it('should allow deactivating an already active skill (no-op)', async () => {
const { data: firstDeactivate } = await deactivateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(firstDeactivate.deactivateSkill.isActive).toBe(false);
const { data: secondDeactivate } = await deactivateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(secondDeactivate.deactivateSkill.isActive).toBe(false);
});
it('should allow activating an already active skill (no-op)', async () => {
const { data: firstActivate } = await activateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(firstActivate.activateSkill.isActive).toBe(true);
const { data: secondActivate } = await activateSkill({
expectToFail: false,
input: { id: testSkillId },
});
expect(secondActivate.activateSkill.isActive).toBe(true);
});
});

View File

@@ -0,0 +1,147 @@
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import { type CreateSkillInput } from 'src/engine/metadata-modules/skill/dtos/create-skill.input';
describe('Skill creation should succeed', () => {
let createdSkillId: string;
afterEach(async () => {
if (createdSkillId) {
await deleteSkill({
expectToFail: false,
input: { id: createdSkillId },
});
}
});
it('should create a basic custom skill with minimal input', async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'testSkill',
label: 'Test Skill',
content: 'This is the skill content with instructions',
},
});
createdSkillId = data?.createSkill?.id;
expect(data.createSkill).toMatchObject({
id: expect.any(String),
name: 'testSkill',
label: 'Test Skill',
icon: null,
description: null,
content: 'This is the skill content with instructions',
isCustom: true,
isActive: true,
});
});
it('should create skill with all optional fields', async () => {
const input = {
name: 'customSkillName',
label: 'Custom Skill Label',
icon: 'IconSparkles',
description: 'A custom skill with all fields specified',
content: 'Detailed instructions for the skill',
} as const satisfies CreateSkillInput;
const { data } = await createSkill({
expectToFail: false,
input,
});
createdSkillId = data?.createSkill?.id;
expect(data.createSkill).toMatchObject({
id: expect.any(String),
...input,
isCustom: true,
isActive: true,
});
});
it('should sanitize input by trimming whitespace', async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: ' skillWithSpaces ',
label: ' Skill With Spaces ',
icon: ' IconSparkles ',
description: ' Description with spaces ',
content: ' Content with spaces ',
},
});
createdSkillId = data?.createSkill?.id;
expect(data.createSkill).toMatchObject({
id: expect.any(String),
name: 'skillWithSpaces',
label: 'Skill With Spaces',
icon: 'IconSparkles',
description: 'Description with spaces',
content: 'Content with spaces',
});
});
it('should create skill with long content', async () => {
const longContent =
'This is a long content that describes the skill instructions in detail.';
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'longContentSkill',
label: 'Long Content Skill',
content: longContent,
},
});
createdSkillId = data?.createSkill?.id;
expect(data.createSkill).toMatchObject({
id: expect.any(String),
name: 'longContentSkill',
label: 'Long Content Skill',
content: longContent,
isCustom: true,
isActive: true,
});
});
it('should preserve markdown formatting with newlines in content', async () => {
const markdownContent = `# Skill Instructions
## Step 1
Do the first thing.
## Step 2
Do the second thing.
- List item 1
- List item 2`;
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'markdownSkill',
label: 'Markdown Skill',
content: markdownContent,
},
});
createdSkillId = data?.createSkill?.id;
expect(data.createSkill).toMatchObject({
id: expect.any(String),
name: 'markdownSkill',
label: 'Markdown Skill',
content: markdownContent,
isCustom: true,
isActive: true,
});
});
});

View File

@@ -0,0 +1,49 @@
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import { findSkill } from 'test/integration/metadata/suites/skill/utils/find-skill.util';
import { isDefined } from 'twenty-shared/utils';
describe('Skill deletion should succeed', () => {
it('should successfully delete a custom skill', async () => {
const { data: createData } = await createSkill({
expectToFail: false,
input: {
name: 'skillToDelete',
label: 'Skill To Delete',
content: 'This skill will be deleted',
},
});
const skillId = createData.createSkill.id;
if (!isDefined(skillId)) {
return;
}
const { data: findBeforeData } = await findSkill({
expectToFail: false,
input: { id: skillId },
});
expect(findBeforeData.skill.id).toBe(skillId);
const { data: deleteData } = await deleteSkill({
expectToFail: false,
input: { id: skillId },
});
expect(deleteData.deleteSkill).toMatchObject({
id: skillId,
name: 'skillToDelete',
label: 'Skill To Delete',
});
// After deletion, the skill query returns null instead of throwing an error
const { data: findAfterData } = await findSkill({
expectToFail: false,
input: { id: skillId },
});
expect(findAfterData.skill).toBeNull();
});
});

View File

@@ -0,0 +1,131 @@
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
import { updateSkill } from 'test/integration/metadata/suites/skill/utils/update-skill.util';
describe('Skill update should succeed', () => {
let testSkillId: string;
beforeEach(async () => {
const { data } = await createSkill({
expectToFail: false,
input: {
name: 'testSkillToUpdate',
label: 'Test Skill To Update',
description: 'Original description',
icon: 'IconSparkles',
content: 'Original content',
},
});
testSkillId = data.createSkill.id;
});
afterEach(async () => {
await deleteSkill({
expectToFail: false,
input: { id: testSkillId },
});
});
it('should update skill label', async () => {
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
label: 'Updated Skill Label',
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
label: 'Updated Skill Label',
description: 'Original description',
icon: 'IconSparkles',
content: 'Original content',
});
});
it('should update skill description', async () => {
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
description: 'Updated description',
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
label: 'Test Skill To Update',
description: 'Updated description',
});
});
it('should update skill icon', async () => {
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
icon: 'IconRobot',
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
icon: 'IconRobot',
});
});
it('should update skill content', async () => {
const newContent = 'Updated content with new instructions';
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
content: newContent,
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
content: newContent,
});
});
it('should update multiple fields at once', async () => {
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
label: 'Completely Updated Skill',
description: 'Completely updated description',
icon: 'IconBrain',
content: 'Completely updated content',
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
label: 'Completely Updated Skill',
description: 'Completely updated description',
icon: 'IconBrain',
content: 'Completely updated content',
});
});
it('should update label to a unique value', async () => {
const { data } = await updateSkill({
expectToFail: false,
input: {
id: testSkillId,
label: 'Unique Updated Label',
},
});
expect(data.updateSkill).toMatchObject({
id: testSkillId,
label: 'Unique Updated Label',
});
});
});

View File

@@ -0,0 +1,36 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
export type ActivateSkillFactoryInput = {
id: string;
};
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
isActive
applicationId
createdAt
updatedAt
`;
export const activateSkillQueryFactory = ({
input,
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<ActivateSkillFactoryInput>) => ({
query: gql`
mutation ActivateSkill($id: UUID!) {
activateSkill(id: $id) {
${gqlFields}
}
}
`,
variables: {
id: input.id,
},
});

View File

@@ -0,0 +1,43 @@
import {
type ActivateSkillFactoryInput,
activateSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/activate-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const activateSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<ActivateSkillFactoryInput>): CommonResponseBody<{
activateSkill: SkillDTO;
}> => {
const graphqlOperation = activateSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Skill activation should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Skill activation has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,36 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { type CreateSkillInput } from 'src/engine/metadata-modules/skill/dtos/create-skill.input';
export type CreateSkillFactoryInput = CreateSkillInput;
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
isActive
applicationId
createdAt
updatedAt
`;
export const createSkillQueryFactory = ({
input,
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<CreateSkillFactoryInput>) => ({
query: gql`
mutation CreateSkill($input: CreateSkillInput!) {
createSkill(input: $input) {
${gqlFields}
}
}
`,
variables: {
input,
},
});

View File

@@ -0,0 +1,43 @@
import {
type CreateSkillFactoryInput,
createSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/create-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const createSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<CreateSkillFactoryInput>): CommonResponseBody<{
createSkill: SkillDTO;
}> => {
const graphqlOperation = createSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Skill creation should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Skill creation has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,36 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
export type DeactivateSkillFactoryInput = {
id: string;
};
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
isActive
applicationId
createdAt
updatedAt
`;
export const deactivateSkillQueryFactory = ({
input,
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<DeactivateSkillFactoryInput>) => ({
query: gql`
mutation DeactivateSkill($id: UUID!) {
deactivateSkill(id: $id) {
${gqlFields}
}
}
`,
variables: {
id: input.id,
},
});

View File

@@ -0,0 +1,43 @@
import {
type DeactivateSkillFactoryInput,
deactivateSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/deactivate-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const deactivateSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<DeactivateSkillFactoryInput>): CommonResponseBody<{
deactivateSkill: SkillDTO;
}> => {
const graphqlOperation = deactivateSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Skill deactivation should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Skill deactivation has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,28 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
export type DeleteSkillFactoryInput = {
id: string;
};
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
`;
export const deleteSkillQueryFactory = ({
input,
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<DeleteSkillFactoryInput>) => ({
query: gql`
mutation DeleteSkill($id: UUID!) {
deleteSkill(id: $id) {
${gqlFields}
}
}
`,
variables: {
id: input.id,
},
});

View File

@@ -0,0 +1,43 @@
import {
type DeleteSkillFactoryInput,
deleteSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/delete-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const deleteSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<DeleteSkillFactoryInput>): CommonResponseBody<{
deleteSkill: SkillDTO;
}> => {
const graphqlOperation = deleteSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Skill deletion should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Skill deletion has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,36 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
export type FindSkillFactoryInput = {
id: string;
};
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
isActive
applicationId
createdAt
updatedAt
`;
export const findSkillQueryFactory = ({
input,
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<FindSkillFactoryInput>) => ({
query: gql`
query Skill($id: UUID!) {
skill(id: $id) {
${gqlFields}
}
}
`,
variables: {
id: input.id,
},
});

View File

@@ -0,0 +1,43 @@
import {
type FindSkillFactoryInput,
findSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/find-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const findSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<FindSkillFactoryInput>): CommonResponseBody<{
skill: SkillDTO;
}> => {
const graphqlOperation = findSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Finding skill should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Finding skill has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,27 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
applicationId
createdAt
updatedAt
`;
export const findSkillsQueryFactory = ({
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
}: PerformMetadataQueryParams<void>) => ({
query: gql`
query Skills {
skills {
${gqlFields}
}
}
`,
});

View File

@@ -0,0 +1,39 @@
import { findSkillsQueryFactory } from 'test/integration/metadata/suites/skill/utils/find-skills-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const findSkills = async ({
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<undefined>): CommonResponseBody<{
skills: SkillDTO[];
}> => {
const graphqlOperation = findSkillsQueryFactory({
gqlFields,
input: undefined,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Finding skills should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Finding skills has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};

View File

@@ -0,0 +1,36 @@
import gql from 'graphql-tag';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { type UpdateSkillInput } from 'src/engine/metadata-modules/skill/dtos/update-skill.input';
export type UpdateSkillFactoryInput = UpdateSkillInput;
const DEFAULT_SKILL_GQL_FIELDS = `
id
name
label
icon
description
content
isCustom
isActive
applicationId
createdAt
updatedAt
`;
export const updateSkillQueryFactory = ({
gqlFields = DEFAULT_SKILL_GQL_FIELDS,
input,
}: PerformMetadataQueryParams<UpdateSkillFactoryInput>) => ({
query: gql`
mutation UpdateSkill($input: UpdateSkillInput!) {
updateSkill(input: $input) {
${gqlFields}
}
}
`,
variables: {
input,
},
});

View File

@@ -0,0 +1,43 @@
import {
type UpdateSkillFactoryInput,
updateSkillQueryFactory,
} from 'test/integration/metadata/suites/skill/utils/update-skill-query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { type PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';
export const updateSkill = async ({
input,
gqlFields,
expectToFail = false,
token,
}: PerformMetadataQueryParams<UpdateSkillFactoryInput>): CommonResponseBody<{
updateSkill: SkillDTO;
}> => {
const graphqlOperation = updateSkillQueryFactory({
input,
gqlFields,
});
const response = await makeMetadataAPIRequest(graphqlOperation, token);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Skill update should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Skill update has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};