diff --git a/.eslintignore b/.eslintignore index c4f7298047..e453170087 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ src/component-index.js test/end-to-end-tests/node_modules/ -test/end-to-end-tests/riot/ +test/end-to-end-tests/element/ test/end-to-end-tests/synapse/ diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index db90d26ba7..1c0a3d1254 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -12,5 +12,5 @@ test/components/views/dialogs/InteractiveAuthDialog-test.js test/mock-clock.js src/component-index.js test/end-to-end-tests/node_modules/ -test/end-to-end-tests/riot/ +test/end-to-end-tests/element/ test/end-to-end-tests/synapse/ diff --git a/package.json b/package.json index f3b8104663..1e778f9875 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lint:types": "tsc --noEmit --jsx react", "lint:style": "stylelint 'res/css/**/*.scss'", "test": "jest", - "test:e2e": "./test/end-to-end-tests/run.sh --riot-url http://localhost:8080" + "test:e2e": "./test/end-to-end-tests/run.sh --app-url http://localhost:8080" }, "dependencies": { "@babel/runtime": "^7.10.5", diff --git a/scripts/ci/riot-unit-tests.sh b/scripts/ci/app-tests.sh similarity index 56% rename from scripts/ci/riot-unit-tests.sh rename to scripts/ci/app-tests.sh index 337c0fe6c3..3ca4d8ec69 100755 --- a/scripts/ci/riot-unit-tests.sh +++ b/scripts/ci/app-tests.sh @@ -2,11 +2,11 @@ # # script which is run by the CI build (after `yarn test`). # -# clones riot-web develop and runs the tests against our version of react-sdk. +# clones element-web develop and runs the tests against our version of react-sdk. set -ev -scripts/ci/layered-riot-web.sh -cd ../riot-web +scripts/ci/layered.sh +cd ../element-web yarn build:genfiles # so the tests can run. Faster version of `build` yarn test diff --git a/scripts/ci/end-to-end-tests.sh b/scripts/ci/end-to-end-tests.sh index 7a62c03b12..65cd3f6c21 100755 --- a/scripts/ci/end-to-end-tests.sh +++ b/scripts/ci/end-to-end-tests.sh @@ -2,7 +2,7 @@ # # script which is run by the CI build (after `yarn test`). # -# clones riot-web develop and runs the tests against our version of react-sdk. +# clones element-web develop and runs the tests against our version of react-sdk. set -ev @@ -14,20 +14,20 @@ handle_error() { trap 'handle_error' ERR echo "--- Building Element" -scripts/ci/layered-riot-web.sh -cd ../riot-web -riot_web_dir=`pwd` +scripts/ci/layered.sh +cd ../element-web +element_web_dir=`pwd` CI_PACKAGE=true yarn build cd ../matrix-react-sdk # run end to end tests pushd test/end-to-end-tests -ln -s $riot_web_dir riot/riot-web +ln -s $element_web_dir element/element-web # PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ./install.sh # CHROME_PATH=$(which google-chrome-stable) ./run.sh echo "--- Install synapse & other dependencies" ./install.sh -# install static webserver to server symlinked local copy of riot -./riot/install-webserver.sh +# install static webserver to server symlinked local copy of element +./element/install-webserver.sh rm -r logs || true mkdir logs echo "+++ Running end-to-end tests" diff --git a/scripts/ci/layered-riot-web.sh b/scripts/ci/layered.sh similarity index 66% rename from scripts/ci/layered-riot-web.sh rename to scripts/ci/layered.sh index f58794b451..51d285aff6 100755 --- a/scripts/ci/layered-riot-web.sh +++ b/scripts/ci/layered.sh @@ -1,8 +1,8 @@ #!/bin/bash -# Creates an environment similar to one that riot-web would expect for +# Creates an environment similar to one that element-web would expect for # development. This means going one directory up (and assuming we're in -# a directory like /workdir/matrix-react-sdk) and putting riot-web and +# a directory like /workdir/matrix-react-sdk) and putting element-web and # the js-sdk there. cd ../ # Assume we're at something like /workdir/matrix-react-sdk @@ -21,9 +21,9 @@ yarn link yarn install popd -# Finally, set up riot-web -matrix-react-sdk/scripts/fetchdep.sh vector-im riot-web -pushd riot-web +# Finally, set up element-web +matrix-react-sdk/scripts/fetchdep.sh vector-im element-web +pushd element-web yarn link matrix-js-sdk yarn link matrix-react-sdk yarn install diff --git a/test/end-to-end-tests/.gitignore b/test/end-to-end-tests/.gitignore index afca1ddcb3..61f9012393 100644 --- a/test/end-to-end-tests/.gitignore +++ b/test/end-to-end-tests/.gitignore @@ -1,3 +1,3 @@ node_modules *.png -riot/env +element/env diff --git a/test/end-to-end-tests/README.md b/test/end-to-end-tests/README.md index 8794ef6c9b..b173fb86c2 100644 --- a/test/end-to-end-tests/README.md +++ b/test/end-to-end-tests/README.md @@ -5,9 +5,9 @@ This directory contains tests for matrix-react-sdk. The tests fire up a headless ## Setup Run `./install.sh`. This will: - - install Synapse, fetches the master branch at the moment. If anything fails here, please refer to the Synapse README to see if you're missing one of the prerequisites. - - install Riot, this fetches the master branch at the moment. - - install dependencies (will download copy of chrome) + - install Synapse, fetches the develop branch at the moment. If anything fails here, please refer to the Synapse README to see if you're missing one of the prerequisites. + - install Element Web, this fetches the develop branch at the moment. + - install dependencies (will download copy of Chrome) ## Running the tests @@ -15,7 +15,7 @@ Run tests with `./run.sh`. ### Debug tests locally. -`./run.sh` will run the tests against the Riot copy present in `riot/riot-web` served by a static Python HTTP server. You can symlink your `riot-web` develop copy here but that doesn't work well with Webpack recompiling. You can run the test runner directly and specify parameters to get more insight into a failure or run the tests against your local Webpack server. +`./run.sh` will run the tests against the Element copy present in `element/element-web` served by a static Python HTTP server. You can symlink your `element-web` develop copy here but that doesn't work well with Webpack recompiling. You can run the test runner directly and specify parameters to get more insight into a failure or run the tests against your local Webpack server. ``` ./synapse/stop.sh && \ @@ -26,8 +26,7 @@ It's important to always stop and start Synapse before each run of the tests to start.js accepts these parameters (and more, see `node start.js --help`) that can help running the tests locally: - - `--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. + - `--app-url ` don't use the Element Web copy and static server provided by the tests, but use a running server like the Webpack watch server to run the tests against. - `--slow-mo` type at a human speed, useful with `--windowed`. - `--throttle-cpu ` throttle cpu in the browser by the given factor. Useful to reproduce failures because of insufficient timeouts happening on the slower CI server. - `--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. diff --git a/test/end-to-end-tests/Windows.md b/test/end-to-end-tests/Windows.md index 39b06a9a62..f6ea87d0af 100644 --- a/test/end-to-end-tests/Windows.md +++ b/test/end-to-end-tests/Windows.md @@ -5,14 +5,14 @@ and start following these steps to get going: 1. Navigate to your working directory (`cd /mnt/c/users/travisr/whatever/matrix-react-sdk` for example). 2. Run `sudo apt-get install unzip python3 virtualenv dos2unix` -3. Run `dos2unix ./test/end-to-end-tests/*.sh ./test/end-to-end-tests/synapse/*.sh ./test/end-to-end-tests/riot/*.sh` +3. Run `dos2unix ./test/end-to-end-tests/*.sh ./test/end-to-end-tests/synapse/*.sh ./test/end-to-end-tests/element/*.sh` 4. Install NodeJS for ubuntu: ```bash curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get update sudo apt-get install nodejs ``` -5. Start Riot on Windows through `yarn start` +5. Start Element on Windows through `yarn start` 6. While that builds... Run: ```bash sudo apt-get install x11-apps @@ -25,11 +25,11 @@ and start following these steps to get going: cd ./test/end-to-end-tests ./synapse/install.sh ./install.sh - ./run.sh --riot-url http://localhost:8080 --no-sandbox + ./run.sh --app-url http://localhost:8080 --no-sandbox ``` Note that using `yarn test:e2e` probably won't work for you. You might also have to use the config.json from the -`riot/config-template` directory in order to actually succeed at the tests. +`element/config-template` directory in order to actually succeed at the tests. Also note that you'll have to use `--no-sandbox` otherwise Chrome will complain that there's no sandbox available. You could probably fix this with enough effort, or you could run a headless Chrome in the WSL container without a sandbox. diff --git a/test/end-to-end-tests/element/.gitignore b/test/end-to-end-tests/element/.gitignore new file mode 100644 index 0000000000..57fac2072f --- /dev/null +++ b/test/end-to-end-tests/element/.gitignore @@ -0,0 +1,2 @@ +element-web +element.pid diff --git a/test/end-to-end-tests/riot/config-template/config.json b/test/end-to-end-tests/element/config-template/config.json similarity index 92% rename from test/end-to-end-tests/riot/config-template/config.json rename to test/end-to-end-tests/element/config-template/config.json index b647d0bec8..b90fefc2cb 100644 --- a/test/end-to-end-tests/riot/config-template/config.json +++ b/test/end-to-end-tests/element/config-template/config.json @@ -8,7 +8,7 @@ "brand": "Element", "integrations_ui_url": "https://scalar.vector.im/", "integrations_rest_url": "https://scalar.vector.im/api", - "bug_report_endpoint_url": "https://riot.im/bugreports/submit", + "bug_report_endpoint_url": "https://element.io/bugreports/submit", "showLabsSettings": true, "default_federate": true, "welcomePageUrl": "home.html", diff --git a/test/end-to-end-tests/riot/install-webserver.sh b/test/end-to-end-tests/element/install-webserver.sh similarity index 100% rename from test/end-to-end-tests/riot/install-webserver.sh rename to test/end-to-end-tests/element/install-webserver.sh diff --git a/test/end-to-end-tests/element/install.sh b/test/end-to-end-tests/element/install.sh new file mode 100755 index 0000000000..e38f795df1 --- /dev/null +++ b/test/end-to-end-tests/element/install.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e +ELEMENT_BRANCH=develop + +if [ -d $BASE_DIR/element-web ]; then + echo "Element is already installed" + exit +fi + +curl -L https://github.com/vector-im/element-web/archive/${ELEMENT_BRANCH}.zip --output element.zip +unzip -q element.zip +rm element.zip +mv element-web-${ELEMENT_BRANCH} element-web +cd element-web +yarn install +yarn run build diff --git a/test/end-to-end-tests/riot/start.sh b/test/end-to-end-tests/element/start.sh similarity index 87% rename from test/end-to-end-tests/riot/start.sh rename to test/end-to-end-tests/element/start.sh index be226ed257..b344f91a19 100755 --- a/test/end-to-end-tests/riot/start.sh +++ b/test/end-to-end-tests/element/start.sh @@ -3,7 +3,7 @@ set -e PORT=5000 BASE_DIR=$(cd $(dirname $0) && pwd) -PIDFILE=$BASE_DIR/riot.pid +PIDFILE=$BASE_DIR/element.pid CONFIG_BACKUP=config.e2etests_backup.json if [ -f $PIDFILE ]; then @@ -11,8 +11,8 @@ if [ -f $PIDFILE ]; then fi cd $BASE_DIR/ -echo -n "starting riot on http://localhost:$PORT ... " -pushd riot-web/webapp/ > /dev/null +echo -n "Starting Element on http://localhost:$PORT ... " +pushd element-web/webapp/ > /dev/null # backup config file before we copy template if [ -f config.json ]; then @@ -34,7 +34,7 @@ LOGFILE=$(mktemp) # NOT expected SIGTERM (128 + 15) # from stop.sh? if [ $RESULT -ne 143 ]; then - echo "failed" + echo "Failed" cat $LOGFILE rm $PIDFILE 2> /dev/null fi @@ -49,6 +49,6 @@ sleep 0.5 & wait -n; RESULT=$? # return exit code of first child to exit if [ $RESULT -eq 0 ]; then - echo "running" + echo "Running" fi exit $RESULT diff --git a/test/end-to-end-tests/riot/stop.sh b/test/end-to-end-tests/element/stop.sh similarity index 79% rename from test/end-to-end-tests/riot/stop.sh rename to test/end-to-end-tests/element/stop.sh index eb99fa11cc..e39f0077eb 100755 --- a/test/end-to-end-tests/riot/stop.sh +++ b/test/end-to-end-tests/element/stop.sh @@ -2,19 +2,19 @@ set -e BASE_DIR=$(cd $(dirname $0) && pwd) -PIDFILE=riot.pid +PIDFILE=element.pid CONFIG_BACKUP=config.e2etests_backup.json cd $BASE_DIR if [ -f $PIDFILE ]; then - echo "stopping riot server ..." + echo "Stopping Element server ..." PID=$(cat $PIDFILE) rm $PIDFILE kill $PID # revert config file - cd riot-web/webapp + cd element-web/webapp rm config.json if [ -f $CONFIG_BACKUP ]; then mv $CONFIG_BACKUP config.json diff --git a/test/end-to-end-tests/has_custom_riot.js b/test/end-to-end-tests/has-custom-app.js similarity index 83% rename from test/end-to-end-tests/has_custom_riot.js rename to test/end-to-end-tests/has-custom-app.js index 95f32d8ad0..00184088fd 100644 --- a/test/end-to-end-tests/has_custom_riot.js +++ b/test/end-to-end-tests/has-custom-app.js @@ -15,10 +15,10 @@ limitations under the License. */ // used from run.sh as getopts doesn't support long parameters -const idx = process.argv.indexOf("--riot-url"); -let hasRiotUrl = false; +const idx = process.argv.indexOf("--app-url"); +let hasAppUrl = false; if (idx !== -1) { const value = process.argv[idx + 1]; - hasRiotUrl = !!value; + hasAppUrl = !!value; } -process.stdout.write(hasRiotUrl ? "1" : "0" ); +process.stdout.write(hasAppUrl ? "1" : "0" ); diff --git a/test/end-to-end-tests/riot/.gitignore b/test/end-to-end-tests/riot/.gitignore deleted file mode 100644 index 0f07d8e498..0000000000 --- a/test/end-to-end-tests/riot/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -riot-web -riot.pid \ No newline at end of file diff --git a/test/end-to-end-tests/riot/install.sh b/test/end-to-end-tests/riot/install.sh deleted file mode 100755 index f66ab3224e..0000000000 --- a/test/end-to-end-tests/riot/install.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e -RIOT_BRANCH=develop - -if [ -d $BASE_DIR/riot-web ]; then - echo "riot is already installed" - exit -fi - -curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip -unzip -q riot.zip -rm riot.zip -mv riot-web-${RIOT_BRANCH} riot-web -cd riot-web -yarn install -yarn run build diff --git a/test/end-to-end-tests/run.sh b/test/end-to-end-tests/run.sh index b9d589eed9..4421bddc34 100755 --- a/test/end-to-end-tests/run.sh +++ b/test/end-to-end-tests/run.sh @@ -9,16 +9,16 @@ echo "Please first run $BASE_DIR/install.sh" exit 1 fi -has_custom_riot=$(node has_custom_riot.js $@) +has_custom_app=$(node has-custom-app.js $@) -if [ ! -d "riot/riot-web" ] && [ $has_custom_riot -ne "1" ]; then - echo "Please provide an instance of riot to test against by passing --riot-url or running $BASE_DIR/riot/install.sh" +if [ ! -d "element/element-web" ] && [ $has_custom_app -ne "1" ]; then + echo "Please provide an instance of Element to test against by passing --element-url or running $BASE_DIR/element/install.sh" exit 1 fi stop_servers() { - if [ $has_custom_riot -ne "1" ]; then - ./riot/stop.sh + if [ $has_custom_app -ne "1" ]; then + ./element/stop.sh fi ./synapse/stop.sh } @@ -32,8 +32,8 @@ handle_error() { trap 'handle_error' ERR ./synapse/start.sh -if [ $has_custom_riot -ne "1" ]; then - ./riot/start.sh +if [ $has_custom_app -ne "1" ]; then + ./element/start.sh fi node start.js $@ stop_servers diff --git a/test/end-to-end-tests/src/session.js b/test/end-to-end-tests/src/session.js index 907ee2fb8e..433baa5e48 100644 --- a/test/end-to-end-tests/src/session.js +++ b/test/end-to-end-tests/src/session.js @@ -22,12 +22,12 @@ const {delay} = require('./util'); const DEFAULT_TIMEOUT = 20000; -module.exports = class RiotSession { - constructor(browser, page, username, riotserver, hsUrl) { +module.exports = class ElementSession { + constructor(browser, page, username, elementServer, hsUrl) { this.browser = browser; this.page = page; this.hsUrl = hsUrl; - this.riotserver = riotserver; + this.elementServer = elementServer; this.username = username; this.consoleLog = new LogBuffer(page, "console", (msg) => `${msg.text()}\n`); this.networkLog = new LogBuffer(page, "requestfinished", async (req) => { @@ -38,7 +38,7 @@ module.exports = class RiotSession { this.log = new Logger(this.username); } - static async create(username, puppeteerOptions, riotserver, hsUrl, throttleCpuFactor = 1) { + static async create(username, puppeteerOptions, elementServer, hsUrl, throttleCpuFactor = 1) { const browser = await puppeteer.launch(puppeteerOptions); const page = await browser.newPage(); await page.setViewport({ @@ -50,7 +50,7 @@ module.exports = class RiotSession { console.log("throttling cpu by a factor of", throttleCpuFactor); await client.send('Emulation.setCPUThrottlingRate', { rate: throttleCpuFactor }); } - return new RiotSession(browser, page, username, riotserver, hsUrl); + return new ElementSession(browser, page, username, elementServer, hsUrl); } async tryGetInnertext(selector) { @@ -194,7 +194,7 @@ module.exports = class RiotSession { } url(path) { - return this.riotserver + path; + return this.elementServer + path; } delay(ms) { diff --git a/test/end-to-end-tests/start.js b/test/end-to-end-tests/start.js index 6c80608903..234d60da9f 100644 --- a/test/end-to-end-tests/start.js +++ b/test/end-to-end-tests/start.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -const RiotSession = require('./src/session'); +const ElementSession = require('./src/session'); const scenario = require('./src/scenario'); const RestSessionCreator = require('./src/rest/creator'); const fs = require("fs"); @@ -22,7 +22,7 @@ const fs = require("fs"); const program = require('commander'); program .option('--no-logs', "don't output logs, document html on error", false) - .option('--riot-url [url]', "riot url to test", "http://localhost:5000") + .option('--app-url [url]', "url to test", "http://localhost:5000") .option('--windowed', "dont run tests headless", false) .option('--slow-mo', "type at a human speed", false) .option('--dev-tools', "open chrome devtools in browser window", false) @@ -57,7 +57,7 @@ async function runTests() { ); async function createSession(username) { - const session = await RiotSession.create(username, options, program.riotUrl, hsUrl, program.throttleCpu); + const session = await ElementSession.create(username, options, program.appUrl, hsUrl, program.throttleCpu); sessions.push(session); return session; } diff --git a/test/end-to-end-tests/synapse/config-templates/consent/homeserver.yaml b/test/end-to-end-tests/synapse/config-templates/consent/homeserver.yaml index 536c017b9e..deb750666f 100644 --- a/test/end-to-end-tests/synapse/config-templates/consent/homeserver.yaml +++ b/test/end-to-end-tests/synapse/config-templates/consent/homeserver.yaml @@ -875,8 +875,8 @@ password_config: # Enable sending emails for notification events -# Defining a custom URL for Riot is only needed if email notifications -# should contain links to a self-hosted installation of Riot; when set +# Defining a custom URL for Element is only needed if email notifications +# should contain links to a self-hosted installation of Element; when set # the "app_name" setting is ignored. # # If your SMTP server requires authentication, the optional smtp_user & @@ -897,7 +897,7 @@ email: notif_template_html: notif_mail.html notif_template_text: notif_mail.txt notif_for_new_users: True - riot_base_url: "http://localhost/riot" + client_base_url: "http://localhost/element" #password_providers: