2114 timebox make sure the zapier integrations supports custom objects (#3091)
* Fix build command * Add hidden trigger to fetch object names * Remove useless actions * Rename createObject to createRecord
This commit is contained in:
@ -1,53 +0,0 @@
|
||||
import App from '../../index';
|
||||
import { Bundle, createAppTester, tools, ZObject } from 'zapier-platform-core';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import requestDb from '../../utils/requestDb';
|
||||
const appTester = createAppTester(App);
|
||||
tools.env.inject();
|
||||
|
||||
describe('creates.create_person', () => {
|
||||
test('should run', async () => {
|
||||
const bundle = getBundle({
|
||||
name: {firstName: 'John', lastName: 'Doe'},
|
||||
email: 'johndoe@gmail.com',
|
||||
phone: '+33610203040',
|
||||
city: 'Paris',
|
||||
});
|
||||
const results = await appTester(
|
||||
App.creates.create_person.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(results).toBeDefined();
|
||||
expect(results.data?.createPerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findPerson {person(filter: {id: {eq: "${results.data.createPerson.id}"}}){phone}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.person.phone).toEqual('+33610203040');
|
||||
});
|
||||
|
||||
test('should run with not required params', async () => {
|
||||
const bundle = getBundle({});
|
||||
const results = await appTester(
|
||||
App.creates.create_person.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(results).toBeDefined();
|
||||
expect(results.data?.createPerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findPerson {person(filter: {id: {eq: "${results.data.createPerson.id}"}}){phone}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.person.phone).toEqual("");
|
||||
});
|
||||
});
|
||||
@ -1,13 +1,14 @@
|
||||
import App from '../../index';
|
||||
import { Bundle, createAppTester, tools, ZObject } from 'zapier-platform-core';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import requestDb from '../../utils/requestDb';
|
||||
import getBundle from "../../utils/getBundle";
|
||||
import { Bundle, createAppTester, tools, ZObject } from "zapier-platform-core";
|
||||
import requestDb from "../../utils/requestDb";
|
||||
const appTester = createAppTester(App);
|
||||
tools.env.inject;
|
||||
|
||||
describe('creates.create_company', () => {
|
||||
test('should run', async () => {
|
||||
describe('creates.create_record', () => {
|
||||
test('should run to create a Company Record', async () => {
|
||||
const bundle = getBundle({
|
||||
nameSingular: 'Company',
|
||||
name: 'Company Name',
|
||||
address: 'Company Address',
|
||||
domainName: 'Company Domain Name',
|
||||
@ -18,7 +19,7 @@ describe('creates.create_company', () => {
|
||||
employees: 25,
|
||||
});
|
||||
const result = await appTester(
|
||||
App.creates.create_company.operation.perform,
|
||||
App.creates.create_record.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
@ -35,26 +36,30 @@ describe('creates.create_company', () => {
|
||||
expect(checkDbResult.data.company.annualRecurringRevenue.amountMicros).toEqual(
|
||||
100000000000,
|
||||
);
|
||||
});
|
||||
test('should run with not required params', async () => {
|
||||
const bundle = getBundle({});
|
||||
})
|
||||
test('should run to create a Person Record', async () => {
|
||||
const bundle = getBundle({
|
||||
nameSingular: 'Person',
|
||||
name: {firstName: 'John', lastName: 'Doe'},
|
||||
email: 'johndoe@gmail.com',
|
||||
phone: '+33610203040',
|
||||
city: 'Paris',
|
||||
});
|
||||
const result = await appTester(
|
||||
App.creates.create_company.operation.perform,
|
||||
App.creates.create_record.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
expect(result.data?.createCompany?.id).toBeDefined();
|
||||
expect(result.data?.createPerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findCompany {company(filter: {id: {eq: "${result.data.createCompany.id}"}}){id annualRecurringRevenue{amountMicros currencyCode}}}`,
|
||||
`query findPerson {person(filter: {id: {eq: "${result.data.createPerson.id}"}}){phone}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.company.annualRecurringRevenue.amountMicros).toEqual(
|
||||
null,
|
||||
);
|
||||
});
|
||||
});
|
||||
expect(checkDbResult.data.person.phone).toEqual('+33610203040');
|
||||
})
|
||||
})
|
||||
@ -0,0 +1,17 @@
|
||||
import { createAppTester } from "zapier-platform-core";
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import App from '../../index';
|
||||
|
||||
const appTester = createAppTester(App);
|
||||
describe('triggers.find_objects', () => {
|
||||
test('should run', async () => {
|
||||
const bundle = getBundle({});
|
||||
const result = await appTester(
|
||||
App.triggers.find_objects.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
expect(result.length).toBeGreaterThan(1)
|
||||
expect(result[0].nameSingular).toBeDefined()
|
||||
})
|
||||
})
|
||||
8
packages/twenty-zapier/src/test/utils/capitalize.spec.ts
Normal file
8
packages/twenty-zapier/src/test/utils/capitalize.spec.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { capitalize } from "../../utils/capitalize";
|
||||
|
||||
describe('capitalize', ()=> {
|
||||
test('should capitalize properly', ()=> {
|
||||
expect(capitalize('word')).toEqual('Word')
|
||||
expect(capitalize('word word')).toEqual('Word word')
|
||||
})
|
||||
})
|
||||
@ -0,0 +1,42 @@
|
||||
import { computeInputFields } from "../../utils/computeInputFields";
|
||||
|
||||
describe('computeInputFields', ()=> {
|
||||
test('should create Person input fields properly', ()=> {
|
||||
const personInfos = {
|
||||
type: "object",
|
||||
properties: {
|
||||
email: {
|
||||
type: "string"
|
||||
},
|
||||
xLink: {
|
||||
type: "object",
|
||||
properties: {
|
||||
url: {
|
||||
type: "string"
|
||||
},
|
||||
label: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
avatarUrl: {
|
||||
type: "string"
|
||||
},
|
||||
favorites: {
|
||||
type: "array",
|
||||
items: {
|
||||
$ref: "#/components/schemas/Favorite"
|
||||
}
|
||||
},
|
||||
},
|
||||
example: {},
|
||||
required: ['avatarUrl']
|
||||
}
|
||||
expect(computeInputFields(personInfos)).toEqual([
|
||||
{ key: "email", label: "Email", required: false, type: "string" },
|
||||
{ key: "xLink__url", label: "X Link: Url", required: false, type: "string" },
|
||||
{ key: "xLink__label", label: "X Link: Label", required: false, type: "string" },
|
||||
{ key: "avatarUrl", label: "Avatar Url", required: true, type: "string" },
|
||||
])
|
||||
})
|
||||
})
|
||||
7
packages/twenty-zapier/src/test/utils/labelize.spec.ts
Normal file
7
packages/twenty-zapier/src/test/utils/labelize.spec.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { labelling } from "../../utils/labelling";
|
||||
|
||||
describe('labelling', ()=> {
|
||||
test('should label properly', ()=> {
|
||||
expect(labelling('createdAt')).toEqual('Created At')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user