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
|
||||
// crude, but effective
|
||||
|
||||
async function assertLastMessage() {
|
||||
async function getLastMessage() {
|
||||
const lastTile = await getLastEventTile(session);
|
||||
const lastMessage = await getMessageFromEventTile(lastTile);
|
||||
await assertMessage(lastMessage, expectedMessage);
|
||||
return getMessageFromEventTile(lastTile);
|
||||
}
|
||||
|
||||
// first try to see if the message is already the last message in the timeline
|
||||
let lastMessage = null;
|
||||
let isExpectedMessage = false;
|
||||
try {
|
||||
assertLastMessage();
|
||||
isExpectedMessage = true;
|
||||
lastMessage = await getLastMessage();
|
||||
isExpectedMessage = lastMessage &&
|
||||
lastMessage.body === expectedMessage.body &&
|
||||
lastMessage.sender === expectedMessage.sender;
|
||||
} catch(ex) {}
|
||||
|
||||
if (!isExpectedMessage) {
|
||||
// first try to see if the message is already the last message in the timeline
|
||||
if (isExpectedMessage) {
|
||||
assertMessage(lastMessage, expectedMessage);
|
||||
} else {
|
||||
await session.page.waitForResponse(async (response) => {
|
||||
if (response.request().url().indexOf("/sync") === -1) {
|
||||
return false;
|
||||
|
@ -75,7 +78,8 @@ module.exports.receiveMessage = async function(session, expectedMessage) {
|
|||
});
|
||||
// wait a bit for the incoming event to be rendered
|
||||
await session.delay(1000);
|
||||
await assertLastMessage();
|
||||
lastMessage = await getLastMessage();
|
||||
assertMessage(lastMessage, expectedMessage);
|
||||
}
|
||||
|
||||
session.log.done();
|
||||
|
|
Loading…
Reference in a new issue