Remove zapier trigger company (#2742)

* Fix zapier tests

* Handle nested fields

* Code review returns

* Add more sample

* Update trigger sample

* Remove zapier trigger company
This commit is contained in:
martmull 2023-11-28 09:58:41 +01:00 committed by GitHub
parent 0fc3c7c567
commit 7b02391b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 167 deletions

View File

@ -2,7 +2,6 @@ const { version } = require('../package.json');
import { version as platformVersion } from 'zapier-platform-core';
import createPerson from './creates/create_person';
import createCompany from './creates/create_company';
import company from './triggers/company';
import authentication from './authentication';
import 'dotenv/config';
@ -10,9 +9,6 @@ export default {
version,
platformVersion,
authentication: authentication,
triggers: {
[company.key]: company,
},
creates: {
[createPerson.key]: createPerson,
[createCompany.key]: createCompany,

View File

@ -1,89 +0,0 @@
import { Bundle, createAppTester, ZObject } from 'zapier-platform-core';
import App from '../../index';
import getBundle from '../../utils/getBundle';
import requestDb from '../../utils/requestDb';
const appTester = createAppTester(App);
describe('triggers.company', () => {
test('should succeed to subscribe', async () => {
const bundle = getBundle({});
bundle.targetUrl = 'https://test.com';
const result = await appTester(
App.triggers.company.operation.performSubscribe,
bundle,
);
expect(result).toBeDefined();
expect(result.id).toBeDefined();
const checkDbResult = await appTester(
(z: ZObject, bundle: Bundle) =>
requestDb(
z,
bundle,
`query webhook {webhook(filter: {id: {eq: "${result.id}"}}){id operation}}`,
),
bundle,
);
expect(checkDbResult.data.webhook.operation).toEqual(
'company',
);
});
test('should succeed to unsubscribe', async () => {
const bundle = getBundle({});
bundle.targetUrl = 'https://test.com';
const result = await appTester(
App.triggers.company.operation.performSubscribe,
bundle,
);
const unsubscribeBundle = getBundle({});
unsubscribeBundle.subscribeData = { id: result.id };
const unsubscribeResult = await appTester(
App.triggers.company.operation.performUnsubscribe,
unsubscribeBundle,
);
expect(unsubscribeResult).toBeDefined();
expect(unsubscribeResult.id).toEqual(result.id);
const checkDbResult = await appTester(
(z: ZObject, bundle: Bundle) =>
requestDb(
z,
bundle,
`query webhook {webhook(filter: {id: {eq: "${result.id}"}}){id}}`,
),
bundle,
);
expect(checkDbResult.data.webhook).toEqual(null);
});
test('should load company from webhook', async () => {
const bundle = {
cleanedRequest: {
id: 'd6ccb1d1-a90b-4822-a992-a0dd946592c9',
name: '',
domainName: '',
createdAt: '2023-10-19 10:10:12.490',
address: '',
employees: null,
linkedinUrl: null,
xUrl: null,
annualRecurringRevenue: null,
idealCustomerProfile: false,
},
};
const results = await appTester(
App.triggers.company.operation.perform,
bundle,
);
expect(results.length).toEqual(1);
const company = results[0];
expect(company.id).toEqual('d6ccb1d1-a90b-4822-a992-a0dd946592c9');
});
it('should load companies from list', async () => {
const bundle = getBundle({});
const results = await appTester(
App.triggers.company.operation.performList,
bundle,
);
expect(results.length).toBeGreaterThan(1);
const firstCompany = results[0];
expect(firstCompany.node.id).toBeDefined();
});
});

View File

@ -1,74 +0,0 @@
import { Bundle, ZObject } from 'zapier-platform-core';
import requestDb from '../utils/requestDb';
import handleQueryParams from '../utils/handleQueryParams';
const performSubscribe = async (z: ZObject, bundle: Bundle) => {
const data = { targetUrl: bundle.targetUrl, operation: 'company' };
const result = await requestDb(
z,
bundle,
`mutation createWebhook {createWebhook(data:{${handleQueryParams(
data,
)}}) {id}}`,
);
return result.data.createWebhook;
};
const performUnsubscribe = async (z: ZObject, bundle: Bundle) => {
const data = { id: bundle.subscribeData?.id };
const result = await requestDb(
z,
bundle,
`mutation deleteWebhook {deleteWebhook(${handleQueryParams(
data,
)}) {id}}`,
);
return result.data.deleteWebhook;
};
const perform = (z: ZObject, bundle: Bundle) => {
return [bundle.cleanedRequest];
};
const performList = async (z: ZObject, bundle: Bundle) => {
const results = await requestDb(
z,
bundle,
`query company {companies {edges {node {
id
name
domainName
createdAt
address
employees
linkedinLink{label url}
xLink{label url}
annualRecurringRevenue{amountMicros currencyCode}
idealCustomerProfile
}}}}`,
);
return results.data.companies.edges;
};
export default {
key: 'company',
noun: 'Company',
display: {
label: 'New Company',
description: 'Triggers when a new company is created.',
},
operation: {
inputFields: [],
type: 'hook',
performSubscribe,
performUnsubscribe,
perform,
performList,
sample: {
id: 'f75f6b2e-9442-4c72-aa95-47d8e5ec8cb3',
createdAt: '2023-10-19T07:37:25.306Z',
workspaceId: 'c8b070fc-c969-4ca5-837a-e7c3735734d2',
},
outputFields: [
{ key: 'id', label: 'ID' },
{ key: 'createdAt', label: 'Created At' },
{ key: 'workspaceId', label: 'Workspace ID' },
],
},
};