From 8ee7623d9010dc5fa1e35404084747c5b97953f6 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 25 Sep 2018 18:01:10 +0100 Subject: [PATCH 1/9] current tests need riot develop to set a room alias without a domain name --- riot/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riot/install.sh b/riot/install.sh index 209926d4c5..9b5a0a0757 100755 --- a/riot/install.sh +++ b/riot/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -RIOT_BRANCH=master +RIOT_BRANCH=develop BASE_DIR=$(readlink -f $(dirname $0)) if [ -d $BASE_DIR/riot-web ]; then From 1147508c345d7744185ec9619ab7e1e4cc4d9356 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 27 Sep 2018 18:09:27 +0100 Subject: [PATCH 2/9] list of tests we want to write --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000000..4cbcba801b --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +join a peekable room by directory +join a peekable room by invite +join a non-peekable room by directory +join a non-peekable room by invite From b2bd134945a907c6bdd29d98785c33737a13db58 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 8 Oct 2018 16:58:01 +0200 Subject: [PATCH 3/9] add config file instructions to run with --riot-url --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index acfeed8257..4f4f9217e3 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ It's important to always stop and start synapse before each run of the tests to start.js accepts the following parameters that can help running the tests locally: - `--no-logs` dont show the excessive logging show by default (meant for CI), just where the test failed. - - `--riot-url ` don't use the riot copy and static server provided by the tests, but use a running server like the webpack watch server to run the tests against. Make sure to have `welcomeUserId` disabled in your config as the tests assume there is no riot-bot currently. + - `--riot-url ` don't use the riot copy and static server provided by the tests, but use a running server like the webpack watch server to run the tests against. Make sure to have the following local config: + - `welcomeUserId` disabled as the tests assume there is no riot-bot currently. Make sure to set the default homeserver to + - `"default_hs_url": "http://localhost:5005"`, to use the e2e tests synapse (the tests use the default HS to run against atm) + - `"feature_lazyloading": "labs"`, currently assumes lazy loading needs to be turned on in the settings, will change soon. - `--slow-mo` run the tests a bit slower, so it's easier to follow along with `--windowed`. - `--windowed` run the tests in an actual browser window Try to limit interacting with the windows while the tests are running. Hovering over the window tends to fail the tests, dragging the title bar should be fine though. - `--dev-tools` open the devtools in the browser window, only applies if `--windowed` is set as well. From 1a2254677c91dc291180a26a5f736bb3e852e6ca Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 9 Oct 2018 15:15:03 +0200 Subject: [PATCH 4/9] test leaving members disappear from memberlist --- src/rest/multi.js | 7 ++++++- src/rest/session.js | 14 +++++++++++++- src/scenarios/lazy-loading.js | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/rest/multi.js b/src/rest/multi.js index 3d24245ddf..b930a27c1e 100644 --- a/src/rest/multi.js +++ b/src/rest/multi.js @@ -59,6 +59,11 @@ module.exports = class RestMultiSession { this.log.done(); return new RestMultiRoom(rooms, roomIdOrAlias, this.log); } + + room(roomIdOrAlias) { + const rooms = this.sessions.map(s => s.room(roomIdOrAlias)); + return new RestMultiRoom(rooms, roomIdOrAlias, this.log); + } } class RestMultiRoom { @@ -82,7 +87,7 @@ class RestMultiRoom { this.log.step(`leave ${this.roomIdOrAlias}`) await Promise.all(this.rooms.map(async (r) => { r.log.mute(); - await r.leave(message); + await r.leave(); r.log.unmute(); })); this.log.done(); diff --git a/src/rest/session.js b/src/rest/session.js index 21922a69f1..de05cd4b5c 100644 --- a/src/rest/session.js +++ b/src/rest/session.js @@ -24,6 +24,7 @@ module.exports = class RestSession { this.log = new Logger(credentials.userId); this._credentials = credentials; this._displayName = null; + this._rooms = {}; } userId() { @@ -51,7 +52,18 @@ module.exports = class RestSession { this.log.step(`joins ${roomIdOrAlias}`); const {room_id} = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`); this.log.done(); - return new RestRoom(this, room_id, this.log); + const room = new RestRoom(this, room_id, this.log); + this._rooms[room_id] = room; + this._rooms[roomIdOrAlias] = room; + return room; + } + + room(roomIdOrAlias) { + if (this._rooms.hasOwnProperty(roomIdOrAlias)) { + return this._rooms[roomIdOrAlias]; + } else { + throw new Error(`${this._credentials.userId} is not in ${roomIdOrAlias}`); + } } async createRoom(name, options) { diff --git a/src/scenarios/lazy-loading.js b/src/scenarios/lazy-loading.js index c33e83215c..7fd67153f0 100644 --- a/src/scenarios/lazy-loading.js +++ b/src/scenarios/lazy-loading.js @@ -40,6 +40,10 @@ module.exports = async function lazyLoadingScenarios(alice, bob, charlies) { await checkMemberList(alice, charly1to5); await joinCharliesWhileAliceIsOffline(alice, charly6to10); await checkMemberList(alice, charly6to10); + await charlies.room(alias).leave(); + await delay(1000); + await checkMemberListLacksCharlies(alice, charlies); + await checkMemberListLacksCharlies(bob, charlies); } const room = "Lazy Loading Test"; @@ -92,6 +96,17 @@ async function checkMemberList(alice, charlies) { alice.log.done(); } +async function checkMemberListLacksCharlies(session, charlies) { + session.log.step(`checks the memberlist doesn't contain ${charlies.log.username}`); + const displayNames = (await getMembersInMemberlist(session)).map((m) => m.displayName); + charlies.sessions.forEach((charly) => { + assert(!displayNames.includes(charly.displayName()), + `${charly.displayName()} should not be in the member list, ` + + `only have ${displayNames}`); + }); + session.log.done(); +} + async function joinCharliesWhileAliceIsOffline(alice, charly6to10) { await alice.setOffline(true); await delay(1000); From f607cb27027d0f5180ac69b7a040672502912ca2 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 1 Nov 2018 17:55:48 -0600 Subject: [PATCH 5/9] Fix the registration process to handle m.login.terms auth --- src/usecases/signup.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/usecases/signup.js b/src/usecases/signup.js index b715e111a1..dfd97a975f 100644 --- a/src/usecases/signup.js +++ b/src/usecases/signup.js @@ -59,6 +59,12 @@ module.exports = async function signup(session, username, password, homeserver) //confirm dialog saying you cant log back in without e-mail const continueButton = await session.waitAndQuery('.mx_QuestionDialog button.mx_Dialog_primary'); await continueButton.click(); + + //find the privacy policy checkbox and check it + //this should automatically move ahead with registration + const policyCheckbox = await session.waitAndQuery('.mx_Login_box input[type="checkbox"]'); + await policyCheckbox.click(); + //wait for registration to finish so the hash gets set //onhashchange better? await session.delay(2000); From d57a56d7a8e873b57dababd511b103d61b94b593 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 1 Nov 2018 18:20:55 -0600 Subject: [PATCH 6/9] There is no more server notices invite on signup --- src/scenario.js | 2 -- src/usecases/consent.js | 27 ---------------------- src/usecases/server-notices-consent.js | 31 -------------------------- src/usecases/signup.js | 1 - 4 files changed, 61 deletions(-) delete mode 100644 src/usecases/consent.js delete mode 100644 src/usecases/server-notices-consent.js diff --git a/src/scenario.js b/src/scenario.js index 2fd52de679..5b9d1f2906 100644 --- a/src/scenario.js +++ b/src/scenario.js @@ -17,7 +17,6 @@ limitations under the License. const {range} = require('./util'); const signup = require('./usecases/signup'); -const acceptServerNoticesInviteAndConsent = require('./usecases/server-notices-consent'); const roomDirectoryScenarios = require('./scenarios/directory'); const lazyLoadingScenarios = require('./scenarios/lazy-loading'); const e2eEncryptionScenarios = require('./scenarios/e2e-encryption'); @@ -26,7 +25,6 @@ module.exports = async function scenario(createSession, restCreator, runningOnTr async function createUser(username) { const session = await createSession(username); await signup(session, session.username, 'testtest', session.hsUrl); - await acceptServerNoticesInviteAndConsent(session); return session; } diff --git a/src/usecases/consent.js b/src/usecases/consent.js deleted file mode 100644 index b4a6289fca..0000000000 --- a/src/usecases/consent.js +++ /dev/null @@ -1,27 +0,0 @@ -/* -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 acceptTerms(session) { - const reviewTermsButton = await session.waitAndQuery('.mx_QuestionDialog button.mx_Dialog_primary'); - const termsPagePromise = session.waitForNewPage(); - await reviewTermsButton.click(); - const termsPage = await termsPagePromise; - const acceptButton = await termsPage.$('input[type=submit]'); - await acceptButton.click(); - await session.delay(1000); //TODO yuck, timers -} diff --git a/src/usecases/server-notices-consent.js b/src/usecases/server-notices-consent.js deleted file mode 100644 index 25c3bb3bd5..0000000000 --- a/src/usecases/server-notices-consent.js +++ /dev/null @@ -1,31 +0,0 @@ -/* -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'); -const acceptInvite = require("./accept-invite") -module.exports = async function acceptServerNoticesInviteAndConsent(session) { - await acceptInvite(session, "Server Notices"); - session.log.step(`accepts terms & conditions`); - const consentLink = await session.waitAndQuery(".mx_EventTile_body a"); - const termsPagePromise = session.waitForNewPage(); - await consentLink.click(); - const termsPage = await termsPagePromise; - const acceptButton = await termsPage.$('input[type=submit]'); - await acceptButton.click(); - await session.delay(1000); //TODO yuck, timers - await termsPage.close(); - session.log.done(); -} diff --git a/src/usecases/signup.js b/src/usecases/signup.js index dfd97a975f..bf2a512a91 100644 --- a/src/usecases/signup.js +++ b/src/usecases/signup.js @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const acceptTerms = require('./consent'); const assert = require('assert'); module.exports = async function signup(session, username, password, homeserver) { From 1a0f09543bc3bf2141967c9098cfeee6f619124e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 7 Nov 2018 15:26:30 -0700 Subject: [PATCH 7/9] Tell synapse to require consent at registration To fix issues where the tests can't correctly test terms auth. --- synapse/config-templates/consent/homeserver.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/config-templates/consent/homeserver.yaml b/synapse/config-templates/consent/homeserver.yaml index 9fa16ebe5f..4f3837a878 100644 --- a/synapse/config-templates/consent/homeserver.yaml +++ b/synapse/config-templates/consent/homeserver.yaml @@ -674,6 +674,7 @@ user_consent: block_events_error: >- To continue using this homeserver you must review and agree to the terms and conditions at %(consent_uri)s + require_at_registration: true From 2e839d545adb848e5578e6ae53b16a5ebc595710 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 15 Nov 2018 20:23:15 -0700 Subject: [PATCH 8/9] Click the 'Accept' button as part of the signup process Part of https://github.com/vector-im/riot-web/issues/7700 --- src/usecases/signup.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/usecases/signup.js b/src/usecases/signup.js index bf2a512a91..825a2c27fa 100644 --- a/src/usecases/signup.js +++ b/src/usecases/signup.js @@ -60,10 +60,13 @@ module.exports = async function signup(session, username, password, homeserver) await continueButton.click(); //find the privacy policy checkbox and check it - //this should automatically move ahead with registration const policyCheckbox = await session.waitAndQuery('.mx_Login_box input[type="checkbox"]'); await policyCheckbox.click(); + //now click the 'Accept' button to agree to the privacy policy + const acceptButton = await session.waitAndQuery('.mx_InteractiveAuthEntryComponents_termsSubmit'); + await acceptButton.click(); + //wait for registration to finish so the hash gets set //onhashchange better? await session.delay(2000); From 19c4f4a8c6aa039aa6269299468b0c006e908602 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 21 Dec 2018 18:36:27 -0700 Subject: [PATCH 9/9] Install jinja2 --- synapse/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/install.sh b/synapse/install.sh index 37dfd7d7e2..1b27f0952d 100755 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -25,6 +25,7 @@ source env/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install . +pip install jinja2 # We use the ConsentResource, which requires jinja2 python -m synapse.app.homeserver \ --server-name localhost \ --config-path homeserver.yaml \