Fix storybook tests on Field Preview (Settings) (#3761)
This commit is contained in:
@ -8,7 +8,7 @@ export const CurrencyFieldDisplay = () => {
|
|||||||
return (
|
return (
|
||||||
<CurrencyDisplay
|
<CurrencyDisplay
|
||||||
amount={
|
amount={
|
||||||
fieldValue.amountMicros ? fieldValue.amountMicros / 1000000 : null
|
fieldValue?.amountMicros ? fieldValue.amountMicros / 1000000 : null
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -69,7 +69,7 @@ export const RecordTableRow = ({ recordId, rowIndex }: RecordTableRowProps) => {
|
|||||||
<RecordTableCellContainer />
|
<RecordTableCellContainer />
|
||||||
</RecordTableCellContext.Provider>
|
</RecordTableCellContext.Provider>
|
||||||
) : (
|
) : (
|
||||||
<td></td>
|
<td key={column.fieldMetadataId}></td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { Field, FieldMetadataType } from '~/generated-metadata/graphql';
|
import { Field, FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
||||||
|
import { RecordStoreDecorator } from '~/testing/decorators/RecordStoreDecorator';
|
||||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
import {
|
import {
|
||||||
@ -17,6 +18,7 @@ const meta: Meta<typeof SettingsObjectFieldPreview> = {
|
|||||||
title: 'Modules/Settings/DataModel/SettingsObjectFieldPreview',
|
title: 'Modules/Settings/DataModel/SettingsObjectFieldPreview',
|
||||||
component: SettingsObjectFieldPreview,
|
component: SettingsObjectFieldPreview,
|
||||||
decorators: [
|
decorators: [
|
||||||
|
RecordStoreDecorator,
|
||||||
ComponentDecorator,
|
ComponentDecorator,
|
||||||
ObjectMetadataItemsDecorator,
|
ObjectMetadataItemsDecorator,
|
||||||
SnackBarDecorator,
|
SnackBarDecorator,
|
||||||
@ -28,6 +30,23 @@ const meta: Meta<typeof SettingsObjectFieldPreview> = {
|
|||||||
objectMetadataId: mockedCompaniesMetadata.node.id,
|
objectMetadataId: mockedCompaniesMetadata.node.id,
|
||||||
},
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
|
records: [
|
||||||
|
{
|
||||||
|
id: `${mockedCompaniesMetadata.node.id}-field-form`,
|
||||||
|
domainName: 'Test',
|
||||||
|
idealCustomerProfile: true,
|
||||||
|
annualRecurringRevenue: {
|
||||||
|
amountMicros: 1000000,
|
||||||
|
currency: 'USD',
|
||||||
|
},
|
||||||
|
updatedAt: '2021-08-05T14:00:00.000Z',
|
||||||
|
linkedinLink: {
|
||||||
|
label: 'LinkedIn',
|
||||||
|
url: 'https://linkedin.com',
|
||||||
|
},
|
||||||
|
employees: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { Decorator } from '@storybook/react';
|
||||||
|
|
||||||
|
import { useSetRecordInStore } from '@/object-record/record-store/hooks/useSetRecordInStore';
|
||||||
|
|
||||||
|
export const RecordStoreDecorator: Decorator = (Story, context) => {
|
||||||
|
const { records } = context.parameters;
|
||||||
|
|
||||||
|
const { setRecords } = useSetRecordInStore();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setRecords(records);
|
||||||
|
});
|
||||||
|
|
||||||
|
return <Story />;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user