move everything to subfolder to merge into react-sdk
This commit is contained in:
parent
6cb9ef7e65
commit
ca86969f92
47 changed files with 0 additions and 0 deletions
2
test/end-to-end-tests/src/usecases/README.md
Normal file
2
test/end-to-end-tests/src/usecases/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
use cases contains the detailed DOM interactions to perform a given use case, may also do some assertions.
|
||||
use cases are often used in multiple scenarios.
|
38
test/end-to-end-tests/src/usecases/accept-invite.js
Normal file
38
test/end-to-end-tests/src/usecases/accept-invite.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
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 {acceptDialogMaybe} = require('./dialog');
|
||||
|
||||
module.exports = async function acceptInvite(session, name) {
|
||||
session.log.step(`accepts "${name}" invite`);
|
||||
//TODO: brittle selector
|
||||
const invitesHandles = await session.queryAll('.mx_RoomTile_name.mx_RoomTile_invite');
|
||||
const invitesWithText = await Promise.all(invitesHandles.map(async (inviteHandle) => {
|
||||
const text = await session.innerText(inviteHandle);
|
||||
return {inviteHandle, text};
|
||||
}));
|
||||
const inviteHandle = invitesWithText.find(({inviteHandle, text}) => {
|
||||
return text.trim() === name;
|
||||
}).inviteHandle;
|
||||
|
||||
await inviteHandle.click();
|
||||
|
||||
const acceptInvitationLink = await session.query(".mx_RoomPreviewBar_Invite .mx_AccessibleButton_kind_primary");
|
||||
await acceptInvitationLink.click();
|
||||
|
||||
session.log.done();
|
||||
}
|
48
test/end-to-end-tests/src/usecases/create-room.js
Normal file
48
test/end-to-end-tests/src/usecases/create-room.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
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');
|
||||
|
||||
async function openRoomDirectory(session) {
|
||||
const roomDirectoryButton = await session.query('.mx_LeftPanel_explore .mx_AccessibleButton');
|
||||
await roomDirectoryButton.click();
|
||||
}
|
||||
|
||||
async function createRoom(session, roomName) {
|
||||
session.log.step(`creates room "${roomName}"`);
|
||||
|
||||
const roomListHeaders = await session.queryAll('.mx_RoomSubList_labelContainer');
|
||||
const roomListHeaderLabels = await Promise.all(roomListHeaders.map(h => session.innerText(h)));
|
||||
const roomsIndex = roomListHeaderLabels.findIndex(l => l.toLowerCase().includes("rooms"));
|
||||
if (roomsIndex === -1) {
|
||||
throw new Error("could not find room list section that contains rooms in header");
|
||||
}
|
||||
const roomsHeader = roomListHeaders[roomsIndex];
|
||||
const addRoomButton = await roomsHeader.$(".mx_RoomSubList_addRoom");
|
||||
await addRoomButton.click();
|
||||
|
||||
|
||||
const roomNameInput = await session.query('.mx_CreateRoomDialog_name input');
|
||||
await session.replaceInputText(roomNameInput, roomName);
|
||||
|
||||
const createButton = await session.query('.mx_Dialog_primary');
|
||||
await createButton.click();
|
||||
|
||||
await session.query('.mx_MessageComposer');
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
module.exports = {openRoomDirectory, createRoom};
|
50
test/end-to-end-tests/src/usecases/dialog.js
Normal file
50
test/end-to-end-tests/src/usecases/dialog.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
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');
|
||||
|
||||
async function assertDialog(session, expectedTitle) {
|
||||
const titleElement = await session.query(".mx_Dialog .mx_Dialog_title");
|
||||
const dialogHeader = await session.innerText(titleElement);
|
||||
assert(dialogHeader, expectedTitle);
|
||||
}
|
||||
|
||||
async function acceptDialog(session, expectedTitle) {
|
||||
const foundDialog = await acceptDialogMaybe(session, expectedTitle);
|
||||
if (!foundDialog) {
|
||||
throw new Error("could not find a dialog");
|
||||
}
|
||||
}
|
||||
|
||||
async function acceptDialogMaybe(session, expectedTitle) {
|
||||
let primaryButton = null;
|
||||
try {
|
||||
primaryButton = await session.query(".mx_Dialog .mx_Dialog_primary");
|
||||
} catch(err) {
|
||||
return false;
|
||||
}
|
||||
if (expectedTitle) {
|
||||
await assertDialog(session, expectedTitle);
|
||||
}
|
||||
await primaryButton.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
assertDialog,
|
||||
acceptDialog,
|
||||
acceptDialogMaybe,
|
||||
};
|
30
test/end-to-end-tests/src/usecases/invite.js
Normal file
30
test/end-to-end-tests/src/usecases/invite.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
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 invite(session, userId) {
|
||||
session.log.step(`invites "${userId}" to room`);
|
||||
await session.delay(1000);
|
||||
const inviteButton = await session.query(".mx_MemberList_invite");
|
||||
await inviteButton.click();
|
||||
const inviteTextArea = await session.query(".mx_AddressPickerDialog textarea");
|
||||
await inviteTextArea.type(userId);
|
||||
await inviteTextArea.press("Enter");
|
||||
const confirmButton = await session.query(".mx_Dialog_primary");
|
||||
await confirmButton.click();
|
||||
session.log.done();
|
||||
}
|
30
test/end-to-end-tests/src/usecases/join.js
Normal file
30
test/end-to-end-tests/src/usecases/join.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
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 {openRoomDirectory} = require('./create-room');
|
||||
|
||||
module.exports = async function join(session, roomName) {
|
||||
session.log.step(`joins room "${roomName}"`);
|
||||
await openRoomDirectory(session);
|
||||
const roomInput = await session.query('.mx_DirectorySearchBox input');
|
||||
await session.replaceInputText(roomInput, roomName);
|
||||
|
||||
const joinFirstLink = await session.query('.mx_RoomDirectory_table .mx_RoomDirectory_join .mx_AccessibleButton');
|
||||
await joinFirstLink.click();
|
||||
await session.query('.mx_MessageComposer');
|
||||
session.log.done();
|
||||
}
|
70
test/end-to-end-tests/src/usecases/memberlist.js
Normal file
70
test/end-to-end-tests/src/usecases/memberlist.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
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');
|
||||
|
||||
async function openMemberInfo(session, name) {
|
||||
const membersAndNames = await getMembersInMemberlist(session);
|
||||
const matchingLabel = membersAndNames.filter((m) => {
|
||||
return m.displayName === name;
|
||||
}).map((m) => m.label)[0];
|
||||
await matchingLabel.click();
|
||||
};
|
||||
|
||||
module.exports.openMemberInfo = openMemberInfo;
|
||||
|
||||
module.exports.verifyDeviceForUser = async function(session, name, expectedDevice) {
|
||||
session.log.step(`verifies e2e device for ${name}`);
|
||||
const membersAndNames = await getMembersInMemberlist(session);
|
||||
const matchingLabel = membersAndNames.filter((m) => {
|
||||
return m.displayName === name;
|
||||
}).map((m) => m.label)[0];
|
||||
await matchingLabel.click();
|
||||
// click verify in member info
|
||||
const firstVerifyButton = await session.query(".mx_MemberDeviceInfo_verify");
|
||||
await firstVerifyButton.click();
|
||||
// expect "Verify device" dialog and click "Begin Verification"
|
||||
const dialogHeader = await session.innerText(await session.query(".mx_Dialog .mx_Dialog_title"));
|
||||
assert(dialogHeader, "Verify device");
|
||||
const beginVerificationButton = await session.query(".mx_Dialog .mx_Dialog_primary")
|
||||
await beginVerificationButton.click();
|
||||
// get emoji SAS labels
|
||||
const sasLabelElements = await session.queryAll(".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label");
|
||||
const sasLabels = await Promise.all(sasLabelElements.map(e => session.innerText(e)));
|
||||
console.log("my sas labels", sasLabels);
|
||||
|
||||
|
||||
const dialogCodeFields = await session.queryAll(".mx_QuestionDialog code");
|
||||
assert.equal(dialogCodeFields.length, 2);
|
||||
const deviceId = await session.innerText(dialogCodeFields[0]);
|
||||
const deviceKey = await session.innerText(dialogCodeFields[1]);
|
||||
assert.equal(expectedDevice.id, deviceId);
|
||||
assert.equal(expectedDevice.key, deviceKey);
|
||||
const confirmButton = await session.query(".mx_Dialog_primary");
|
||||
await confirmButton.click();
|
||||
const closeMemberInfo = await session.query(".mx_MemberInfo_cancel");
|
||||
await closeMemberInfo.click();
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
async function getMembersInMemberlist(session) {
|
||||
const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name");
|
||||
return Promise.all(memberNameElements.map(async (el) => {
|
||||
return {label: el, displayName: await session.innerText(el)};
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports.getMembersInMemberlist = getMembersInMemberlist;
|
99
test/end-to-end-tests/src/usecases/room-settings.js
Normal file
99
test/end-to-end-tests/src/usecases/room-settings.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
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 {acceptDialog} = require('./dialog');
|
||||
|
||||
async function setSettingsToggle(session, toggle, enabled) {
|
||||
const className = await session.getElementProperty(toggle, "className");
|
||||
const checked = className.includes("mx_ToggleSwitch_on");
|
||||
if (checked !== enabled) {
|
||||
await toggle.click();
|
||||
session.log.done();
|
||||
return true;
|
||||
} else {
|
||||
session.log.done("already set");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = async function changeRoomSettings(session, settings) {
|
||||
session.log.startGroup(`changes the room settings`);
|
||||
/// XXX delay is needed here, possibly because the header is being rerendered
|
||||
/// click doesn't do anything otherwise
|
||||
await session.delay(1000);
|
||||
const settingsButton = await session.query(".mx_RoomHeader .mx_AccessibleButton[title=Settings]");
|
||||
await settingsButton.click();
|
||||
//find tabs
|
||||
const tabButtons = await session.queryAll(".mx_RoomSettingsDialog .mx_TabbedView_tabLabel");
|
||||
const tabLabels = await Promise.all(tabButtons.map(t => session.innerText(t)));
|
||||
const securityTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("security"))];
|
||||
|
||||
const generalSwitches = await session.queryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||
const isDirectory = generalSwitches[0];
|
||||
|
||||
if (typeof settings.directory === "boolean") {
|
||||
session.log.step(`sets directory listing to ${settings.directory}`);
|
||||
await setSettingsToggle(session, isDirectory, settings.directory);
|
||||
}
|
||||
|
||||
if (settings.alias) {
|
||||
session.log.step(`sets alias to ${settings.alias}`);
|
||||
const aliasField = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings input[type=text]");
|
||||
await session.replaceInputText(aliasField, settings.alias);
|
||||
const addButton = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings .mx_AccessibleButton");
|
||||
await addButton.click();
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
securityTabButton.click();
|
||||
await session.delay(500);
|
||||
const securitySwitches = await session.queryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||
const e2eEncryptionToggle = securitySwitches[0];
|
||||
|
||||
if (typeof settings.encryption === "boolean") {
|
||||
session.log.step(`sets room e2e encryption to ${settings.encryption}`);
|
||||
const clicked = await setSettingsToggle(session, e2eEncryptionToggle, settings.encryption);
|
||||
// if enabling, accept beta warning dialog
|
||||
if (clicked && settings.encryption) {
|
||||
await acceptDialog(session, "Enable encryption?");
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.visibility) {
|
||||
session.log.step(`sets visibility to ${settings.visibility}`);
|
||||
const radios = await session.queryAll(".mx_RoomSettingsDialog input[type=radio]");
|
||||
assert.equal(radios.length, 7);
|
||||
const inviteOnly = radios[0];
|
||||
const publicNoGuests = radios[1];
|
||||
const publicWithGuests = radios[2];
|
||||
|
||||
if (settings.visibility === "invite_only") {
|
||||
await inviteOnly.click();
|
||||
} else if (settings.visibility === "public_no_guests") {
|
||||
await publicNoGuests.click();
|
||||
} else if (settings.visibility === "public_with_guests") {
|
||||
await publicWithGuests.click();
|
||||
} else {
|
||||
throw new Error(`unrecognized room visibility setting: ${settings.visibility}`);
|
||||
}
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
const closeButton = await session.query(".mx_RoomSettingsDialog .mx_Dialog_cancelButton");
|
||||
await closeButton.click();
|
||||
|
||||
session.log.endGroup();
|
||||
}
|
34
test/end-to-end-tests/src/usecases/send-message.js
Normal file
34
test/end-to-end-tests/src/usecases/send-message.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
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 sendMessage(session, message) {
|
||||
session.log.step(`writes "${message}" in room`);
|
||||
// this selector needs to be the element that has contenteditable=true,
|
||||
// not any if its parents, otherwise it behaves flaky at best.
|
||||
const composer = await session.query('.mx_MessageComposer_editor');
|
||||
// sometimes the focus that type() does internally doesn't seem to work
|
||||
// and calling click before seems to fix it 🤷
|
||||
await composer.click();
|
||||
await composer.type(message);
|
||||
const text = await session.innerText(composer);
|
||||
assert.equal(text.trim(), message.trim());
|
||||
await composer.press("Enter");
|
||||
// wait for the message to appear sent
|
||||
await session.query(".mx_EventTile_last:not(.mx_EventTile_sending)");
|
||||
session.log.done();
|
||||
}
|
53
test/end-to-end-tests/src/usecases/settings.js
Normal file
53
test/end-to-end-tests/src/usecases/settings.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
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');
|
||||
|
||||
async function openSettings(session, section) {
|
||||
const menuButton = await session.query(".mx_TopLeftMenuButton_name");
|
||||
await menuButton.click();
|
||||
const settingsItem = await session.query(".mx_TopLeftMenu_icon_settings");
|
||||
await settingsItem.click();
|
||||
if (section) {
|
||||
const sectionButton = await session.query(`.mx_UserSettingsDialog .mx_TabbedView_tabLabels .mx_UserSettingsDialog_${section}Icon`);
|
||||
await sectionButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.enableLazyLoading = async function(session) {
|
||||
session.log.step(`enables lazy loading of members in the lab settings`);
|
||||
const settingsButton = await session.query('.mx_BottomLeftMenu_settings');
|
||||
await settingsButton.click();
|
||||
const llCheckbox = await session.query("#feature_lazyloading");
|
||||
await llCheckbox.click();
|
||||
await session.waitForReload();
|
||||
const closeButton = await session.query(".mx_RoomHeader_cancelButton");
|
||||
await closeButton.click();
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
module.exports.getE2EDeviceFromSettings = async function(session) {
|
||||
session.log.step(`gets e2e device/key from settings`);
|
||||
await openSettings(session, "security");
|
||||
const deviceAndKey = await session.queryAll(".mx_SettingsTab_section .mx_SecurityUserSettingsTab_deviceInfo code");
|
||||
assert.equal(deviceAndKey.length, 2);
|
||||
const id = await (await deviceAndKey[0].getProperty("innerText")).jsonValue();
|
||||
const key = await (await deviceAndKey[1].getProperty("innerText")).jsonValue();
|
||||
const closeButton = await session.query(".mx_UserSettingsDialog .mx_Dialog_cancelButton");
|
||||
await closeButton.click();
|
||||
session.log.done();
|
||||
return {id, key};
|
||||
}
|
90
test/end-to-end-tests/src/usecases/signup.js
Normal file
90
test/end-to-end-tests/src/usecases/signup.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
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 signup(session, username, password, homeserver) {
|
||||
session.log.step("signs up");
|
||||
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();
|
||||
|
||||
// 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');
|
||||
await session.replaceInputText(hsInputField, homeserver);
|
||||
const nextButton = await session.query('.mx_Login_submit');
|
||||
// accept homeserver
|
||||
await nextButton.click();
|
||||
}
|
||||
//fill out form
|
||||
const usernameField = await session.query("#mx_RegistrationForm_username");
|
||||
const passwordField = await session.query("#mx_RegistrationForm_password");
|
||||
const passwordRepeatField = await session.query("#mx_RegistrationForm_passwordConfirm");
|
||||
await session.replaceInputText(usernameField, username);
|
||||
await session.replaceInputText(passwordField, password);
|
||||
await session.replaceInputText(passwordRepeatField, password);
|
||||
//wait 300ms because Registration/ServerConfig have a 250ms
|
||||
//delay to internally set the homeserver url
|
||||
//see Registration::render and ServerConfig::props::delayTimeMs
|
||||
await session.delay(300);
|
||||
/// focus on the button to make sure error validation
|
||||
/// has happened before checking the form is good to go
|
||||
const registerButton = await session.query('.mx_Login_submit');
|
||||
await registerButton.focus();
|
||||
// Password validation is async, wait for it to complete before submit
|
||||
await session.query(".mx_Field_valid #mx_RegistrationForm_password");
|
||||
//check no errors
|
||||
const error_text = await session.tryGetInnertext('.mx_Login_error');
|
||||
assert.strictEqual(!!error_text, false);
|
||||
//submit form
|
||||
//await page.screenshot({path: "beforesubmit.png", fullPage: true});
|
||||
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');
|
||||
await continueButton.click();
|
||||
|
||||
//find the privacy policy checkbox and check it
|
||||
const policyCheckbox = await session.query('.mx_InteractiveAuthEntryComponents_termsPolicy input');
|
||||
await policyCheckbox.click();
|
||||
|
||||
//now click the 'Accept' button to agree to the privacy policy
|
||||
const acceptButton = await session.query('.mx_InteractiveAuthEntryComponents_termsSubmit');
|
||||
await acceptButton.click();
|
||||
|
||||
//wait for registration to finish so the hash gets set
|
||||
//onhashchange better?
|
||||
|
||||
const foundHomeUrl = await session.poll(async () => {
|
||||
const url = session.page.url();
|
||||
return url === session.url('/#/home');
|
||||
});
|
||||
assert(foundHomeUrl);
|
||||
session.log.done();
|
||||
}
|
143
test/end-to-end-tests/src/usecases/timeline.js
Normal file
143
test/end-to-end-tests/src/usecases/timeline.js
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
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.scrollToTimelineTop = async function(session) {
|
||||
session.log.step(`scrolls to the top of the timeline`);
|
||||
await session.page.evaluate(() => {
|
||||
return Promise.resolve().then(async () => {
|
||||
let timedOut = false;
|
||||
let timeoutHandle = null;
|
||||
// set scrollTop to 0 in a loop and check every 50ms
|
||||
// if content became available (scrollTop not being 0 anymore),
|
||||
// assume everything is loaded after 3s
|
||||
do {
|
||||
const timelineScrollView = document.querySelector(".mx_RoomView_timeline .mx_ScrollPanel");
|
||||
if (timelineScrollView && timelineScrollView.scrollTop !== 0) {
|
||||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle);
|
||||
}
|
||||
timeoutHandle = setTimeout(() => timedOut = true, 3000);
|
||||
timelineScrollView.scrollTop = 0;
|
||||
} else {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
} while (!timedOut)
|
||||
});
|
||||
})
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
module.exports.receiveMessage = async function(session, expectedMessage) {
|
||||
session.log.step(`receives message "${expectedMessage.body}" from ${expectedMessage.sender}`);
|
||||
// wait for a response to come in that contains the message
|
||||
// crude, but effective
|
||||
|
||||
async function getLastMessage() {
|
||||
const lastTile = await getLastEventTile(session);
|
||||
return getMessageFromEventTile(lastTile);
|
||||
}
|
||||
|
||||
let lastMessage;
|
||||
await session.poll(async () => {
|
||||
try {
|
||||
lastMessage = await getLastMessage();
|
||||
} catch(err) {
|
||||
return false;
|
||||
}
|
||||
// stop polling when found the expected message
|
||||
return lastMessage &&
|
||||
lastMessage.body === expectedMessage.body &&
|
||||
lastMessage.sender === expectedMessage.sender;
|
||||
});
|
||||
assertMessage(lastMessage, expectedMessage);
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
|
||||
module.exports.checkTimelineContains = async function (session, expectedMessages, sendersDescription) {
|
||||
session.log.step(`checks timeline contains ${expectedMessages.length} ` +
|
||||
`given messages${sendersDescription ? ` from ${sendersDescription}`:""}`);
|
||||
const eventTiles = await getAllEventTiles(session);
|
||||
let timelineMessages = await Promise.all(eventTiles.map((eventTile) => {
|
||||
return getMessageFromEventTile(eventTile);
|
||||
}));
|
||||
//filter out tiles that were not messages
|
||||
timelineMessages = timelineMessages.filter((m) => !!m);
|
||||
timelineMessages.reduce((prevSender, m) => {
|
||||
if (m.continuation) {
|
||||
m.sender = prevSender;
|
||||
return prevSender;
|
||||
} else {
|
||||
return m.sender;
|
||||
}
|
||||
});
|
||||
|
||||
expectedMessages.forEach((expectedMessage) => {
|
||||
const foundMessage = timelineMessages.find((message) => {
|
||||
return message.sender === expectedMessage.sender &&
|
||||
message.body === expectedMessage.body;
|
||||
});
|
||||
try {
|
||||
assertMessage(foundMessage, expectedMessage);
|
||||
} catch(err) {
|
||||
console.log("timelineMessages", timelineMessages);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
function assertMessage(foundMessage, expectedMessage) {
|
||||
assert(foundMessage, `message ${JSON.stringify(expectedMessage)} not found in timeline`);
|
||||
assert.equal(foundMessage.body, expectedMessage.body);
|
||||
assert.equal(foundMessage.sender, expectedMessage.sender);
|
||||
if (expectedMessage.hasOwnProperty("encrypted")) {
|
||||
assert.equal(foundMessage.encrypted, expectedMessage.encrypted);
|
||||
}
|
||||
}
|
||||
|
||||
function getLastEventTile(session) {
|
||||
return session.query(".mx_EventTile_last");
|
||||
}
|
||||
|
||||
function getAllEventTiles(session) {
|
||||
return session.queryAll(".mx_RoomView_MessageList .mx_EventTile");
|
||||
}
|
||||
|
||||
async function getMessageFromEventTile(eventTile) {
|
||||
const senderElement = await eventTile.$(".mx_SenderProfile_name");
|
||||
const className = await (await eventTile.getProperty("className")).jsonValue();
|
||||
const classNames = className.split(" ");
|
||||
const bodyElement = await eventTile.$(".mx_EventTile_body");
|
||||
let sender = null;
|
||||
if (senderElement) {
|
||||
sender = await(await senderElement.getProperty("innerText")).jsonValue();
|
||||
}
|
||||
if (!bodyElement) {
|
||||
return null;
|
||||
}
|
||||
const body = await(await bodyElement.getProperty("innerText")).jsonValue();
|
||||
|
||||
return {
|
||||
sender,
|
||||
body,
|
||||
encrypted: classNames.includes("mx_EventTile_verified"),
|
||||
continuation: classNames.includes("mx_EventTile_continuation"),
|
||||
};
|
||||
}
|
68
test/end-to-end-tests/src/usecases/verify.js
Normal file
68
test/end-to-end-tests/src/usecases/verify.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
Copyright 2019 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 {openMemberInfo} = require("./memberlist");
|
||||
const {assertDialog, acceptDialog} = require("./dialog");
|
||||
|
||||
async function assertVerified(session) {
|
||||
const dialogSubTitle = await session.innerText(await session.query(".mx_Dialog h2"));
|
||||
assert(dialogSubTitle, "Verified!");
|
||||
}
|
||||
|
||||
async function startVerification(session, name) {
|
||||
await openMemberInfo(session, name);
|
||||
// click verify in member info
|
||||
const firstVerifyButton = await session.query(".mx_MemberDeviceInfo_verify");
|
||||
await firstVerifyButton.click();
|
||||
}
|
||||
|
||||
async function getSasCodes(session) {
|
||||
const sasLabelElements = await session.queryAll(".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label");
|
||||
const sasLabels = await Promise.all(sasLabelElements.map(e => session.innerText(e)));
|
||||
return sasLabels;
|
||||
}
|
||||
|
||||
module.exports.startSasVerifcation = async function(session, name) {
|
||||
await startVerification(session, name);
|
||||
// expect "Verify device" dialog and click "Begin Verification"
|
||||
await assertDialog(session, "Verify device");
|
||||
// click "Begin Verification"
|
||||
await acceptDialog(session);
|
||||
const sasCodes = await getSasCodes(session);
|
||||
// click "Verify"
|
||||
await acceptDialog(session);
|
||||
await assertVerified(session);
|
||||
// click "Got it" when verification is done
|
||||
await acceptDialog(session);
|
||||
return sasCodes;
|
||||
};
|
||||
|
||||
module.exports.acceptSasVerification = async function(session, name) {
|
||||
await assertDialog(session, "Incoming Verification Request");
|
||||
const opponentLabelElement = await session.query(".mx_IncomingSasDialog_opponentProfile h2");
|
||||
const opponentLabel = await session.innerText(opponentLabelElement);
|
||||
assert(opponentLabel, name);
|
||||
// click "Continue" button
|
||||
await acceptDialog(session);
|
||||
const sasCodes = await getSasCodes(session);
|
||||
// click "Verify"
|
||||
await acceptDialog(session);
|
||||
await assertVerified(session);
|
||||
// click "Got it" when verification is done
|
||||
await acceptDialog(session);
|
||||
return sasCodes;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue