2052 zapier integration 5 deploy twenty zapier app into the public repository (#2101)
* Add create_company Zap action * Add testing for that action * Core review returns
This commit is contained in:
@ -0,0 +1,68 @@
|
||||
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_company', () => {
|
||||
test('should run', async () => {
|
||||
const bundle = getBundle({
|
||||
name: 'Company Name',
|
||||
address: 'Company Address',
|
||||
domainName: 'Company Domain Name',
|
||||
linkedinUrl: 'Test linkedinUrl',
|
||||
xUrl: 'Test xUrl',
|
||||
annualRecurringRevenue: 100000,
|
||||
idealCustomerProfile: true,
|
||||
employees: 25,
|
||||
});
|
||||
const result = await appTester(
|
||||
App.creates.create_company.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
expect(result.data?.createOneCompany?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findCompany {findUniqueCompany(where: {id: "${result.data.createOneCompany.id}"}){id, annualRecurringRevenue}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.findUniqueCompany.annualRecurringRevenue).toEqual(
|
||||
100000,
|
||||
);
|
||||
});
|
||||
test('should run with not required missing params', async () => {
|
||||
const bundle = getBundle({
|
||||
name: 'Company Name',
|
||||
address: 'Company Address',
|
||||
domainName: 'Company Domain Name',
|
||||
linkedinUrl: 'Test linkedinUrl',
|
||||
xUrl: 'Test xUrl',
|
||||
idealCustomerProfile: true,
|
||||
employees: 25,
|
||||
});
|
||||
const result = await appTester(
|
||||
App.creates.create_company.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
expect(result.data?.createOneCompany?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findCompany {findUniqueCompany(where: {id: "${result.data.createOneCompany.id}"}){id, annualRecurringRevenue}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.findUniqueCompany.annualRecurringRevenue).toEqual(
|
||||
null,
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -1,25 +1,59 @@
|
||||
import App from '../../index';
|
||||
import { createAppTester, tools } from 'zapier-platform-core';
|
||||
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 = {
|
||||
authData: { apiKey: String(process.env.API_KEY) },
|
||||
inputData: {
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'johndoe@gmail.com',
|
||||
phone: '+33610203040',
|
||||
city: 'Paris',
|
||||
},
|
||||
};
|
||||
const bundle = getBundle({
|
||||
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?.createOnePerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findPerson {findUniquePerson(id: "${results.data.createOnePerson.id}"){id, phone}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.findUniquePerson.phone).toEqual('+33610203040');
|
||||
});
|
||||
|
||||
test('should run with not required missing params', async () => {
|
||||
const bundle = getBundle({
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'johndoe@gmail.com',
|
||||
city: 'Paris',
|
||||
});
|
||||
const results = await appTester(
|
||||
App.creates.create_person.operation.perform,
|
||||
bundle,
|
||||
);
|
||||
expect(results).toBeDefined();
|
||||
expect(results.data?.createOnePerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`query findPerson {findUniquePerson(id: "${results.data.createOnePerson.id}"){id, phone}}`,
|
||||
),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.findUniquePerson.phone).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user