diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92da543..ef3ccdf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ stages: - - test - build + - test - upload artifacts variables: @@ -8,8 +8,6 @@ variables: FF_USE_FASTZIP: 1 CACHE_COMPRESSION_LEVEL: fastest - - test:cargo: stage: "test" needs: [] @@ -34,6 +32,22 @@ test:cargo: - cargo test --workspace --verbose --locked - cargo clippy +test:register:element-release: + stage: "test" + needs: + - "build:cargo:x86_64-unknown-linux-gnu" + image: "buildkite/puppeteer:latest" + tags: ["docker"] + script: + - "CONDUIT_CONFIG=tests/test-config.toml ./conduit-x86_64-unknown-linux-gnu > conduit.log &&" + - "cd tests/puppeteer/" + - "npm install puppeteer" + - "node test-element-web.js" + - "killall conduit-x86_64-unknown-linux-gnu" + - "cd ../.." + - "cat conduit.log" + + # --------------------------------------------------------------------- # # Cargo: Compiling for different architectures # # --------------------------------------------------------------------- # @@ -76,6 +90,7 @@ build:cargo:x86_64-unknown-linux-gnu: extends: .build-cargo-shared-settings variables: TARGET: "x86_64-unknown-linux-gnu" + rules: [] build:cargo:armv7-unknown-linux-gnueabihf: extends: .build-cargo-shared-settings diff --git a/tests/puppeteer/test-element-web.js b/tests/puppeteer/test-element-web.js new file mode 100644 index 0000000..83a43c2 --- /dev/null +++ b/tests/puppeteer/test-element-web.js @@ -0,0 +1,65 @@ +const puppeteer = require('puppeteer'); + +run().then(() => console.log('Done')).catch(_error => process.exit(111)); + +async function run() { + + const username = "testuser" + String(Math.floor(Math.random()*100000)); + const password = "testpassword" + String(Math.floor(Math.random()*100000)); + console.debug("Testuser for this run:\n User: "+username+"\n Password: "+password); + + const browser = await puppeteer.launch({headless: true}); + + const page = await browser.newPage(); + await page.goto('https://app.element.io/'); + + console.debug("Click [Create Account] button"); + await page.waitForSelector('a.mx_ButtonCreateAccount'); + await page.click('a.mx_ButtonCreateAccount'); + + // The webapp should have loaded right now, if anything takes more than 5 seconds, something probably broke + page.setDefaultTimeout(5000); + + console.debug("Click [Edit] to switch homeserver"); + await page.waitForSelector('div.mx_ServerPicker_change'); + await page.click('div.mx_ServerPicker_change'); + + console.debug("Type in local homeserver url"); + await page.waitForSelector('input#mx_homeserverInput'); + await page.click('input#mx_homeserverInput'); + await page.click('input#mx_homeserverInput'); + await page.keyboard.type('http://localhost:6167'); + + console.debug("[Continue] with changed homeserver"); + await page.waitForSelector("div.mx_ServerPickerDialog_continue"); + await page.click('div.mx_ServerPickerDialog_continue'); + + console.debug("Type in username"); + await page.waitForSelector("input#mx_RegistrationForm_username"); + await page.click('input#mx_RegistrationForm_username'); + await page.keyboard.type(username); + + console.debug("Type in password"); + await page.waitForSelector("input#mx_RegistrationForm_password"); + await page.click('input#mx_RegistrationForm_password'); + await page.keyboard.type(password); + + console.debug("Type in password again"); + await page.waitForSelector("input#mx_RegistrationForm_passwordConfirm"); + await page.click('input#mx_RegistrationForm_passwordConfirm'); + await page.keyboard.type(password); + + console.debug("Click on [Register] to finish the account creation"); + await page.waitForSelector("input.mx_Login_submit"); + await page.click('input.mx_Login_submit'); + + console.debug("Wait for chat window to show up"); + await page.waitForSelector("div.mx_HomePage_default_buttons"); + console.debug("Apparently the registration worked."); + + // Wait 5 seconds + await new Promise(resolve => setTimeout(resolve, 5000)); + + // Close the browser and exit the script + await browser.close(); +} \ No newline at end of file diff --git a/tests/test-config.toml b/tests/test-config.toml new file mode 100644 index 0000000..26b0ee3 --- /dev/null +++ b/tests/test-config.toml @@ -0,0 +1,47 @@ +[global] +# The server_name is the name of this server. It is used as a suffix for user +# and room ids. Examples: matrix.org, conduit.rs +# The Conduit server needs to be reachable at https://your.server.name/ on port +# 443 (client-server) and 8448 (federation) OR you can create /.well-known +# files to redirect requests. See +# https://matrix.org/docs/spec/client_server/latest#get-well-known-matrix-client +# and https://matrix.org/docs/spec/server_server/r0.1.4#get-well-known-matrix-server +# for more information + +# YOU NEED TO EDIT THIS +server_name = "localhost" + +# This is the only directory where Conduit will save its data +database_path = "/home/jfowl/projects/conduit/_conduit_db" + +# The port Conduit will be running on. You need to set up a reverse proxy in +# your web server (e.g. apache or nginx), so all requests to /_matrix on port +# 443 and 8448 will be forwarded to the Conduit instance running on this port +port = 6167 + +# Max size for uploads +max_request_size = 20_000_000 # in bytes + +# Disable registration. No new users will be able to register on this server +allow_registration = true + +# Disable encryption, so no new encrypted rooms can be created +# Note: existing rooms will continue to work +#allow_encryption = false +#allow_federation = false + +# Enable jaeger to support monitoring and troubleshooting through jaeger +#allow_jaeger = false + +trusted_servers = ["matrix.org"] + +#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time +#log = "info,state_res=warn,rocket=off,_=off,sled=off" +#workers = 4 # default: cpu core count * 2 + +address = "127.0.0.1" # This makes sure Conduit can only be reached using the reverse proxy + +proxy = "none" # more examples can be found at src/database/proxy.rs:6 + +# The total amount of memory that the database will use. +#db_cache_capacity_mb = 200 \ No newline at end of file