mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +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) {
|
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) {
|
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
|
// wait for a response to come in that contains the message
|
||||||
// crude, but effective
|
// crude, but effective
|
||||||
await session.page.waitForResponse(async (response) => {
|
await session.page.waitForResponse(async (response) => {
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
return body.indexOf(message.body) !== -1;
|
return body.indexOf(message.body) !== -1;
|
||||||
});
|
});
|
||||||
|
// 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();
|
||||||
|
|
||||||
let lastTile = await session.waitAndQuery(".mx_EventTile_last");
|
assert.equal(body, message.body);
|
||||||
let lastMessage = await getMessageFromTile(lastTile);
|
assert.equal(sender, message.sender);
|
||||||
assert.equal(lastMessage.body, message.body);
|
|
||||||
assert.equal(lastMessage.sender, message.sender);
|
|
||||||
session.log.done();
|
session.log.done();
|
||||||
}
|
}
|
Loading…
Reference in a new issue