mirror of https://github.com/vector-im/riot-web
wait to receive message from other user
parent
a78c095cf6
commit
1fd379b3d2
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||
|
||||
const signup = require('./tests/signup');
|
||||
const join = require('./tests/join');
|
||||
const sendMessage = require('./tests/send-message');
|
||||
const receiveMessage = require('./tests/receive-message');
|
||||
const createRoom = require('./tests/create-room');
|
||||
const changeRoomSettings = require('./tests/room-settings');
|
||||
const acceptServerNoticesInviteAndConsent = require('./tests/server-notices-consent');
|
||||
|
@ -36,4 +38,6 @@ module.exports = async function scenario(createSession) {
|
|||
await createRoom(alice, room);
|
||||
await changeRoomSettings(alice, {directory: true, visibility: "public_no_guests"});
|
||||
await join(bob, room);
|
||||
await sendMessage(bob, "hi Alice!");
|
||||
await receiveMessage(alice, {sender: "bob", body: "hi Alice!"});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
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`);
|
||||
// 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);
|
||||
session.log.done();
|
||||
}
|
|
@ -32,7 +32,7 @@ module.exports = async function changeRoomSettings(session, settings) {
|
|||
if (typeof settings.directory === "boolean") {
|
||||
session.log.step(`sets directory listing to ${settings.directory}`);
|
||||
const checked = await session.getElementProperty(isDirectory, "checked");
|
||||
assert(typeof checked, "boolean");
|
||||
assert.equal(typeof checked, "boolean");
|
||||
if (checked !== settings.directory) {
|
||||
await isDirectory.click();
|
||||
session.log.done();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
module.exports = async function sendMessage(session, message) {
|
||||
session.log.step(`writes "${message}" in room`);
|
||||
const composer = await session.waitAndQuery('.mx_MessageComposer');
|
||||
await composer.type(message);
|
||||
await composer.press("Enter");
|
||||
session.log.done();
|
||||
}
|
Loading…
Reference in New Issue