Files
twenty/packages/twenty-server/test/integration/graphql/suites/object-generated/timeline-activities.integration-spec.ts
T
Guillim b83dc3aaff TimelineActivity migration to morph (#15652)
# TimelineActivity migration to morph


- Creates `timelineActivities2` relations on Company, Dashboard, Note,
Opportunity, Person, Task, Workflow, WorkflowRun, and WorkflowVersion
entities with proper metadata and cascade delete behavior.

It was required to create standard fields as well since the
mapObjectMetadataByUniqueIdentifier needs it. otherwise the fields won't
be considered

- Feature Flag `IS_TIMELINE_ACTIVITY_MIGRATED` necessary to have the two
states in parallel. It is used as a stamp once the migration has been
run

- Migration is done using the coreDataSource. Why ?
even though is unsafe to use, the first implementation of the migration
took forever on each workspace. See [this
commit](https://github.com/twentyhq/twenty/pull/15652/commits/477011e8d7d4c580f79ba7ec4a8fb002a3ec86b2)

The plan for this complex migration is as follows :

![plan](https://github.com/user-attachments/assets/51c63ea6-fb0d-40b4-b99d-3e0b35a204e6)
Note: we will need to rename fields in the release 1.12 (there is no
easy way to do all this in one release)
2025-12-11 14:28:26 +01:00

86 lines
3.1 KiB
TypeScript

import request from 'supertest';
const client = request(`http://localhost:${APP_PORT}`);
describe('timelineActivitiesResolver (e2e)', () => {
it('should find many timelineActivities', () => {
const queryData = {
query: `
query timelineActivities {
timelineActivities {
edges {
node {
happensAt
name
properties
linkedRecordCachedName
linkedRecordId
linkedObjectMetadataId
id
createdAt
updatedAt
deletedAt
workspaceMemberId
targetPersonId
targetCompanyId
targetOpportunityId
targetNoteId
targetTaskId
targetWorkflowId
targetWorkflowVersionId
targetWorkflowRunId
targetPetId
targetSurveyResultId
}
}
}
}
`,
};
return client
.post('/graphql')
.set('Authorization', `Bearer ${APPLE_JANE_ADMIN_ACCESS_TOKEN}`)
.send(queryData)
.expect(200)
.expect((res) => {
expect(res.body.data).toBeDefined();
expect(res.body.errors).toBeUndefined();
})
.expect((res) => {
const data = res.body.data.timelineActivities;
expect(data).toBeDefined();
expect(Array.isArray(data.edges)).toBe(true);
const edges = data.edges;
if (edges.length > 0) {
const timelineActivities = edges[0].node;
expect(timelineActivities).toHaveProperty('happensAt');
expect(timelineActivities).toHaveProperty('name');
expect(timelineActivities).toHaveProperty('properties');
expect(timelineActivities).toHaveProperty('linkedRecordCachedName');
expect(timelineActivities).toHaveProperty('linkedRecordId');
expect(timelineActivities).toHaveProperty('linkedObjectMetadataId');
expect(timelineActivities).toHaveProperty('id');
expect(timelineActivities).toHaveProperty('createdAt');
expect(timelineActivities).toHaveProperty('updatedAt');
expect(timelineActivities).toHaveProperty('deletedAt');
expect(timelineActivities).toHaveProperty('workspaceMemberId');
expect(timelineActivities).toHaveProperty('targetPersonId');
expect(timelineActivities).toHaveProperty('targetCompanyId');
expect(timelineActivities).toHaveProperty('targetOpportunityId');
expect(timelineActivities).toHaveProperty('targetNoteId');
expect(timelineActivities).toHaveProperty('targetTaskId');
expect(timelineActivities).toHaveProperty('targetWorkflowId');
expect(timelineActivities).toHaveProperty('targetWorkflowVersionId');
expect(timelineActivities).toHaveProperty('targetWorkflowRunId');
expect(timelineActivities).toHaveProperty('targetPetId');
expect(timelineActivities).toHaveProperty('targetSurveyResultId');
}
});
});
});