add test for joining preexisting room
This commit is contained in:
parent
5c4f92952f
commit
400327a0f1
5 changed files with 54 additions and 3 deletions
|
@ -5,6 +5,7 @@ This repository contains tests for the matrix-react-sdk web app. The tests fire
|
|||
## Current tests
|
||||
- test riot loads (check title)
|
||||
- signup with custom homeserver
|
||||
- join preexisting room
|
||||
|
||||
## Roadmap
|
||||
- get rid of jest, as a test framework won't be helpful to have a continuous flow going from one use case to another (think: do login, create a room, invite a user, ...). a test framework usually assumes the tests are semi-indepedent.
|
||||
|
|
|
@ -82,6 +82,11 @@ async function replace_input_text(input, text) {
|
|||
await input.type(text);
|
||||
}
|
||||
|
||||
async function wait_and_query_selector(page, selector, timeout = 500) {
|
||||
await page.waitForSelector(selector, {visible: true, timeout});
|
||||
return await page.$(selector);
|
||||
}
|
||||
|
||||
// other helpers
|
||||
|
||||
function rnd_int(max) {
|
||||
|
@ -104,6 +109,7 @@ module.exports = {
|
|||
get_outer_html,
|
||||
print_elements,
|
||||
replace_input_text,
|
||||
wait_and_query_selector,
|
||||
rnd_int,
|
||||
riot_url,
|
||||
delay,
|
||||
|
|
12
start.js
12
start.js
|
@ -19,6 +19,7 @@ const helpers = require('./helpers');
|
|||
const assert = require('assert');
|
||||
const do_signup = require('./tests/signup');
|
||||
const test_title = require('./tests/loads');
|
||||
const join_room = require('./tests/join_room');
|
||||
|
||||
global.riotserver = 'http://localhost:8080';
|
||||
global.homeserver = 'http://localhost:8008';
|
||||
|
@ -31,11 +32,20 @@ async function run_tests() {
|
|||
await test_title();
|
||||
process.stdout.write('done\n');
|
||||
|
||||
|
||||
|
||||
const page = await helpers.new_page();
|
||||
const username = 'bruno-' + helpers.rnd_int(10000);
|
||||
const password = 'testtest';
|
||||
process.stdout.write(`* signing up as ${username} ... `);
|
||||
await do_signup(username, password, homeserver);
|
||||
await do_signup(page, username, password, homeserver);
|
||||
process.stdout.write('done\n');
|
||||
|
||||
const room = 'test';
|
||||
process.stdout.write(`* joining room ${room} ... `);
|
||||
await join_room(page, room);
|
||||
process.stdout.write('done\n');
|
||||
|
||||
await end_session();
|
||||
}
|
||||
|
||||
|
|
35
tests/join_room.js
Normal file
35
tests/join_room.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
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 helpers = require('../helpers');
|
||||
const assert = require('assert');
|
||||
|
||||
module.exports = async function join_room(page, room_name) {
|
||||
//TODO: brittle selector
|
||||
const directory_button = await helpers.wait_and_query_selector(page, '.mx_RoleButton[aria-label="Room directory"]');
|
||||
await directory_button.click();
|
||||
|
||||
const room_input = await helpers.wait_and_query_selector(page, '.mx_DirectorySearchBox_input');
|
||||
await helpers.replace_input_text(room_input, room_name);
|
||||
|
||||
const first_room_label = await helpers.wait_and_query_selector(page, '.mx_RoomDirectory_table .mx_RoomDirectory_name:first-child');
|
||||
await first_room_label.click();
|
||||
|
||||
const join_link = await helpers.wait_and_query_selector(page, '.mx_RoomPreviewBar_join_text a');
|
||||
await join_link.click();
|
||||
|
||||
await page.waitForSelector('.mx_MessageComposer');
|
||||
}
|
|
@ -17,8 +17,7 @@ limitations under the License.
|
|||
const helpers = require('../helpers');
|
||||
const assert = require('assert');
|
||||
|
||||
module.exports = async function do_signup(username, password, homeserver) {
|
||||
const page = await helpers.new_page();
|
||||
module.exports = async function do_signup(page, username, password, homeserver) {
|
||||
const console_logs = helpers.log_console(page);
|
||||
const xhr_logs = helpers.log_xhr_requests(page);
|
||||
await page.goto(helpers.riot_url('/#/register'));
|
||||
|
|
Loading…
Reference in a new issue