Fix broken storybook tests on SettingsPreview

This commit is contained in:
Charles Bochet 2024-03-01 12:55:48 +01:00
parent 0c2c57ab9b
commit b69fed9023
3 changed files with 196 additions and 11 deletions

View File

@ -9,6 +9,7 @@ import {
} from '@/object-record/record-field/types/FieldMetadata';
import {
mockedCompaniesMetadata,
mockedCustomMetadata,
mockedPeopleMetadata,
} from '~/testing/mock-data/metadata';
@ -18,11 +19,17 @@ export const mockedPersonObjectMetadataItem = {
...mockedPeopleMetadata.node,
fields: mockedPeopleMetadata.node.fields.edges.map(({ node }) => node),
};
export const mockedCompanyObjectMetadataItem = {
...mockedCompaniesMetadata.node,
fields: mockedCompaniesMetadata.node.fields.edges.map(({ node }) => node),
};
export const mockedCustomObjectMetadataItem = {
...mockedCustomMetadata.node,
fields: mockedCustomMetadata.node.fields.edges.map(({ node }) => node),
};
export const textfieldDefinition: FieldDefinition<FieldTextMetadata> = {
fieldMetadataId,
label: 'User Name',

View File

@ -101,11 +101,13 @@ export const Relation: Story = {
},
};
export const CustomObject: Story = {
args: {
fieldMetadataItem: mockedCompanyObjectMetadataItem.fields.find(
({ isCustom }) => isCustom,
),
objectMetadataItem: mockedCompanyObjectMetadataItem,
},
};
// Todo: re-enable this test once useObjectMetadataItem has been split and refactored into smaller functions.
// Right now, as the workspace is not set, the hook things the user is not logged in and it is not possible to have a custom object
// export const Custom: Story = {
// args: {
// fieldMetadataItem: mockedCustomObjectMetadataItem.fields.find(
// ({ type }) => type === FieldMetadataType.Text,
// ),
// objectMetadataItem: mockedCustomObjectMetadataItem,
// },
// };

View File

@ -1019,7 +1019,7 @@ export const mockedCompaniesMetadata = {
label: 'Address',
description: 'The company address',
icon: 'IconMap',
isCustom: false,
isCustom: true,
isActive: true,
isSystem: false,
isNullable: true,
@ -1114,7 +1114,7 @@ export const mockedCompaniesMetadata = {
label: 'Industry',
description: 'The industry the company is involved in',
icon: 'IconUsers',
isCustom: true,
isCustom: false,
isActive: true,
isSystem: false,
isNullable: true,
@ -4755,6 +4755,181 @@ export const mockedAPIKeysMetadata = {
},
};
export const mockedCustomMetadata = {
__typename: 'objectEdge',
node: {
__typename: 'object',
id: 'd5c37777-3450-4e30-80a2-66853331ca90',
dataSourceId: 'cabbcaa6-05d6-41f4-920f-9144172a4f08',
nameSingular: 'myCustom',
namePlural: 'myCustoms',
labelSingular: 'My Custom',
labelPlural: 'My Customs',
description: 'A custom object example',
icon: 'IconRobot',
isCustom: false,
isActive: true,
isSystem: true,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
labelIdentifierFieldMetadataId: null,
imageIdentifierFieldMetadataId: null,
fields: {
__typename: 'ObjectFieldsConnection',
edges: [
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: 'bdda452a-c123-4fa3-8543-d04c2c43836f',
type: FieldMetadataType.DateTime,
name: 'revokedAt',
label: 'Revocation date',
description: 'ApiKey revocation date',
icon: 'IconCalendar',
isCustom: false,
isActive: true,
isSystem: true,
isNullable: true,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: null,
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: 'dd217f48-d1bf-4451-9b8d-e06feb7365f9',
type: FieldMetadataType.DateTime,
name: 'createdAt',
label: 'Creation date',
description: null,
icon: 'IconCalendar',
isCustom: false,
isActive: true,
isSystem: true,
isNullable: false,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: {
type: 'now',
},
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: '3fd655ef-3dc6-4edf-84cf-3f398150412b',
type: FieldMetadataType.DateTime,
name: 'expiresAt',
label: 'Expiration date',
description: 'ApiKey expiration date',
icon: 'IconCalendar',
isCustom: false,
isActive: true,
isSystem: true,
isNullable: false,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: null,
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: '5f404704-d084-420e-a2bf-ab3108da12ae',
type: FieldMetadataType.Text,
name: 'name',
label: 'Name',
description: 'ApiKey name',
icon: 'IconLink',
isCustom: false,
isActive: true,
isSystem: true,
isNullable: false,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: {
value: '',
},
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: '948db156-f5de-4ddf-ad95-34fabc7cb273',
type: FieldMetadataType.DateTime,
name: 'updatedAt',
label: 'Update date',
description: null,
icon: 'IconCalendar',
isCustom: false,
isActive: true,
isSystem: true,
isNullable: false,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: {
type: 'now',
},
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: '2204f9d1-274d-4bd5-be9c-3598da520df0',
type: FieldMetadataType.Uuid,
name: 'id',
label: 'Id',
description: null,
icon: null,
isCustom: false,
isActive: true,
isSystem: true,
isNullable: false,
createdAt: '2023-12-15T15:29:39.070Z',
updatedAt: '2023-12-15T15:29:39.070Z',
fromRelationMetadata: null,
toRelationMetadata: null,
options: [],
defaultValue: {
type: FieldMetadataType.Uuid,
},
},
},
],
pageInfo: {
__typename: 'PageInfo',
hasNextPage: false,
hasPreviousPage: false,
startCursor: 'YXJyYXljb25uZWN0aW9uOjA=',
endCursor: 'YXJyYXljb25uZWN0aW9uOjU=',
},
totalCount: 6,
},
},
};
export const mockedComments = {
__typename: 'objectEdge',
node: {
@ -6860,6 +7035,7 @@ export const mockedObjectMetadataItems = {
mockedWebhooksMetadata,
mockedAttachmentsMetadata,
mockedMessageParticipantsMetadata,
mockedCustomMetadata,
],
pageInfo: {
__typename: 'PageInfo',
@ -6868,5 +7044,5 @@ export const mockedObjectMetadataItems = {
startCursor: 'YXJyYXljb25uZWN0aW9uOjA=',
endCursor: 'YXJyYXljb25uZWN0aW9uOjk=',
},
totalCount: 18,
totalCount: 19,
};