|
1 | 1 | import {useArgs} from '@storybook/preview-api';
|
| 2 | +import {expect, userEvent, waitFor, within} from '@storybook/test'; |
2 | 3 | import {produce} from 'immer';
|
3 | 4 | import set from 'lodash/set';
|
4 | 5 |
|
@@ -197,3 +198,96 @@ export const EvaluateDMN = {
|
197 | 198 | },
|
198 | 199 | },
|
199 | 200 | };
|
| 201 | + |
| 202 | +export const EvaluateDMNWithInitialErrors = { |
| 203 | + render, |
| 204 | + name: 'Evaluate DMN with initial errors', |
| 205 | + args: { |
| 206 | + prefixText: 'Action', |
| 207 | + |
| 208 | + action: { |
| 209 | + component: '', |
| 210 | + variable: 'bar', |
| 211 | + formStep: '', |
| 212 | + formStepUuid: '', |
| 213 | + |
| 214 | + action: { |
| 215 | + config: { |
| 216 | + pluginId: '', |
| 217 | + decisionDefinitionId: '', |
| 218 | + }, |
| 219 | + type: 'evaluate-dmn', |
| 220 | + value: '', |
| 221 | + }, |
| 222 | + }, |
| 223 | + errors: { |
| 224 | + action: { |
| 225 | + config: { |
| 226 | + pluginId: 'This field is required.', |
| 227 | + decisionDefinitionId: 'This field is required.', |
| 228 | + }, |
| 229 | + }, |
| 230 | + }, |
| 231 | + availableDMNPlugins: [ |
| 232 | + {id: 'camunda7', label: 'Camunda 7'}, |
| 233 | + {id: 'some-other-engine', label: 'Some other engine'}, |
| 234 | + ], |
| 235 | + availableFormVariables: [ |
| 236 | + {type: 'textfield', key: 'name', name: 'Name'}, |
| 237 | + {type: 'textfield', key: 'surname', name: 'Surname'}, |
| 238 | + {type: 'number', key: 'income', name: 'Income'}, |
| 239 | + {type: 'checkbox', key: 'canApply', name: 'Can apply?'}, |
| 240 | + ], |
| 241 | + }, |
| 242 | + decorators: [FormDecorator], |
| 243 | + |
| 244 | + parameters: { |
| 245 | + msw: { |
| 246 | + handlers: [ |
| 247 | + mockDMNDecisionDefinitionsGet({ |
| 248 | + camunda7: [ |
| 249 | + { |
| 250 | + id: 'approve-payment', |
| 251 | + label: 'Approve payment', |
| 252 | + }, |
| 253 | + { |
| 254 | + id: 'invoiceClassification', |
| 255 | + label: 'Invoice Classification', |
| 256 | + }, |
| 257 | + ], |
| 258 | + 'some-other-engine': [{id: 'some-definition-id', label: 'Some definition id'}], |
| 259 | + }), |
| 260 | + mockDMNDecisionDefinitionVersionsGet, |
| 261 | + ], |
| 262 | + }, |
| 263 | + }, |
| 264 | + play: async ({canvasElement, step}) => { |
| 265 | + const canvas = within(canvasElement); |
| 266 | + |
| 267 | + step('Verify that global DMN config error is shown', () => { |
| 268 | + expect( |
| 269 | + canvas.getByRole('listitem', {text: 'De DMN-instellingen zijn niet geldig.'}) |
| 270 | + ).toBeVisible(); |
| 271 | + }); |
| 272 | + |
| 273 | + step('Open configuration modal', async () => { |
| 274 | + await userEvent.click(canvas.getByRole('button', {name: 'Instellen'})); |
| 275 | + |
| 276 | + const dialog = within(canvas.getByRole('dialog')); |
| 277 | + |
| 278 | + const pluginDropdown = dialog.getByLabelText('Plugin'); |
| 279 | + const decisionDefDropdown = dialog.getByLabelText('Beslisdefinitie-ID'); |
| 280 | + |
| 281 | + // Mark dropdowns as touched |
| 282 | + await userEvent.click(pluginDropdown); |
| 283 | + await userEvent.click(decisionDefDropdown); |
| 284 | + await userEvent.tab(); |
| 285 | + |
| 286 | + await waitFor(async () => { |
| 287 | + const errorMessages = await dialog.getAllByRole('listitem'); |
| 288 | + |
| 289 | + await expect(errorMessages.length).toBe(2); |
| 290 | + }); |
| 291 | + }); |
| 292 | + }, |
| 293 | +}; |
0 commit comments