- [x] findOne/findManyCalendarEvents / findOne/findManyMessages - add
integration tests
- [ ] ~~fix typing~~ - coming in new PR >
[Issue](https://github.com/twentyhq/core-team-issues/issues/976)
This commit is contained in:
Etienne
2025-05-16 11:38:34 +02:00
committed by GitHub
parent dc4bcc3049
commit 160eb23454
7 changed files with 185 additions and 1 deletions

View File

@ -2,6 +2,10 @@ import { WorkspaceEntityManager } from 'src/engine/twenty-orm/entity-manager/wor
const tableName = 'calendarEvent';
export const DEV_SEED_CALENDAR_EVENT_IDS = {
CALENDAR_EVENT_1: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
};
export const seedCalendarEvents = async (
entityManager: WorkspaceEntityManager,
schemaName: string,
@ -30,7 +34,7 @@ export const seedCalendarEvents = async (
.orIgnore()
.values([
{
id: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
id: DEV_SEED_CALENDAR_EVENT_IDS.CALENDAR_EVENT_1,
title: 'Meeting with Christoph',
isCanceled: false,
isFullDay: false,

View File

@ -0,0 +1,9 @@
export const CALENDAR_EVENT_GQL_FIELDS = `
id
title
description
endsAt
startsAt
createdAt
updatedAt
deletedAt`;

View File

@ -0,0 +1,7 @@
export const MESSAGE_GQL_FIELDS = `
id
subject
text
createdAt
updatedAt
deletedAt`;

View File

@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`calendarEventsResolver (e2e) should find many calendarEvents 1`] = `
{
"createdAt": Any<String>,
"deletedAt": null,
"description": "Discuss project progress",
"endsAt": Any<String>,
"id": "86083141-1c0e-494c-a1b6-85b1c6fefaa5",
"startsAt": Any<String>,
"title": "Meeting with Christoph",
"updatedAt": Any<String>,
}
`;
exports[`calendarEventsResolver (e2e) should find one calendarEvent 1`] = `
{
"createdAt": Any<String>,
"deletedAt": null,
"description": "Discuss project progress",
"endsAt": Any<String>,
"id": "86083141-1c0e-494c-a1b6-85b1c6fefaa5",
"startsAt": Any<String>,
"title": "Meeting with Christoph",
"updatedAt": Any<String>,
}
`;

View File

@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`messagesResolver (e2e) should find many messages 1`] = `
{
"createdAt": Any<String>,
"deletedAt": null,
"id": "20202020-04c8-4f24-93f2-764948e95014",
"subject": "Inquiry Regarding Topic",
"text": "Good Morning,
I am writing to inquire about information. Could you please provide me with details regarding this topic?
Your assistance in this matter would be greatly appreciated. Thank you in advance for your prompt response.
Best regards,Tim",
"updatedAt": Any<String>,
}
`;
exports[`messagesResolver (e2e) should find one message 1`] = `
{
"createdAt": Any<String>,
"deletedAt": null,
"id": "20202020-2b8a-405d-8f42-e820ca921421",
"subject": "Meeting Request",
"text": "Hello,
I hope this email finds you well. I am writing to request a meeting. I believe it would be beneficial for both parties to collaborate and explore potential opportunities. Would you be available for a meeting sometime next week? Please let me know your availability, and I will arrange a suitable time.
Looking forward to your response.
Best regards",
"updatedAt": Any<String>,
}
`;

View File

@ -0,0 +1,56 @@
import { CALENDAR_EVENT_GQL_FIELDS } from 'test/integration/constants/calendar-event-gql-fields.constants';
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
import { DEV_SEED_CALENDAR_EVENT_IDS } from 'src/database/typeorm-seeds/workspace/calendar-events';
describe('calendarEventsResolver (e2e)', () => {
it('should find many calendarEvents', async () => {
const graphqlOperation = findManyOperationFactory({
objectMetadataSingularName: 'calendarEvent',
objectMetadataPluralName: 'calendarEvents',
gqlFields: CALENDAR_EVENT_GQL_FIELDS,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
const data = response.body.data.calendarEvents;
expect(data).toBeDefined();
expect(Array.isArray(data.edges)).toBe(true);
const edges = data.edges;
expect(edges.length).toEqual(1);
const calendarEvent = edges[0].node;
expect(calendarEvent).toMatchSnapshot({
createdAt: expect.any(String),
endsAt: expect.any(String),
startsAt: expect.any(String),
updatedAt: expect.any(String),
});
});
it('should find one calendarEvent', async () => {
const graphqlOperation = findOneOperationFactory({
objectMetadataSingularName: 'calendarEvent',
filter: { id: { eq: DEV_SEED_CALENDAR_EVENT_IDS.CALENDAR_EVENT_1 } },
gqlFields: CALENDAR_EVENT_GQL_FIELDS,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
const data = response.body.data.calendarEvent;
expect(data).toBeDefined();
expect(data).toMatchSnapshot({
createdAt: expect.any(String),
endsAt: expect.any(String),
startsAt: expect.any(String),
updatedAt: expect.any(String),
});
});
});

View File

@ -0,0 +1,52 @@
import { MESSAGE_GQL_FIELDS } from 'test/integration/constants/message-gql-fields.constants';
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
import { DEV_SEED_MESSAGE_IDS } from 'src/database/typeorm-seeds/workspace/messages';
describe('messagesResolver (e2e)', () => {
it('should find many messages', async () => {
const graphqlOperation = findManyOperationFactory({
objectMetadataSingularName: 'message',
objectMetadataPluralName: 'messages',
gqlFields: MESSAGE_GQL_FIELDS,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
const data = response.body.data.messages;
expect(data).toBeDefined();
expect(Array.isArray(data.edges)).toBe(true);
const edges = data.edges;
expect(edges.length).toEqual(3);
const message1 = edges[0].node;
expect(message1).toMatchSnapshot({
createdAt: expect.any(String),
updatedAt: expect.any(String),
});
});
it('should find one message', async () => {
const graphqlOperation = findOneOperationFactory({
objectMetadataSingularName: 'message',
filter: { id: { eq: DEV_SEED_MESSAGE_IDS.MESSAGE_1 } },
gqlFields: MESSAGE_GQL_FIELDS,
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
const data = response.body.data.message;
expect(data).toBeDefined();
expect(data).toMatchSnapshot({
createdAt: expect.any(String),
updatedAt: expect.any(String),
});
});
});