Skip to content

Commit 618b9af

Browse files
committed
test: use waitFor instead of fixed waiting time
1 parent c3cc4df commit 618b9af

File tree

3 files changed

+33
-45
lines changed

3 files changed

+33
-45
lines changed

test/spec/provider/zeebe/BusinessRuleImplementationProps.spec.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import TestContainer from 'mocha-test-container-support';
22

33
import {
4-
act
4+
act,
5+
waitFor
56
} from '@testing-library/preact';
67

78
import {
@@ -367,19 +368,14 @@ function getTaskHeaders(element) {
367368
return getExtensionElementsList(businessObject, 'zeebe:TaskHeaders')[ 0 ];
368369
}
369370

370-
async function expectEdited(container, exists) {
371+
function expectEdited(container, exists) {
372+
return waitFor(() => {
373+
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
371374

372-
await wait(50);
373-
374-
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
375-
376-
if (exists) {
377-
expect(indicator).to.exist;
378-
} else {
379-
expect(indicator).not.to.exist;
380-
}
375+
if (exists) {
376+
expect(indicator).to.exist;
377+
} else {
378+
expect(indicator).not.to.exist;
379+
}
380+
});
381381
}
382-
383-
function wait(ms) {
384-
return new Promise(resolve => setTimeout(resolve, ms));
385-
}

test/spec/provider/zeebe/ScriptImplementationProps.spec.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import TestContainer from 'mocha-test-container-support';
22

33
import {
4-
act
4+
act,
5+
waitFor
56
} from '@testing-library/preact';
67

78
import {
@@ -346,19 +347,14 @@ function getTaskHeaders(element) {
346347
return getExtensionElementsList(businessObject, 'zeebe:TaskHeaders')[ 0 ];
347348
}
348349

349-
async function expectEdited(container, exists) {
350+
function expectEdited(container, exists) {
351+
return waitFor(() => {
352+
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
350353

351-
await wait(50);
352-
353-
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
354-
355-
if (exists) {
356-
expect(indicator).to.exist;
357-
} else {
358-
expect(indicator).not.to.exist;
359-
}
354+
if (exists) {
355+
expect(indicator).to.exist;
356+
} else {
357+
expect(indicator).not.to.exist;
358+
}
359+
});
360360
}
361-
362-
function wait(ms) {
363-
return new Promise(resolve => setTimeout(resolve, ms));
364-
}

test/spec/provider/zeebe/UserTaskImplementationProps.spec.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import TestContainer from 'mocha-test-container-support';
22

33
import {
4-
act
4+
act,
5+
waitFor
56
} from '@testing-library/preact';
67

78
import {
@@ -242,19 +243,14 @@ function getZeebeUserTask(element) {
242243
}
243244

244245

245-
async function expectEdited(container, exists) {
246+
function expectEdited(container, exists) {
247+
return waitFor(() => {
248+
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
246249

247-
await wait(50);
248-
249-
const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);
250-
251-
if (exists) {
252-
expect(indicator).to.exist;
253-
} else {
254-
expect(indicator).not.to.exist;
255-
}
250+
if (exists) {
251+
expect(indicator).to.exist;
252+
} else {
253+
expect(indicator).not.to.exist;
254+
}
255+
});
256256
}
257-
258-
function wait(ms) {
259-
return new Promise(resolve => setTimeout(resolve, ms));
260-
}

0 commit comments

Comments
 (0)