Skip to content

Commit

Permalink
test: fix flaky test in literal expression
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Oct 16, 2024
1 parent e9227ec commit 9f72c23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/dmn-js-literal-expression/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"literal expression"
],
"devDependencies": {
"@testing-library/dom": "^10.4.0",
"dmn-font": "^0.6.2",
"inferno-test-utils": "~5.6.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { bootstrapModeler, inject } from 'test/helper';

import { fireEvent, waitFor } from '@testing-library/dom';

import { query as domQuery } from 'min-dom';

import { queryEditor } from 'dmn-js-shared/test/util/EditorUtil';
Expand Down Expand Up @@ -71,10 +73,12 @@ describe('textarea editor', function() {
await act(() => editor.focus());

// when
await changeInput(document.activeElement, 'foo');
changeInput(document.activeElement, 'foo');

// then
expect(viewer.getDecision().decisionLogic.text).to.equal('foo');
await waitFor(() => {
expect(viewer.getDecision().decisionLogic.text).to.equal('foo');
});
}));


Expand Down Expand Up @@ -109,10 +113,12 @@ describe('textarea editor', function() {
await changeFocus(editor);

// when
await changeInput(document.activeElement, 'Var');
changeInput(document.activeElement, 'Var');

// then
expect(getVariablesSpy).to.have.been.called;
await waitFor(() => {
expect(getVariablesSpy).to.have.been.called;
});
});
});

Expand All @@ -124,8 +130,8 @@ describe('textarea editor', function() {
* @param {HTMLElement} input
* @param {string} value
*/
async function changeInput(input, value) {
await act(() => input.textContent = value);
function changeInput(input, value) {
fireEvent.change(input, { target: { textContent: value } });
}

async function changeFocus(editor) {
Expand Down

0 comments on commit 9f72c23

Please sign in to comment.