Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zapier tests #7568

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/twenty-zapier/src/test/authentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('custom auth', () => {
expect(response.data).toHaveProperty('currentWorkspace');
expect(response.data.currentWorkspace).toHaveProperty('displayName');
Comment on lines 62 to 63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: These expectations are unreachable if an error is thrown. Consider moving them before the try-catch block or removing them.

} catch (error: any) {
expect(error.message).toContain('ENOTFOUND');
expect(error.message).toBeDefined();
}
});

Expand Down
28 changes: 21 additions & 7 deletions packages/twenty-zapier/src/test/creates/crud_record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ describe('creates.create_company', () => {
crudZapierOperation: Operation.create,
name: 'Company Name',
address: { addressCity: 'Paris' },
domainName: 'Company Domain Name',
linkedinLink: { url: '/linkedin_url', label: 'Test linkedinUrl' },
xLink: { url: '/x_url', label: 'Test xUrl' },
linkedinLink: {
primaryLinkUrl: '/linkedin_url',
primaryLinkLabel: 'Test linkedinUrl',
secondaryLinks: [
'{ url: "/linkedin_url2", label: "Test linkedinUrl2" }',
],
},
Comment on lines +18 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The secondaryLinks are stored as a string representation of an object, which may cause issues when parsing. Consider using a proper object structure instead of a string.

xLink: {
primaryLinkUrl: '/x_url',
primaryLinkLabel: 'Test xUrl',
secondaryLinks: ['{ url: "/x_url2", label: "Test xUrl2" }'],
},
Comment on lines +25 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Similar to the linkedinLink, the xLink secondaryLinks are stored as a string. Ensure this is the intended format and that it can be properly parsed.

annualRecurringRevenue: {
amountMicros: 100000000000,
currencyCode: 'USD',
Expand Down Expand Up @@ -49,8 +58,11 @@ describe('creates.create_company', () => {
nameSingular: 'Person',
crudZapierOperation: Operation.create,
name: { firstName: 'John', lastName: 'Doe' },
email: '[email protected]',
phone: '+33610203040',
phones: {
primaryPhoneNumber: '610203040',
primaryPhoneCountryCode: '+33',
additionalPhones: ['{number: "610203041", countryCode: "+33"}'],
},
Comment on lines +61 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The additionalPhones field is using a string representation of an object. This might cause parsing issues. Consider using a proper object structure.

city: 'Paris',
});
const result = await appTester(
Expand All @@ -64,11 +76,13 @@ describe('creates.create_company', () => {
requestDb(
z,
bundle,
`query findPerson {person(filter: {id: {eq: "${result.data.createPerson.id}"}}){phone}}`,
`query findPerson {person(filter: {id: {eq: "${result.data.createPerson.id}"}}){phones{primaryPhoneNumber}}}`,
),
bundle,
);
expect(checkDbResult.data.person.phone).toEqual('+33610203040');
expect(checkDbResult.data.person.phones.primaryPhoneNumber).toEqual(
'610203040',
);
});
});

Expand Down
46 changes: 38 additions & 8 deletions packages/twenty-zapier/src/test/utils/computeInputFields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ describe('computeInputFields', () => {
helpText:
'Annual Salary of the Person: Amount Micros. eg: set 3210000 for 3.21$',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'annualSalary__currencyCode',
Expand All @@ -150,97 +152,125 @@ describe('computeInputFields', () => {
helpText:
'Annual Salary of the Person: Currency Code. eg: USD, EUR, etc...',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'jobTitle',
label: 'Job Title',
type: 'string',
helpText: 'Contact’s job title',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'updatedAt',
label: 'Update date',
type: 'datetime',
helpText: null,
required: false,
list: false,
placeholder: undefined,
},
{
key: 'name__firstName',
label: 'Name: First Name',
type: 'string',
helpText: 'Contact’s name: First Name',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'name__lastName',
label: 'Name: Last Name',
type: 'string',
helpText: 'Contact’s name: Last Name',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'recordPosition',
label: 'RecordPosition',
type: 'integer',
helpText: 'Record Position',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'xLink__url',
label: 'X: Url',
type: 'string',
helpText: 'Contact’s X/Twitter account: Link Url',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'xLink__label',
label: 'X: Label',
type: 'string',
helpText: 'Contact’s X/Twitter account: Link Label',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'whatsapp__url',
label: 'Whatsapp: Url',
key: 'whatsapp__primaryLinkLabel',
label: 'Whatsapp: Primary Link Label',
type: 'string',
helpText: 'Contact’s Whatsapp account: Link Url',
helpText: 'Contact’s Whatsapp account: Primary Link Label',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'whatsapp__label',
label: 'Whatsapp: Label',
key: 'whatsapp__primaryLinkUrl',
label: 'Whatsapp: Primary Link Url',
type: 'string',
helpText: 'Contact’s Whatsapp account: Link Label',
helpText: 'Contact’s Whatsapp account: Primary Link Url',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'whatsapp__secondaryLinks',
label: 'Whatsapp: Secondary Lings',
label: 'Whatsapp: Secondary Links',
type: 'string',
helpText: 'Contact’s Whatsapp account: Link Label',
helpText: 'Contact’s Whatsapp account: Secondary Links',
required: false,
list: true,
placeholder: '{ url: "", label: "" }',
},
{
key: 'email',
label: 'Email',
type: 'string',
helpText: 'Contact’s Email',
required: false,
list: false,
placeholder: undefined,
},
{
key: 'companyId',
label: 'Company id (foreign key)',
type: 'string',
helpText: 'Contact’s company id foreign key',
required: false,
list: false,
placeholder: undefined,
},
];
const idInputField: InputField = {
key: 'id',
label: 'Id',
type: 'string',
helpText: null,
list: false,
placeholder: undefined,
required: false,
};
const expectedResult = [idInputField].concat(baseExpectedResult);
Expand Down
1 change: 1 addition & 0 deletions packages/twenty-zapier/src/utils/computeInputFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export const computeInputFields = (
helpText: nodeField.description,
required,
list: getListFromFieldMetadataType(nodeField.type),
placeholder: undefined,
};
result.push(field);
break;
Expand Down
4 changes: 0 additions & 4 deletions packages/twenty-zapier/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"skipLibCheck": true
},
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"jest.config.ts"
]
}
Loading