mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
End-to-end test alias publishing flow (#7779)
This commit is contained in:
parent
73899bb2e3
commit
ac6a356027
@ -170,7 +170,7 @@ export default class EditableItemList<P = {}> extends React.PureComponent<IProps
|
||||
const label = this.props.items.length > 0 ? this.props.itemsLabel : this.props.noItemsLabel;
|
||||
|
||||
return (
|
||||
<div className="mx_EditableItemList">
|
||||
<div className="mx_EditableItemList" id={this.props.id}>
|
||||
<div className="mx_EditableItemList_label">
|
||||
{ label }
|
||||
</div>
|
||||
|
@ -19,15 +19,24 @@ import { join } from '../usecases/join';
|
||||
import { sendMessage } from '../usecases/send-message';
|
||||
import { receiveMessage } from '../usecases/timeline';
|
||||
import { createRoom } from '../usecases/create-room';
|
||||
import { changeRoomSettings } from '../usecases/room-settings';
|
||||
import { changeRoomSettings, checkRoomSettings } from '../usecases/room-settings';
|
||||
import { ElementSession } from "../session";
|
||||
|
||||
export async function roomDirectoryScenarios(alice: ElementSession, bob: ElementSession) {
|
||||
console.log(" creating a public room and join through directory:");
|
||||
const room = 'test';
|
||||
await createRoom(alice, room);
|
||||
await changeRoomSettings(alice, { directory: true, visibility: "public", alias: "#test" });
|
||||
|
||||
const settings = {
|
||||
directory: true,
|
||||
visibility: "public",
|
||||
alias: "#test:localhost",
|
||||
publishedAlias: "#test:localhost",
|
||||
};
|
||||
await changeRoomSettings(alice, settings);
|
||||
await join(bob, room); //looks up room in directory
|
||||
await checkRoomSettings(bob, settings);
|
||||
|
||||
const bobMessage = "hi Alice!";
|
||||
await sendMessage(bob, bobMessage);
|
||||
await receiveMessage(alice, { sender: "bob", body: bobMessage });
|
||||
|
@ -71,9 +71,10 @@ async function findTabs(session: ElementSession): Promise<Tabs> {
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
encryption: boolean;
|
||||
encryption?: boolean;
|
||||
directory?: boolean;
|
||||
alias?: string;
|
||||
publishedAlias?: string;
|
||||
visibility?: string;
|
||||
}
|
||||
|
||||
@ -89,11 +90,22 @@ export async function checkRoomSettings(session: ElementSession, expectedSetting
|
||||
await checkSettingsToggle(session, isDirectory, expectedSettings.directory);
|
||||
}
|
||||
|
||||
if (expectedSettings.publishedAlias) {
|
||||
session.log.step(`checks for published alias of ${expectedSettings.publishedAlias}`);
|
||||
const publishedAliases = await session.queryAll('#roomAltAliases .mx_EditableItem_item, #roomAltAliases li');
|
||||
const publishedAliasTexts = await Promise.all(publishedAliases.map(a => session.innerText(a)));
|
||||
if (publishedAliasTexts.find(a => a.includes(expectedSettings.publishedAlias))) {
|
||||
session.log.done("present");
|
||||
} else {
|
||||
throw new Error(`could not find published alias ${expectedSettings.publishedAlias}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedSettings.alias) {
|
||||
session.log.step(`checks for local alias of ${expectedSettings.alias}`);
|
||||
const summary = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings summary");
|
||||
await summary.click();
|
||||
const localAliases = await session.queryAll('.mx_RoomSettingsDialog .mx_AliasSettings .mx_EditableItem_item');
|
||||
const localAliases = await session.queryAll('#roomAliases .mx_EditableItem_item, #roomAliases li');
|
||||
const localAliasTexts = await Promise.all(localAliases.map(a => session.innerText(a)));
|
||||
if (localAliasTexts.find(a => a.includes(expectedSettings.alias))) {
|
||||
session.log.done("present");
|
||||
@ -115,12 +127,15 @@ export async function checkRoomSettings(session: ElementSession, expectedSetting
|
||||
if (expectedSettings.visibility) {
|
||||
session.log.step(`checks visibility is ${expectedSettings.visibility}`);
|
||||
const radios = await session.queryAll(".mx_RoomSettingsDialog input[type=radio]");
|
||||
assert.equal(radios.length, 6);
|
||||
const [inviteOnlyRoom, publicRoom] = radios;
|
||||
// the "Who can read history?" "Anyone" radio option is only shown if visibility is set to public
|
||||
assert.equal(radios.length, expectedSettings.visibility === "public" ? 7 : 6);
|
||||
const [inviteOnlyRoom, spaceMembers, publicRoom] = radios;
|
||||
|
||||
let expectedRadio = null;
|
||||
if (expectedSettings.visibility === "invite_only") {
|
||||
expectedRadio = inviteOnlyRoom;
|
||||
} else if (expectedSettings.visibility === "space_members") {
|
||||
expectedRadio = spaceMembers;
|
||||
} else if (expectedSettings.visibility === "public") {
|
||||
expectedRadio = publicRoom;
|
||||
} else {
|
||||
@ -139,7 +154,17 @@ export async function checkRoomSettings(session: ElementSession, expectedSetting
|
||||
session.log.endGroup();
|
||||
}
|
||||
|
||||
export async function changeRoomSettings(session, settings) {
|
||||
async function getValidationError(session: ElementSession): Promise<string | undefined> {
|
||||
try {
|
||||
const validationDetail = await session.query(".mx_Validation_detail");
|
||||
return session.innerText(validationDetail);
|
||||
} catch (e) {
|
||||
// no validation tooltips
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export async function changeRoomSettings(session: ElementSession, settings: Settings) {
|
||||
session.log.startGroup(`changes the room settings`);
|
||||
|
||||
const { securityTabButton, generalTabButton } = await findTabs(session);
|
||||
@ -186,12 +211,24 @@ export async function changeRoomSettings(session, settings) {
|
||||
}
|
||||
|
||||
if (settings.alias) {
|
||||
session.log.step(`sets alias to ${settings.alias}`);
|
||||
const aliasField = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details input[type=text]");
|
||||
session.log.step(`adding local alias ${settings.alias}`);
|
||||
const aliasField = await session.query("#roomAliases input[type=text]");
|
||||
await session.replaceInputText(aliasField, settings.alias.substring(1, settings.alias.lastIndexOf(":")));
|
||||
const addButton = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details .mx_AccessibleButton");
|
||||
const addButton = await session.query("#roomAliases .mx_AccessibleButton");
|
||||
await addButton.click();
|
||||
await session.delay(10); // delay to give time for the validator to run and check the alias
|
||||
await session.query("#roomAliases .mx_Field_valid, #roomAliases .mx_Field_invalid"); // await validator
|
||||
assert.equal(await getValidationError(session), undefined);
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
if (settings.publishedAlias) {
|
||||
session.log.step(`adding published alias ${settings.alias}`);
|
||||
const aliasField = await session.query("#roomAltAliases input[type=text]");
|
||||
await session.replaceInputText(aliasField, settings.alias.substring(1));
|
||||
const addButton = await session.query("#roomAltAliases .mx_AccessibleButton");
|
||||
await addButton.click();
|
||||
await session.query("#roomAltAliases .mx_Field_valid, #roomAltAliases .mx_Field_invalid"); // await validator
|
||||
assert.equal(await getValidationError(session), undefined);
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { strict as assert } from 'assert';
|
||||
|
||||
import { ElementSession } from "../session";
|
||||
|
||||
export async function openSettings(session: ElementSession, section: string): Promise<void> {
|
||||
@ -30,33 +28,3 @@ export async function openSettings(session: ElementSession, section: string): Pr
|
||||
await sectionButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
export async function enableLazyLoading(session: ElementSession): Promise<void> {
|
||||
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();
|
||||
}
|
||||
|
||||
interface E2EDevice {
|
||||
id: string;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export async function getE2EDeviceFromSettings(session: ElementSession): Promise<E2EDevice> {
|
||||
session.log.step(`gets e2e device/key from settings`);
|
||||
await openSettings(session, "security");
|
||||
const deviceAndKey = await session.queryAll(".mx_SettingsTab_section .mx_CryptographyPanel code");
|
||||
assert.equal(deviceAndKey.length, 2);
|
||||
const id: string = await (await deviceAndKey[0].getProperty("innerText")).jsonValue();
|
||||
const key: string = 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 };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user