Skip to content

Commit

Permalink
test: use waitFor instead of fixed waiting time
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Feb 24, 2025
1 parent c3cc4df commit 618b9af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 45 deletions.
26 changes: 11 additions & 15 deletions test/spec/provider/zeebe/BusinessRuleImplementationProps.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import TestContainer from 'mocha-test-container-support';

import {
act
act,
waitFor
} from '@testing-library/preact';

import {
Expand Down Expand Up @@ -367,19 +368,14 @@ function getTaskHeaders(element) {
return getExtensionElementsList(businessObject, 'zeebe:TaskHeaders')[ 0 ];
}

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

await wait(50);

const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);

if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
});
}

function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
26 changes: 11 additions & 15 deletions test/spec/provider/zeebe/ScriptImplementationProps.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import TestContainer from 'mocha-test-container-support';

import {
act
act,
waitFor
} from '@testing-library/preact';

import {
Expand Down Expand Up @@ -346,19 +347,14 @@ function getTaskHeaders(element) {
return getExtensionElementsList(businessObject, 'zeebe:TaskHeaders')[ 0 ];
}

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

await wait(50);

const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);

if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
});
}

function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
26 changes: 11 additions & 15 deletions test/spec/provider/zeebe/UserTaskImplementationProps.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import TestContainer from 'mocha-test-container-support';

import {
act
act,
waitFor
} from '@testing-library/preact';

import {
Expand Down Expand Up @@ -242,19 +243,14 @@ function getZeebeUserTask(element) {
}


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

await wait(50);

const indicator = domQuery(`${GROUP_SELECTOR} .bio-properties-panel-dot`, container);

if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
if (exists) {
expect(indicator).to.exist;
} else {
expect(indicator).not.to.exist;
}
});
}

function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

0 comments on commit 618b9af

Please sign in to comment.