Fix more tests 2 (#18293)

## Summary
- Migrate more hand-written test mocks to auto-generated data from a
real Twenty instance
- Add generators for views, billing plans, API keys; extend record
generator for workspace members, favorites, connected accounts, calendar
events
- Remove 9 hand-written mock files replaced by generated equivalents
- Update 16 test/story files to use generated data
- Fix WorkflowEditActionEmailBase story assertion to match configured
recipient email

## Test plan
- [x] Lint, typecheck, unit tests pass
- [ ] Storybook tests pass in CI
This commit is contained in:
Charles Bochet
2026-02-27 23:11:56 +01:00
committed by GitHub
parent cfad24da48
commit 9342b16aad
37 changed files with 30101 additions and 3139 deletions
@@ -101,23 +101,31 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle successfull record deletion 2`] = `
{
"__typename": "Company",
"accountOwner": null,
"accountOwner": {},
"accountOwnerId": "20202020-1553-45c6-a028-5a9064cce07f",
"address": {
"__typename": "Address",
"addressCity": "Dublin",
"addressCountry": "Ireland",
"addressCity": "Denver",
"addressCountry": "",
"addressLat": null,
"addressLng": null,
"addressPostcode": null,
"addressState": null,
"addressStreet1": "Eutaw Street",
"addressStreet2": null,
"addressPostcode": "",
"addressState": "",
"addressStreet1": "",
"addressStreet2": "",
},
"createdAt": "2025-02-16T08:21:51.715Z",
"annualRecurringRevenue": {
"__typename": "Currency",
"amountMicros": null,
"currencyCode": null,
},
"attachments": [],
"caredForPets": [],
"createdAt": "2026-02-27T01:17:29.464Z",
"createdBy": {
"__typename": "Actor",
"context": {},
"name": "Tim Apple",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
@@ -125,28 +133,63 @@ exports[`useDeleteOneRecord B. Starting from filled cache 1. Should handle succe
"domainName": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com",
"primaryLinkUrl": "housecallpro.com",
"secondaryLinks": [],
},
"employees": null,
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
"linkedinLink": {
"employees": 894,
"favorites": [],
"id": "20202020-a000-4485-94de-70c2a98daef2",
"idealCustomerProfile": false,
"introVideo": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
"name": "Linkedin",
"noteTargets": [],
"opportunities": [
"linkedinLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com/company/housecallpro",
"secondaryLinks": [],
},
"name": "Housecall Pro",
"noteTargets": [
{},
],
"opportunities": [],
"people": [
{},
{},
],
"position": 1,
"taskTargets": [],
"position": 442,
"previousEmployees": [],
"tagline": "",
"taskTargets": [
{},
],
"timelineActivities": [
{},
{},
{},
{},
{},
],
"updatedAt": "2026-02-27T01:17:29.464Z",
"updatedBy": {
"__typename": "Actor",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
"visaSponsorship": false,
"workPolicy": [],
"xLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
}
`;
@@ -243,23 +286,31 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optimistic cache on record deletion 2`] = `
{
"__typename": "Company",
"accountOwner": null,
"accountOwner": {},
"accountOwnerId": "20202020-1553-45c6-a028-5a9064cce07f",
"address": {
"__typename": "Address",
"addressCity": "Dublin",
"addressCountry": "Ireland",
"addressCity": "Denver",
"addressCountry": "",
"addressLat": null,
"addressLng": null,
"addressPostcode": null,
"addressState": null,
"addressStreet1": "Eutaw Street",
"addressStreet2": null,
"addressPostcode": "",
"addressState": "",
"addressStreet1": "",
"addressStreet2": "",
},
"createdAt": "2025-02-16T08:21:51.715Z",
"annualRecurringRevenue": {
"__typename": "Currency",
"amountMicros": null,
"currencyCode": null,
},
"attachments": [],
"caredForPets": [],
"createdAt": "2026-02-27T01:17:29.464Z",
"createdBy": {
"__typename": "Actor",
"context": {},
"name": "Tim Apple",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
@@ -267,28 +318,63 @@ exports[`useDeleteOneRecord B. Starting from filled cache 2. Should handle optim
"domainName": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com",
"primaryLinkUrl": "housecallpro.com",
"secondaryLinks": [],
},
"employees": null,
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
"linkedinLink": {
"employees": 894,
"favorites": [],
"id": "20202020-a000-4485-94de-70c2a98daef2",
"idealCustomerProfile": false,
"introVideo": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
"name": "Linkedin",
"noteTargets": [],
"opportunities": [
"linkedinLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com/company/housecallpro",
"secondaryLinks": [],
},
"name": "Housecall Pro",
"noteTargets": [
{},
],
"opportunities": [],
"people": [
{},
{},
],
"position": 1,
"taskTargets": [],
"position": 442,
"previousEmployees": [],
"tagline": "",
"taskTargets": [
{},
],
"timelineActivities": [
{},
{},
{},
{},
{},
],
"updatedAt": "2026-02-27T01:17:29.464Z",
"updatedBy": {
"__typename": "Actor",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
"visaSponsorship": false,
"workPolicy": [],
"xLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
}
`;
@@ -385,23 +471,31 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optimistic cache rollback on record deletion failure 2`] = `
{
"__typename": "Company",
"accountOwner": null,
"accountOwner": {},
"accountOwnerId": "20202020-1553-45c6-a028-5a9064cce07f",
"address": {
"__typename": "Address",
"addressCity": "Dublin",
"addressCountry": "Ireland",
"addressCity": "Denver",
"addressCountry": "",
"addressLat": null,
"addressLng": null,
"addressPostcode": null,
"addressState": null,
"addressStreet1": "Eutaw Street",
"addressStreet2": null,
"addressPostcode": "",
"addressState": "",
"addressStreet1": "",
"addressStreet2": "",
},
"createdAt": "2025-02-16T08:21:51.715Z",
"annualRecurringRevenue": {
"__typename": "Currency",
"amountMicros": null,
"currencyCode": null,
},
"attachments": [],
"caredForPets": [],
"createdAt": "2026-02-27T01:17:29.464Z",
"createdBy": {
"__typename": "Actor",
"context": {},
"name": "Tim Apple",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
@@ -409,27 +503,62 @@ exports[`useDeleteOneRecord B. Starting from filled cache 3. Should handle optim
"domainName": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com",
"primaryLinkUrl": "housecallpro.com",
"secondaryLinks": [],
},
"employees": null,
"id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
"linkedinLink": {
"employees": 894,
"favorites": [],
"id": "20202020-a000-4485-94de-70c2a98daef2",
"idealCustomerProfile": false,
"introVideo": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
"name": "Linkedin",
"noteTargets": [],
"opportunities": [
"linkedinLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "https://linkedin.com/company/housecallpro",
"secondaryLinks": [],
},
"name": "Housecall Pro",
"noteTargets": [
{},
],
"opportunities": [],
"people": [
{},
{},
],
"position": 1,
"taskTargets": [],
"position": 442,
"previousEmployees": [],
"tagline": "",
"taskTargets": [
{},
],
"timelineActivities": [
{},
{},
{},
{},
{},
],
"updatedAt": "2026-02-27T01:17:29.464Z",
"updatedBy": {
"__typename": "Actor",
"context": null,
"name": "Tim A",
"source": "MANUAL",
"workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
},
"visaSponsorship": false,
"workPolicy": [],
"xLink": {
"__typename": "Links",
"primaryLinkLabel": "",
"primaryLinkUrl": "",
"secondaryLinks": [],
},
}
`;
@@ -9,7 +9,7 @@ import { type MockedResponse } from '@apollo/client/testing';
import { InMemoryTestingCacheInstance } from '~/testing/cache/inMemoryTestingCacheInstance';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
import { allMockCompanyRecordsWithRelation } from '~/testing/mock-data/companiesWithRelations';
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
@@ -24,15 +24,19 @@ const flatPersonRecords = mockedPersonRecords.map((record) =>
getRecordFromRecordNode({ recordNode: record }),
);
const flatCompanyRecords = mockedCompanyRecords.map((record) =>
getRecordFromRecordNode({ recordNode: record }),
);
describe('useDeleteOneRecord', () => {
const matchingCompanyId = allMockCompanyRecordsWithRelation[0].id;
const matchingCompanyId = flatCompanyRecords[0].id;
const personRecord = {
...flatPersonRecords[0],
deletedAt: null,
companyId: matchingCompanyId,
company: { ...allMockCompanyRecordsWithRelation[0] },
company: { ...flatCompanyRecords[0] },
};
const relatedCompanyRecord = allMockCompanyRecordsWithRelation[0];
const relatedCompanyRecord = flatCompanyRecords[0];
const personObjectMetadataItem = getMockObjectMetadataItemOrThrow('person');
const companyObjectMetadataItem = getMockObjectMetadataItemOrThrow('company');
const objectMetadataItems = generatedMockObjectMetadataItems;
@@ -199,7 +203,7 @@ describe('useDeleteOneRecord', () => {
initialRecordsInCache: [
{
objectMetadataItem: companyObjectMetadataItem,
records: allMockCompanyRecordsWithRelation,
records: flatCompanyRecords,
},
{
objectMetadataItem: personObjectMetadataItem,