Skip to content

Commit 1c9b3e9

Browse files
Fix flake
1 parent 689b7f6 commit 1c9b3e9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

selenium/test/authnz-msg-protocols/amqp10.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ const { tokenFor, openIdConfiguration } = require('../utils')
33
const { reset, expectUser, expectVhost, expectResource, allow, verifyAll } = require('../mock_http_backend')
44
const { open: openAmqp, once: onceAmqp, on: onAmqp, close: closeAmqp } = require('../amqp')
55

6-
var receivedAmqpMessageCount = 0
76
var untilConnectionEstablished = new Promise((resolve, reject) => {
87
onAmqp('connection_open', function(context) {
98
resolve()
109
})
1110
})
1211

13-
onAmqp('message', function (context) {
14-
receivedAmqpMessageCount++
15-
})
1612
onceAmqp('sendable', function (context) {
1713
context.sender.send({body:'first message'})
1814
})
@@ -52,16 +48,21 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
5248
})
5349

5450
it('can open an AMQP 1.0 connection', async function () {
51+
var untilFirstMessageReceived = new Promise((resolve, reject) => {
52+
onAmqp('message', function(context) {
53+
resolve()
54+
})
55+
})
5556
amqp = openAmqp()
5657
await untilConnectionEstablished
57-
var untilMessageReceived = new Promise((resolve, reject) => {
58+
await untilFirstMessageReceived
59+
var untilSecondMessageReceived = new Promise((resolve, reject) => {
5860
onAmqp('message', function(context) {
5961
resolve()
6062
})
6163
})
6264
amqp.sender.send({body:'second message'})
63-
await untilMessageReceived
64-
assert.equal(2, receivedAmqpMessageCount)
65+
await untilSecondMessageReceived
6566
})
6667

6768
after(function () {

0 commit comments

Comments
 (0)