-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Server Integration tests] Enrich integration GraphQL API tests #2 #7978
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request introduces comprehensive integration tests for various GraphQL API resolvers in the Twenty server. Here's a summary of the key changes:
- Added
TIM_USER_ID
constant for consistent user identification in tests - Implemented extensive test suites for API keys, attachments, audit logs, blocklists, calendar channel event associations, and calendar channels
- Each test suite covers CRUD operations, including edge cases and error handling
- Special handling for workspace members, preventing multiple deletions as required
Key points:
- Tests ensure API behaves correctly for single and multiple record operations
- Soft deletion and permanent removal scenarios are covered
- Test suites are designed to be independent and leave no side effects
- Consistent use of utility functions for creating GraphQL operations and making API requests
8 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
expect(destroyApiKeyResponse.body.data.destroyApiKey).toBeTruthy(); | ||
}); | ||
|
||
it('9. should not find many API keys anymore', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Test could be combined with test on line 257 to reduce duplication
it('9. should not find many API keys anymore', async () => { | |
it('9. should not find many API keys anymore', async () => { | |
const graphqlOperation = findManyOperationFactory({ | |
objectMetadataSingularName: 'apiKey', | |
objectMetadataPluralName: 'apiKeys', | |
gqlFields: API_KEY_GQL_FIELDS, | |
filter: { | |
id: { | |
in: [API_KEY_1_ID, API_KEY_2_ID], | |
}, | |
not: { | |
deletedAt: { | |
is: 'NULL', | |
}, | |
}, | |
}, | |
}); | |
const response = await makeGraphqlAPIRequest(graphqlOperation); | |
expect(response.body.data.apiKeys.edges).toHaveLength(0); | |
}); |
expect(createdAttachment).toHaveProperty('opportunityId'); | ||
}); | ||
|
||
it('2. should find many attachments', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Duplicate test number. Should be '3.' instead of '2.'
it('2. should find many attachments', async () => { | |
it('3. should find many attachments', async () => { |
}, | ||
}); | ||
|
||
const findAuditLogsResponse = await makeGraphqlAPIRequest(graphqlOperation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Rename variable to 'response' for consistency with other tests
const destroyAuditLogResponse = | ||
await makeGraphqlAPIRequest(graphqlOperation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Unnecessary variable assignment. Use inline await
if (data.edges.length > 0) { | ||
const associations = data.edges[0].node; | ||
|
||
expect(associations).toHaveProperty('eventExternalId'); | ||
expect(associations).toHaveProperty('id'); | ||
expect(associations).toHaveProperty('createdAt'); | ||
expect(associations).toHaveProperty('updatedAt'); | ||
expect(associations).toHaveProperty('deletedAt'); | ||
expect(associations).toHaveProperty('calendarChannelId'); | ||
expect(associations).toHaveProperty('calendarEventId'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Check if data exists before asserting properties
expect(data).toBeDefined(); | ||
expect(Array.isArray(data.edges)).toBe(true); | ||
|
||
if (data.edges.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Check if data.edges is empty before accessing
if (data.edges.length > 0) { | |
if (data.edges && data.edges.length > 0) { | |
const calendarChannels = data.edges[0].node; | |
// ... existing assertions | |
} |
This PR was created by GitStart to address the requirements from this ticket: TWNTY-7526.
Description
For workspace members, the deletion of multiple members is a special case that is not permitted by the method for regular users. As a result, we ensure that multiple deletions are not processed.
For certain tests, both an account ID and a user ID are required. We are utilizing Tim's account for all testing purposes, as specified by the token in
jest-integration.config.ts
. To streamline this process, we have defined a constant to store and reference the account ID and user ID during testing.Refs#7526
Dem