mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
dont assert the first time in receiveMessage, as it will show an ugly assert error while everything is fine, just need to wait longer
This commit is contained in:
parent
9f4cf776c5
commit
af255c6386
1 changed files with 13 additions and 9 deletions
|
@ -47,20 +47,23 @@ module.exports.receiveMessage = async function(session, expectedMessage) {
|
||||||
// wait for a response to come in that contains the message
|
// wait for a response to come in that contains the message
|
||||||
// crude, but effective
|
// crude, but effective
|
||||||
|
|
||||||
async function assertLastMessage() {
|
async function getLastMessage() {
|
||||||
const lastTile = await getLastEventTile(session);
|
const lastTile = await getLastEventTile(session);
|
||||||
const lastMessage = await getMessageFromEventTile(lastTile);
|
return getMessageFromEventTile(lastTile);
|
||||||
await assertMessage(lastMessage, expectedMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// first try to see if the message is already the last message in the timeline
|
let lastMessage = null;
|
||||||
let isExpectedMessage = false;
|
let isExpectedMessage = false;
|
||||||
try {
|
try {
|
||||||
assertLastMessage();
|
lastMessage = await getLastMessage();
|
||||||
isExpectedMessage = true;
|
isExpectedMessage = lastMessage &&
|
||||||
|
lastMessage.body === expectedMessage.body &&
|
||||||
|
lastMessage.sender === expectedMessage.sender;
|
||||||
} catch(ex) {}
|
} catch(ex) {}
|
||||||
|
// first try to see if the message is already the last message in the timeline
|
||||||
if (!isExpectedMessage) {
|
if (isExpectedMessage) {
|
||||||
|
assertMessage(lastMessage, expectedMessage);
|
||||||
|
} else {
|
||||||
await session.page.waitForResponse(async (response) => {
|
await session.page.waitForResponse(async (response) => {
|
||||||
if (response.request().url().indexOf("/sync") === -1) {
|
if (response.request().url().indexOf("/sync") === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -75,7 +78,8 @@ module.exports.receiveMessage = async function(session, expectedMessage) {
|
||||||
});
|
});
|
||||||
// wait a bit for the incoming event to be rendered
|
// wait a bit for the incoming event to be rendered
|
||||||
await session.delay(1000);
|
await session.delay(1000);
|
||||||
await assertLastMessage();
|
lastMessage = await getLastMessage();
|
||||||
|
assertMessage(lastMessage, expectedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.log.done();
|
session.log.done();
|
||||||
|
|
Loading…
Reference in a new issue