-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix form record picker field #11817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix form record picker field #11817
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b7821ad
Make form single record picker fully selectable
thomtrp 8d28200
Enrich record form field on submit
thomtrp 3927495
Create width type
thomtrp 09c0d99
Fix disabled state + handle empty string
thomtrp a32a3cc
Add single record picker test
thomtrp 9e00e5c
Add comment on stop propagation
thomtrp 907f5fe
Add validation step in update and delete record
thomtrp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...-record/record-field/form-types/components/__stories__/FormSingleRecordPicker.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { expect, fn, userEvent, within } from '@storybook/test'; | ||
import { ComponentDecorator, RouterDecorator } from 'twenty-ui/testing'; | ||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; | ||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator'; | ||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; | ||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator'; | ||
import { WorkspaceDecorator } from '~/testing/decorators/WorkspaceDecorator'; | ||
import { graphqlMocks } from '~/testing/graphqlMocks'; | ||
import { MOCKED_STEP_ID } from '~/testing/mock-data/workflow'; | ||
import { FormSingleRecordPicker } from '../FormSingleRecordPicker'; | ||
|
||
const meta: Meta<typeof FormSingleRecordPicker> = { | ||
title: 'UI/Data/Field/Form/Input/FormSingleRecordPicker', | ||
component: FormSingleRecordPicker, | ||
parameters: { | ||
msw: graphqlMocks, | ||
}, | ||
args: {}, | ||
argTypes: {}, | ||
decorators: [ | ||
I18nFrontDecorator, | ||
ObjectMetadataItemsDecorator, | ||
ComponentDecorator, | ||
WorkspaceDecorator, | ||
SnackBarDecorator, | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof FormSingleRecordPicker>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
label: 'Company', | ||
defaultValue: '123e4567-e89b-12d3-a456-426614174000', | ||
objectNameSingular: 'company', | ||
onChange: fn(), | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
await canvas.findByText('Company'); | ||
const dropdown = await canvas.findByRole('button'); | ||
expect(dropdown).toBeVisible(); | ||
}, | ||
}; | ||
|
||
export const WithVariables: Story = { | ||
args: { | ||
label: 'Company', | ||
defaultValue: `{{${MOCKED_STEP_ID}.company.id}}`, | ||
objectNameSingular: 'company', | ||
onChange: fn(), | ||
VariablePicker: () => <div>VariablePicker</div>, | ||
}, | ||
decorators: [ | ||
WorkflowStepDecorator, | ||
ComponentDecorator, | ||
ObjectMetadataItemsDecorator, | ||
SnackBarDecorator, | ||
RouterDecorator, | ||
], | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
await canvas.findByText('Company'); | ||
const variablePicker = await canvas.findByText('VariablePicker'); | ||
expect(variablePicker).toBeVisible(); | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
label: 'Company', | ||
defaultValue: '123e4567-e89b-12d3-a456-426614174000', | ||
objectNameSingular: 'company', | ||
onChange: fn(), | ||
disabled: true, | ||
VariablePicker: () => <div>VariablePicker</div>, | ||
}, | ||
play: async ({ canvasElement, args }) => { | ||
const canvas = within(canvasElement); | ||
|
||
await canvas.findByText('Company'); | ||
const dropdown = canvas.queryByRole('button'); | ||
expect(dropdown).not.toBeInTheDocument(); | ||
|
||
// Variable picker should not be visible when disabled | ||
const variablePicker = canvas.queryByText('VariablePicker'); | ||
expect(variablePicker).not.toBeInTheDocument(); | ||
|
||
// Clicking should not trigger onChange | ||
await userEvent.click(dropdown); | ||
expect(args.onChange).not.toHaveBeenCalled(); | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.