1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Merge branch 'develop' of https://github.com/matrix-org/matrix-react-sdk into new/room-alias-in-permalink

This commit is contained in:
Simon Merrick
2020-12-07 10:30:50 +13:00
98 changed files with 3150 additions and 1812 deletions

View File

@@ -52,7 +52,7 @@ describe('Login', function() {
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
currentFlow: "m.login.password",
flows: [{ type: "m.login.password" }],
});
const form = ReactTestUtils.findRenderedComponentWithType(
@@ -61,10 +61,7 @@ describe('Login', function() {
);
expect(form).toBeTruthy();
const changeServerLink = ReactTestUtils.findRenderedDOMComponentWithClass(
root,
'mx_AuthBody_editServerDetails',
);
const changeServerLink = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_ServerPicker_change');
expect(changeServerLink).toBeTruthy();
});
@@ -77,7 +74,7 @@ describe('Login', function() {
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
currentFlow: "m.login.password",
flows: [{ type: "m.login.password" }],
});
const form = ReactTestUtils.findRenderedComponentWithType(
@@ -86,10 +83,70 @@ describe('Login', function() {
);
expect(form).toBeTruthy();
const changeServerLinks = ReactTestUtils.scryRenderedDOMComponentsWithClass(
root,
'mx_AuthBody_editServerDetails',
);
const changeServerLinks = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, 'mx_ServerPicker_change');
expect(changeServerLinks).toHaveLength(0);
});
it("should show SSO button if that flow is available", () => {
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});
const root = render();
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
flows: [{ type: "m.login.sso" }],
});
const ssoButton = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_SSOButton");
expect(ssoButton).toBeTruthy();
});
it("should show both SSO button and username+password if both are available", () => {
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});
const root = render();
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
flows: [{ type: "m.login.password" }, { type: "m.login.sso" }],
});
const form = ReactTestUtils.findRenderedComponentWithType(root, sdk.getComponent('auth.PasswordLogin'));
expect(form).toBeTruthy();
const ssoButton = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_SSOButton");
expect(ssoButton).toBeTruthy();
});
it("should show multiple SSO buttons if multiple identity_providers are available", () => {
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});
const root = render();
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
flows: [{
type: "m.login.sso",
identity_providers: [{
id: "a",
name: "Provider 1",
}, {
id: "b",
name: "Provider 2",
}, {
id: "c",
name: "Provider 3",
}],
}],
});
const ssoButtons = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, "mx_SSOButton");
expect(ssoButtons.length).toBe(3);
});
});

View File

@@ -48,12 +48,9 @@ describe('Registration', function() {
/>, parentDiv);
}
it('should show server type selector', function() {
it('should show server picker', function() {
const root = render();
const selector = ReactTestUtils.findRenderedComponentWithType(
root,
sdk.getComponent('auth.ServerTypeSelector'),
);
const selector = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_ServerPicker");
expect(selector).toBeTruthy();
});
@@ -79,4 +76,27 @@ describe('Registration', function() {
);
expect(form).toBeTruthy();
});
it("should show SSO options if those are available", () => {
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});
const root = render();
// Set non-empty flows & matrixClient to get past the loading spinner
root.setState({
flows: [{
stages: [],
}],
ssoFlow: {
type: "m.login.sso",
},
matrixClient: {},
busy: false,
});
const ssoButton = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_SSOButton");
expect(ssoButton).toBeTruthy();
});
});

View File

@@ -1,3 +1,3 @@
node_modules
*.png
riot/env
element/env

View File

@@ -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 <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 <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 <factor>` 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.

View File

@@ -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.

View File

@@ -0,0 +1,2 @@
element-web
element.pid

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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" );

View File

@@ -1,2 +0,0 @@
riot-web
riot.pid

View File

@@ -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

View File

@@ -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 <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 <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

View File

@@ -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) {

View File

@@ -22,24 +22,12 @@ module.exports = async function signup(session, username, password, homeserver)
await session.goto(session.url('/#/register'));
// change the homeserver by clicking the advanced section
if (homeserver) {
const advancedButton = await session.query('.mx_ServerTypeSelector_type_Advanced');
await advancedButton.click();
const changeButton = await session.query('.mx_ServerPicker_change');
await changeButton.click();
// depending on what HS is configured as the default, the advanced registration
// goes the HS/IS entry directly (for matrix.org) or takes you to the user/pass entry (not matrix.org).
// To work with both, we look for the "Change" link in the user/pass entry but don't fail when we can't find it
// As this link should be visible immediately, and to not slow down the case where it isn't present,
// pick a lower timeout of 5000ms
try {
const changeHsField = await session.query('.mx_AuthBody_editServerDetails', 5000);
if (changeHsField) {
await changeHsField.click();
}
} catch (err) {}
const hsInputField = await session.query('#mx_ServerConfig_hsUrl');
const hsInputField = await session.query('.mx_ServerPickerDialog_otherHomeserver');
await session.replaceInputText(hsInputField, homeserver);
const nextButton = await session.query('.mx_Login_submit');
const nextButton = await session.query('.mx_ServerPickerDialog_continue');
// accept homeserver
await nextButton.click();
}
@@ -68,7 +56,7 @@ module.exports = async function signup(session, username, password, homeserver)
await registerButton.click();
//confirm dialog saying you cant log back in without e-mail
const continueButton = await session.query('.mx_QuestionDialog button.mx_Dialog_primary');
const continueButton = await session.query('.mx_RegistrationEmailPromptDialog button.mx_Dialog_primary');
await continueButton.click();
//find the privacy policy checkbox and check it

View File

@@ -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;
}

View File

@@ -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: