Skip to content

Commit

Permalink
[maykinmedia/open-producten#24] Remove productPrice key from edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Oct 16, 2024
1 parent 4ac23fc commit 982f038
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
10 changes: 0 additions & 10 deletions src/components/ComponentConfiguration.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2305,9 +2305,6 @@ export const ProductPrice: Story = {
const preview = within(canvas.getByTestId('componentPreview'));

await expect(canvas.getByLabelText('Label')).toHaveValue('A productPrice field');
await waitFor(async () => {
await expect(canvas.getByLabelText('Property Name')).toHaveValue('aProductPriceField');
});
await expect(canvas.getByLabelText('Description')).toHaveValue('');
await expect(canvas.getByLabelText('Tooltip')).toHaveValue('');
await expect(canvas.getByLabelText('Show in summary')).toBeChecked();
Expand All @@ -2320,16 +2317,9 @@ export const ProductPrice: Story = {
await userEvent.type(canvas.getByLabelText('Label'), 'Updated preview label');
await expect(await preview.findByText('Updated preview label')).toBeVisible();

// Ensure that the manually entered key is kept instead of derived from the label,
// even when key/label components are not mounted.
const keyInput = canvas.getByLabelText('Property Name');
// fireEvent is deliberate, as userEvent.clear + userEvent.type briefly makes the field
// not have any value, which triggers the generate-key-from-label behaviour.
fireEvent.change(keyInput, {target: {value: 'customKey'}});
await userEvent.click(canvas.getByRole('tab', {name: 'Basic'}));
await userEvent.clear(canvas.getByLabelText('Label'));
await userEvent.type(canvas.getByLabelText('Label'), 'Other label', {delay: 50});
await expect(canvas.getByLabelText('Property Name')).toHaveDisplayValue('customKey');

await step('Submit form', async () => {
await userEvent.click(canvas.getByRole('button', {name: 'Save'}));
Expand Down
4 changes: 0 additions & 4 deletions src/registry/productPrice/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import {
Description,
Hidden,
IsSensitiveData,
Key,
Label,
PresentationConfig,
Registration,
SimpleConditional,
Tooltip,
Translations,
Validate,
useDeriveComponentKey,
} from '@/components/builder';
import {LABELS} from '@/components/builder/messages';
import {TabList, TabPanel, Tabs} from '@/components/formio';
Expand All @@ -28,7 +26,6 @@ import {EditFormDefinition} from '../types';
*/
const EditForm: EditFormDefinition<ProductPriceComponentSchema> = () => {
const intl = useIntl();
const [isKeyManuallySetRef, generatedKey] = useDeriveComponentKey();
const {hasAnyError} = useErrorChecker<ProductPriceComponentSchema>();

Validate.useManageValidatorsTranslations<ProductPriceComponentSchema>(['required']);
Expand Down Expand Up @@ -58,7 +55,6 @@ const EditForm: EditFormDefinition<ProductPriceComponentSchema> = () => {
{/* Basic tab */}
<TabPanel>
<Label />
<Key isManuallySetRef={isKeyManuallySetRef} generatedValue={generatedKey} />
<Description />
<Tooltip />
<PresentationConfig />
Expand Down

0 comments on commit 982f038

Please sign in to comment.