Skip to content

Commit 1815059

Browse files
committed
MOBILE-4616 behat: Block Behat for at least 500ms after a press
1 parent dd2ffd0 commit 1815059

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/testing/services/behat-blocking.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ export class TestingBehatBlockingService {
139139
this.unblock(key);
140140
}
141141

142+
/**
143+
* Adds a pending key to the array, and remove it after some time.
144+
*
145+
* @param milliseconds Number of milliseconds to wait before the key is removed.
146+
* @returns Promise resolved after the time has passed.
147+
*/
148+
async wait(milliseconds: number): Promise<void> {
149+
const key = this.block();
150+
await CoreWait.wait(milliseconds);
151+
this.unblock(key);
152+
}
153+
142154
/**
143155
* It would be really beautiful if you could detect CSS transitions and animations, that would
144156
* cover almost everything, but sadly there is no way to do this because the transitionstart

src/testing/services/behat-runtime.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export class TestingBehatRuntimeService {
219219
// Click button
220220
await TestingBehatDomUtils.pressElement(foundButton);
221221

222+
// Block Behat for at least 500ms, WS calls or DOM changes might not begin immediately.
223+
TestingBehatBlocking.wait(500);
224+
222225
return 'OK';
223226
}
224227

@@ -446,6 +449,9 @@ export class TestingBehatRuntimeService {
446449

447450
await TestingBehatDomUtils.pressElement(found);
448451

452+
// Block Behat for at least 500ms, WS calls or DOM changes might not begin immediately.
453+
TestingBehatBlocking.wait(500);
454+
449455
return 'OK';
450456
} catch (error) {
451457
return 'ERROR: ' + error.message;

0 commit comments

Comments
 (0)