mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 10:15:43 +03:00
make receiving a bit more robust
This commit is contained in:
parent
1fd379b3d2
commit
c5f064e389
1 changed files with 11 additions and 11 deletions
|
@ -18,25 +18,25 @@ const assert = require('assert');
|
|||
|
||||
|
||||
async function getMessageFromTile(eventTile) {
|
||||
const senderElement = await eventTile.$(".mx_SenderProfile_name");
|
||||
const bodyElement = await eventTile.$(".mx_EventTile_body");
|
||||
const sender = await(await senderElement.getProperty("innerText")).jsonValue();
|
||||
const body = await(await bodyElement.getProperty("innerText")).jsonValue();
|
||||
return {sender, body};
|
||||
}
|
||||
|
||||
module.exports = async function receiveMessage(session, message) {
|
||||
session.log.step(`waits to receive message from ${message.sender} in room`);
|
||||
session.log.step(`receives message "${message.body}" from ${message.sender} in room`);
|
||||
// wait for a response to come in that contains the message
|
||||
// crude, but effective
|
||||
await session.page.waitForResponse(async (response) => {
|
||||
const body = await response.text();
|
||||
return body.indexOf(message.body) !== -1;
|
||||
});
|
||||
|
||||
let lastTile = await session.waitAndQuery(".mx_EventTile_last");
|
||||
let lastMessage = await getMessageFromTile(lastTile);
|
||||
assert.equal(lastMessage.body, message.body);
|
||||
assert.equal(lastMessage.sender, message.sender);
|
||||
// wait a bit for the incoming event to be rendered
|
||||
await session.delay(100);
|
||||
let lastTile = await session.query(".mx_EventTile_last");
|
||||
const senderElement = await lastTile.$(".mx_SenderProfile_name");
|
||||
const bodyElement = await lastTile.$(".mx_EventTile_body");
|
||||
const sender = await(await senderElement.getProperty("innerText")).jsonValue();
|
||||
const body = await(await bodyElement.getProperty("innerText")).jsonValue();
|
||||
|
||||
assert.equal(body, message.body);
|
||||
assert.equal(sender, message.sender);
|
||||
session.log.done();
|
||||
}
|
Loading…
Reference in a new issue