Skip to content

Commit

Permalink
✅ [#4524] Fixed storybook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Oct 2, 2024
1 parent fa5166f commit 994e06e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {expect, fireEvent, fn, userEvent, waitFor, within} from '@storybook/test';
import selectEvent from 'react-select-event';

import {
mockDMNDecisionDefinitionVersionsGet,
Expand Down Expand Up @@ -232,10 +233,16 @@ export const Empty = {

const [formVarsDropdowns, dmnVarsDropdown] = dropdowns;

await userEvent.selectOptions(formVarsDropdowns, 'Name (name)');
await userEvent.selectOptions(dmnVarsDropdown, 'camundaVar');
await selectEvent.select(formVarsDropdowns, (content, element) => {
return (
content === '(name)' && element.classList.contains('form-variable-dropdown__option__key')
);
});

await expect(formVarsDropdowns.value).toBe('name');
await expect(
formVarsDropdowns.closest('.form-variable-dropdown').querySelector('input[type="hidden"]')
).toHaveValue('name');
await expect(dmnVarsDropdown.value).toBe('camundaVar');
});

Expand Down Expand Up @@ -314,12 +321,14 @@ export const withInitialValues = {
});

await step('Form variable dropdown values', async () => {
const formVariableDropdowns = await canvas.findAllByLabelText('Formuliervariabele');
const formVariableDropdownInputs = await document.querySelectorAll(
'.form-variable-dropdown input[type="hidden"]'
);

await waitFor(async () => {
await expect(formVariableDropdowns[0]).toHaveValue('name');
await expect(formVariableDropdowns[1]).toHaveValue('surname');
await expect(formVariableDropdowns[2]).toHaveValue('canApply');
await expect(formVariableDropdownInputs[0]).toHaveValue('name');
await expect(formVariableDropdownInputs[1]).toHaveValue('surname');
await expect(formVariableDropdownInputs[2]).toHaveValue('canApply');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {useArgs} from '@storybook/preview-api';

import {FormDecorator} from 'components/admin/form_design/story-decorators';

import VariableSelection from './VariableSelection';
import {VARIABLE_SOURCES} from '../form_design/variables/constants';
import VariableSelection from './VariableSelection';

const render = ({name, includeStaticVariables, filter}) => {
const [{value}, updateArgs] = useArgs();
Expand Down

0 comments on commit 994e06e

Please sign in to comment.