From c6ec764b23e0cba09e98631a2bd8b52e0779ace2 Mon Sep 17 00:00:00 2001 From: Paul Rastoin <45004772+prastoin@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:51:46 +0100 Subject: [PATCH] Fix ci-server ci (#18180) --- .../src/generated-metadata/graphql.ts | 62 +++++++++++++------ .../commands/generate-api-key.command.ts | 2 +- .../services/client-config.service.spec.ts | 2 +- .../__tests__/workspace.service.spec.ts | 2 + .../ai/ai-agent/agent.resolver.ts | 6 +- packages/twenty-server/src/main.ts | 1 + ...cessful-find-view.integration-spec.ts.snap | 8 +++ ...failing-agent-creation.integration-spec.ts | 18 +++--- .../failing-agent-update.integration-spec.ts | 4 +- ...cessful-agent-creation.integration-spec.ts | 16 ++--- ...cessful-agent-deletion.integration-spec.ts | 2 +- ...sful-agent-role-update.integration-spec.ts | 6 +- ...uccessful-agent-update.integration-spec.ts | 10 +-- .../upsert-fields-widget.integration-spec.ts | 31 +++++++++- 14 files changed, 116 insertions(+), 54 deletions(-) diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 86cd0776e1..65cb61ccc9 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -2318,6 +2318,7 @@ export type Mutation = { runEvaluationInput: AgentTurn; saveImapSmtpCaldavAccount: ImapSmtpCaldavConnectionSuccess; sendInvitations: SendInvitationsOutput; + setAdminAiModelEnabled: Scalars['Boolean']; setMeteredSubscriptionPrice: BillingUpdateOutput; signIn: AvailableWorkspacesAndAccessTokensOutput; signUp: AvailableWorkspacesAndAccessTokensOutput; @@ -2943,6 +2944,12 @@ export type MutationSendInvitationsArgs = { }; +export type MutationSetAdminAiModelEnabledArgs = { + enabled: Scalars['Boolean']; + modelId: Scalars['String']; +}; + + export type MutationSetMeteredSubscriptionPriceArgs = { priceId: Scalars['String']; }; @@ -6122,11 +6129,6 @@ export type GetConnectedImapSmtpCaldavAccountQueryVariables = Exact<{ export type GetConnectedImapSmtpCaldavAccountQuery = { __typename?: 'Query', getConnectedImapSmtpCaldavAccount: { __typename?: 'ConnectedImapSmtpCaldavAccount', id: string, handle: string, provider: string, accountOwnerId: string, connectionParameters?: { __typename?: 'ImapSmtpCaldavConnectionParameters', IMAP?: { __typename?: 'ConnectionParametersOutput', host: string, port: number, secure?: boolean | null, username?: string | null, password: string } | null, SMTP?: { __typename?: 'ConnectionParametersOutput', host: string, username?: string | null, port: number, secure?: boolean | null, password: string } | null, CALDAV?: { __typename?: 'ConnectionParametersOutput', host: string, username?: string | null, password: string } | null } | null } }; -export type GetAdminAiModelsQueryVariables = Exact<{ [key: string]: never; }>; - - -export type GetAdminAiModelsQuery = { __typename?: 'Query', getAdminAiModels: { __typename?: 'AdminAIModelsOutput', autoEnableNewModels: boolean, models: Array<{ __typename?: 'AdminAIModelConfig', modelId: string, label: string, modelFamily?: ModelFamily | null, inferenceProvider: InferenceProvider, isAvailable: boolean, isAdminEnabled: boolean, deprecated?: boolean | null, isRecommended?: boolean | null }> } }; - export type SetAdminAiModelEnabledMutationVariables = Exact<{ modelId: Scalars['String']; enabled: Scalars['Boolean']; @@ -6135,6 +6137,11 @@ export type SetAdminAiModelEnabledMutationVariables = Exact<{ export type SetAdminAiModelEnabledMutation = { __typename?: 'Mutation', setAdminAiModelEnabled: boolean }; +export type GetAdminAiModelsQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetAdminAiModelsQuery = { __typename?: 'Query', getAdminAiModels: { __typename?: 'AdminAIModelsOutput', autoEnableNewModels: boolean, models: Array<{ __typename?: 'AdminAIModelConfig', modelId: string, label: string, modelFamily?: ModelFamily | null, inferenceProvider: InferenceProvider, isAvailable: boolean, isAdminEnabled: boolean, deprecated?: boolean | null, isRecommended?: boolean | null }> } }; + export type CreateDatabaseConfigVariableMutationVariables = Exact<{ key: Scalars['String']; value: Scalars['JSON']; @@ -12101,6 +12108,38 @@ export function useGetConnectedImapSmtpCaldavAccountLazyQuery(baseOptions?: Apol export type GetConnectedImapSmtpCaldavAccountQueryHookResult = ReturnType; export type GetConnectedImapSmtpCaldavAccountLazyQueryHookResult = ReturnType; export type GetConnectedImapSmtpCaldavAccountQueryResult = Apollo.QueryResult; +export const SetAdminAiModelEnabledDocument = gql` + mutation SetAdminAiModelEnabled($modelId: String!, $enabled: Boolean!) { + setAdminAiModelEnabled(modelId: $modelId, enabled: $enabled) +} + `; +export type SetAdminAiModelEnabledMutationFn = Apollo.MutationFunction; + +/** + * __useSetAdminAiModelEnabledMutation__ + * + * To run a mutation, you first call `useSetAdminAiModelEnabledMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useSetAdminAiModelEnabledMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [setAdminAiModelEnabledMutation, { data, loading, error }] = useSetAdminAiModelEnabledMutation({ + * variables: { + * modelId: // value for 'modelId' + * enabled: // value for 'enabled' + * }, + * }); + */ +export function useSetAdminAiModelEnabledMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(SetAdminAiModelEnabledDocument, options); + } +export type SetAdminAiModelEnabledMutationHookResult = ReturnType; +export type SetAdminAiModelEnabledMutationResult = Apollo.MutationResult; +export type SetAdminAiModelEnabledMutationOptions = Apollo.BaseMutationOptions; export const GetAdminAiModelsDocument = gql` query GetAdminAiModels { getAdminAiModels { @@ -12145,19 +12184,6 @@ export function useGetAdminAiModelsLazyQuery(baseOptions?: Apollo.LazyQueryHookO export type GetAdminAiModelsQueryHookResult = ReturnType; export type GetAdminAiModelsLazyQueryHookResult = ReturnType; export type GetAdminAiModelsQueryResult = Apollo.QueryResult; -export const SetAdminAiModelEnabledDocument = gql` - mutation SetAdminAiModelEnabled($modelId: String!, $enabled: Boolean!) { - setAdminAiModelEnabled(modelId: $modelId, enabled: $enabled) -} - `; -export type SetAdminAiModelEnabledMutationFn = Apollo.MutationFunction; -export function useSetAdminAiModelEnabledMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(SetAdminAiModelEnabledDocument, options); - } -export type SetAdminAiModelEnabledMutationHookResult = ReturnType; -export type SetAdminAiModelEnabledMutationResult = Apollo.MutationResult; -export type SetAdminAiModelEnabledMutationOptions = Apollo.BaseMutationOptions; export const CreateDatabaseConfigVariableDocument = gql` mutation CreateDatabaseConfigVariable($key: String!, $value: JSON!) { createDatabaseConfigVariable(key: $key, value: $value) diff --git a/packages/twenty-server/src/engine/core-modules/api-key/commands/generate-api-key.command.ts b/packages/twenty-server/src/engine/core-modules/api-key/commands/generate-api-key.command.ts index f3d649ffa7..29d08c8862 100644 --- a/packages/twenty-server/src/engine/core-modules/api-key/commands/generate-api-key.command.ts +++ b/packages/twenty-server/src/engine/core-modules/api-key/commands/generate-api-key.command.ts @@ -144,6 +144,6 @@ export class GenerateApiKeyCommand extends CommandRunner { return; } - console.log(`TOKEN:${tokenResult.token}\n`); + this.logger.log(`TOKEN:${tokenResult.token}\n`); } } diff --git a/packages/twenty-server/src/engine/core-modules/client-config/services/client-config.service.spec.ts b/packages/twenty-server/src/engine/core-modules/client-config/services/client-config.service.spec.ts index 446e2921bb..b5969f71cd 100644 --- a/packages/twenty-server/src/engine/core-modules/client-config/services/client-config.service.spec.ts +++ b/packages/twenty-server/src/engine/core-modules/client-config/services/client-config.service.spec.ts @@ -34,7 +34,7 @@ describe('ClientConfigService', () => { { provide: AiModelRegistryService, useValue: { - getAvailableModels: jest.fn().mockReturnValue([]), + getAdminFilteredModels: jest.fn().mockReturnValue([]), }, }, ], diff --git a/packages/twenty-server/src/engine/core-modules/workspace/services/__tests__/workspace.service.spec.ts b/packages/twenty-server/src/engine/core-modules/workspace/services/__tests__/workspace.service.spec.ts index d5aa5bb515..69618c0fd8 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/services/__tests__/workspace.service.spec.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/services/__tests__/workspace.service.spec.ts @@ -29,6 +29,7 @@ import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.ent import { createEmptyAllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-all-flat-entity-maps.constant'; import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service'; import { ObjectMetadataService } from 'src/engine/metadata-modules/object-metadata/object-metadata.service'; +import { AiModelRegistryService } from 'src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service'; import { PermissionsService } from 'src/engine/metadata-modules/permissions/permissions.service'; import { WorkspaceCacheStorageService } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service'; import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service'; @@ -117,6 +118,7 @@ describe('WorkspaceService', () => { ExceptionHandlerService, PermissionsService, FileCorePictureService, + AiModelRegistryService, ].map((service) => ({ provide: service, useValue: {}, diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent/agent.resolver.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent/agent.resolver.ts index 2220089da3..2803ea2dc8 100644 --- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent/agent.resolver.ts +++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent/agent.resolver.ts @@ -2,7 +2,7 @@ import { UseGuards, UseInterceptors } from '@nestjs/common'; import { Args, Mutation, Query } from '@nestjs/graphql'; import { PermissionFlagType } from 'twenty-shared/constants'; -import { isDefined } from 'twenty-shared/utils'; +import { isNonEmptyString } from '@sniptt/guards'; import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; @@ -74,7 +74,7 @@ export class AgentResolver { @Args('input') input: CreateAgentInput, @AuthWorkspace() workspace: WorkspaceEntity, ): Promise { - if (isDefined(input.modelId)) { + if (isNonEmptyString(input.modelId)) { this.aiModelRegistryService.validateModelAvailability( input.modelId, workspace, @@ -96,7 +96,7 @@ export class AgentResolver { @Args('input') input: UpdateAgentInput, @AuthWorkspace() workspace: WorkspaceEntity, ): Promise { - if (isDefined(input.modelId)) { + if (isNonEmptyString(input.modelId)) { this.aiModelRegistryService.validateModelAvailability( input.modelId, workspace, diff --git a/packages/twenty-server/src/main.ts b/packages/twenty-server/src/main.ts index 530e8fc98c..0265aca64d 100644 --- a/packages/twenty-server/src/main.ts +++ b/packages/twenty-server/src/main.ts @@ -22,6 +22,7 @@ import './instrument'; import { settings } from './engine/constants/settings'; import { generateFrontConfig } from './utils/generate-front-config'; +// Trigger const bootstrap = async () => { setPgDateTypeParser(); diff --git a/packages/twenty-server/test/integration/graphql/suites/view/__snapshots__/successful-find-view.integration-spec.ts.snap b/packages/twenty-server/test/integration/graphql/suites/view/__snapshots__/successful-find-view.integration-spec.ts.snap index b062cf5648..46c7bfbdc5 100644 --- a/packages/twenty-server/test/integration/graphql/suites/view/__snapshots__/successful-find-view.integration-spec.ts.snap +++ b/packages/twenty-server/test/integration/graphql/suites/view/__snapshots__/successful-find-view.integration-spec.ts.snap @@ -26,6 +26,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 0, "size": 180, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -37,6 +38,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 1, "size": 100, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -48,6 +50,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 2, "size": 150, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -59,6 +62,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 3, "size": 150, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -70,6 +74,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 4, "size": 150, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -81,6 +86,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 5, "size": 150, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -92,6 +98,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 6, "size": 170, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, { @@ -103,6 +110,7 @@ exports[`successful find view with all sub-relations (e2e) Company View Structur "position": 7, "size": 170, "updatedAt": Any, + "viewFieldGroupId": null, "viewId": Any, }, ], diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-creation.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-creation.integration-spec.ts index f72594e4cb..40db4b4a9d 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-creation.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-creation.integration-spec.ts @@ -32,7 +32,7 @@ describe('Agent creation should fail', () => { input: { label: globalTestContext.existingAgentLabel, prompt: 'Existing agent for testing', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -55,7 +55,7 @@ describe('Agent creation should fail', () => { context: { input: { prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', } as CreateAgentInput, }, }, @@ -64,7 +64,7 @@ describe('Agent creation should fail', () => { context: { input: { label: 'Test Agent Missing Prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', } as CreateAgentInput, }, }, @@ -83,7 +83,7 @@ describe('Agent creation should fail', () => { input: { label: '', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }, }, @@ -93,7 +93,7 @@ describe('Agent creation should fail', () => { input: { label: 'Empty Prompt Agent', prompt: '', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }, }, @@ -114,7 +114,7 @@ describe('Agent creation should fail', () => { input: { label: globalTestContext.existingAgentLabel, prompt: 'Duplicate agent', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }, }, @@ -125,7 +125,7 @@ describe('Agent creation should fail', () => { input: { label: 'Invalid Response Format Agent', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'invalid', } as any, @@ -138,7 +138,7 @@ describe('Agent creation should fail', () => { input: { label: 'JSON Without Schema Agent', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'json', } as any, @@ -151,7 +151,7 @@ describe('Agent creation should fail', () => { input: { label: 'Text With Schema Agent', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'text', schema: { type: 'object' }, diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-update.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-update.integration-spec.ts index a6b9076789..13adff9a2e 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-update.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/failing-agent-update.integration-spec.ts @@ -40,7 +40,7 @@ describe('Agent update should fail', () => { input: { label: globalTestContext.existingAgentLabelForDuplicate, prompt: 'Existing agent for duplicate test', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -55,7 +55,7 @@ describe('Agent update should fail', () => { description: 'Original description', icon: 'IconRobot', prompt: 'Original prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-creation.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-creation.integration-spec.ts index e33b4cce14..860270b888 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-creation.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-creation.integration-spec.ts @@ -23,7 +23,7 @@ describe('Agent creation should succeed', () => { input: { label: 'Test Agent', prompt: 'You are a helpful test assistant', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -36,7 +36,7 @@ describe('Agent creation should succeed', () => { icon: null, description: null, prompt: 'You are a helpful test assistant', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'text' }, roleId: null, isCustom: true, @@ -52,7 +52,7 @@ describe('Agent creation should succeed', () => { icon: 'IconRobot', description: 'A custom agent with all fields specified', prompt: 'You are a specialized assistant for testing', - modelId: 'gpt-4o-mini', + modelId: 'gpt-5.2', responseFormat: { type: 'text' }, modelConfiguration: { webSearch: { @@ -88,7 +88,7 @@ describe('Agent creation should succeed', () => { input: { label: 'JSON Response Agent', prompt: 'Return structured JSON data', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'json', schema: { @@ -127,7 +127,7 @@ describe('Agent creation should succeed', () => { input: { label: 'My Test Agent With Spaces', prompt: 'Testing name computation', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -149,7 +149,7 @@ describe('Agent creation should succeed', () => { icon: ' IconRobot ', description: ' Description with spaces ', prompt: ' Prompt with spaces ', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -192,7 +192,7 @@ describe('Agent creation should succeed', () => { input: { label: 'Agent With Role', prompt: 'Agent with role assignment', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', roleId: createdRoleId, }, }); @@ -203,7 +203,7 @@ describe('Agent creation should succeed', () => { id: expect.any(String), label: 'Agent With Role', prompt: 'Agent with role assignment', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', roleId: createdRoleId, isCustom: true, }); diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-deletion.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-deletion.integration-spec.ts index c6a4fc20c4..8858621923 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-deletion.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-deletion.integration-spec.ts @@ -9,7 +9,7 @@ describe('Agent deletion should succeed', () => { input: { label: 'Agent To Delete', prompt: 'This agent will be deleted', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-role-update.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-role-update.integration-spec.ts index 965d2d589c..8c81f70d4b 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-role-update.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-role-update.integration-spec.ts @@ -74,7 +74,7 @@ describe('Agent role update should succeed', () => { input: { label: 'Agent Without Role', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', }, }); @@ -103,7 +103,7 @@ describe('Agent role update should succeed', () => { input: { label: 'Agent With Initial Role', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', roleId: testRoleId, }, }); @@ -133,7 +133,7 @@ describe('Agent role update should succeed', () => { input: { label: 'Agent With Role To Remove', prompt: 'Test prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', roleId: testRoleId, }, }); diff --git a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-update.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-update.integration-spec.ts index 440af5096c..44a04c1306 100644 --- a/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-update.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/agent/successful-agent-update.integration-spec.ts @@ -15,7 +15,7 @@ describe('Agent update should succeed', () => { description: 'Original description', icon: 'IconRobot', prompt: 'Original prompt', - modelId: 'gpt-4o', + modelId: 'gpt-4.1', responseFormat: { type: 'text' }, evaluationInputs: ['input 1'], }, @@ -100,13 +100,13 @@ describe('Agent update should succeed', () => { expectToFail: false, input: { id: testAgentId, - modelId: 'gpt-4o-mini', + modelId: 'gpt-5.2', }, }); expect(data.updateOneAgent).toMatchObject({ id: testAgentId, - modelId: 'gpt-4o-mini', + modelId: 'gpt-5.2', }); }); @@ -226,7 +226,7 @@ describe('Agent update should succeed', () => { description: 'Updated multiple fields', icon: 'IconBrain', prompt: 'New comprehensive prompt', - modelId: 'gpt-4o-mini', + modelId: 'gpt-5.2', responseFormat: { type: 'json', schema: DEFAULT_TOOL_INPUT_SCHEMA as AgentResponseSchema, @@ -241,7 +241,7 @@ describe('Agent update should succeed', () => { description: 'Updated multiple fields', icon: 'IconBrain', prompt: 'New comprehensive prompt', - modelId: 'gpt-4o-mini', + modelId: 'gpt-5.2', responseFormat: { type: 'json', schema: { type: 'object' }, diff --git a/packages/twenty-server/test/integration/metadata/suites/view-field-group/upsert-fields-widget.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/view-field-group/upsert-fields-widget.integration-spec.ts index 27dbc7a941..82674e7aa4 100644 --- a/packages/twenty-server/test/integration/metadata/suites/view-field-group/upsert-fields-widget.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/view-field-group/upsert-fields-widget.integration-spec.ts @@ -11,6 +11,7 @@ import { v4 as uuidv4 } from 'uuid'; type FieldsWidgetTestSetup = { widgetId: string; viewId: string; + labelIdentifierFieldMetadataId: string | null; viewFields: Array<{ id: string; fieldMetadataId: string; @@ -31,6 +32,7 @@ const VIEW_WITH_FIELDS_AND_GROUPS_GQL_FIELDS = ` `; const fetchFieldsWidgetTestSetup = async (): Promise => { + // TODO refactor should not use global source for that const widgets = await global.testDataSource.query( `SELECT id, configuration->>'viewId' AS "viewId" FROM core."pageLayoutWidget" @@ -46,6 +48,18 @@ const fetchFieldsWidgetTestSetup = async (): Promise => { expect(widgetId).toBeDefined(); expect(viewId).toBeDefined(); + // TODO refactor should not use global source for that + const views = await global.testDataSource.query( + `SELECT v."objectMetadataId", om."labelIdentifierFieldMetadataId" + FROM core."view" v + JOIN core."objectMetadata" om ON om.id = v."objectMetadataId" + WHERE v.id = $1`, + [viewId], + ); + + const labelIdentifierFieldMetadataId = + views[0]?.labelIdentifierFieldMetadataId ?? null; + const { data } = await findCoreViewFields({ viewId, gqlFields: 'id fieldMetadataId position isVisible viewFieldGroupId', @@ -54,7 +68,7 @@ const fetchFieldsWidgetTestSetup = async (): Promise => { const viewFields = data.getCoreViewFields; - return { widgetId, viewId, viewFields }; + return { widgetId, viewId, labelIdentifierFieldMetadataId, viewFields }; }; describe('upsertFieldsWidget', () => { @@ -199,7 +213,12 @@ describe('upsertFieldsWidget', () => { it('should update view field positions and visibility within groups', async () => { const groupId = uuidv4(); - const targetField = testSetup.viewFields[0]; + const targetField = testSetup.viewFields.find( + (field) => + field.fieldMetadataId !== testSetup.labelIdentifierFieldMetadataId, + )!; + + expect(targetField).toBeDefined(); await upsertFieldsWidget({ expectToFail: false, @@ -343,7 +362,13 @@ describe('upsertFieldsWidget', () => { }); it('should update field positions and visibility without groups', async () => { - const targetField = testSetup.viewFields[0]; + const targetField = testSetup.viewFields.find( + (field) => + field.fieldMetadataId !== testSetup.labelIdentifierFieldMetadataId, + )!; + + expect(targetField).toBeDefined(); + const groupId = uuidv4(); // First assign the field to a group so it has a non-null viewFieldGroupId