Delete groups (legacy communities system) (#8027)
* Remove deprecated feature_communities_v2_prototypes * Update _components * i18n * delint * Cut out a bit more dead code * Carve into legacy components * Carve into mostly the room list code * Carve into instances of "groupId" * Carve out more of what comes up with "groups" * Carve out some settings * ignore related groups state * Remove instances of spacesEnabled * Fix some obvious issues * Remove now-unused css * Fix variable naming for legacy components * Update i18n * Misc cleanup from manual review * Update snapshot for changed flag * Appease linters * rethemedex * Remove now-unused AddressPickerDialog * Make ConfirmUserActionDialog's member a required prop * Remove useless override from RightPanelStore * Remove extraneous CSS * Update i18n * Demo: "Communities are now Spaces" landing page * Restore linkify for group IDs * Demo: Dialog on click for communities->spaces notice * i18n for demos * i18n post-merge * Update copy * Appease the linter * Post-merge cleanup * Re-add spaces_learn_more_url to the new SdkConfig place * Round 1 of post-merge fixes * i18n Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
03c80707c9
commit
fce36ec826
171 changed files with 317 additions and 12160 deletions
|
@ -1,378 +0,0 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import MockHttpBackend from 'matrix-mock-request';
|
||||
import * as Matrix from 'matrix-js-sdk/src/matrix';
|
||||
|
||||
import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
|
||||
import sdk from '../../skinned-sdk';
|
||||
import * as TestUtils from '../../test-utils';
|
||||
|
||||
const { waitForUpdate } = TestUtils;
|
||||
|
||||
const GroupView = sdk.getComponent('structures.GroupView');
|
||||
const WrappedGroupView = TestUtils.wrapInMatrixClientContext(GroupView);
|
||||
|
||||
const Spinner = sdk.getComponent('elements.Spinner');
|
||||
|
||||
describe('GroupView', function() {
|
||||
let root;
|
||||
let rootElement;
|
||||
let httpBackend;
|
||||
let summaryResponse;
|
||||
let summaryResponseWithComplicatedLongDesc;
|
||||
let summaryResponseWithNoLongDesc;
|
||||
let summaryResponseWithBadImg;
|
||||
let groupId;
|
||||
let groupIdEncoded;
|
||||
|
||||
// Summary response fields
|
||||
const user = {
|
||||
is_privileged: true, // can edit the group
|
||||
is_public: true, // appear as a member to non-members
|
||||
is_publicised: true, // display flair
|
||||
};
|
||||
const usersSection = {
|
||||
roles: {},
|
||||
total_user_count_estimate: 0,
|
||||
users: [],
|
||||
};
|
||||
const roomsSection = {
|
||||
categories: {},
|
||||
rooms: [],
|
||||
total_room_count_estimate: 0,
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
httpBackend = new MockHttpBackend();
|
||||
|
||||
Matrix.request(httpBackend.requestFn);
|
||||
|
||||
MatrixClientPeg.get = () => Matrix.createClient({
|
||||
baseUrl: 'https://my.home.server',
|
||||
userId: '@me:here',
|
||||
accessToken: '123456789',
|
||||
});
|
||||
|
||||
summaryResponse = {
|
||||
profile: {
|
||||
avatar_url: "mxc://someavatarurl",
|
||||
is_openly_joinable: true,
|
||||
is_public: true,
|
||||
long_description: "This is a <b>LONG</b> description.",
|
||||
name: "The name of a community",
|
||||
short_description: "This is a community",
|
||||
},
|
||||
user,
|
||||
users_section: usersSection,
|
||||
rooms_section: roomsSection,
|
||||
};
|
||||
summaryResponseWithNoLongDesc = {
|
||||
profile: {
|
||||
avatar_url: "mxc://someavatarurl",
|
||||
is_openly_joinable: true,
|
||||
is_public: true,
|
||||
long_description: null,
|
||||
name: "The name of a community",
|
||||
short_description: "This is a community",
|
||||
},
|
||||
user,
|
||||
users_section: usersSection,
|
||||
rooms_section: roomsSection,
|
||||
};
|
||||
summaryResponseWithComplicatedLongDesc = {
|
||||
profile: {
|
||||
avatar_url: "mxc://someavatarurl",
|
||||
is_openly_joinable: true,
|
||||
is_public: true,
|
||||
long_description: `
|
||||
<h1>This is a more complicated group page</h1>
|
||||
<p>With paragraphs</p>
|
||||
<ul>
|
||||
<li>And lists!</li>
|
||||
<li>With list items.</li>
|
||||
</ul>
|
||||
<p>And also images: <img src="mxc://someimageurl"/></p>`,
|
||||
name: "The name of a community",
|
||||
short_description: "This is a community",
|
||||
},
|
||||
user,
|
||||
users_section: usersSection,
|
||||
rooms_section: roomsSection,
|
||||
};
|
||||
|
||||
summaryResponseWithBadImg = {
|
||||
profile: {
|
||||
avatar_url: "mxc://someavatarurl",
|
||||
is_openly_joinable: true,
|
||||
is_public: true,
|
||||
long_description: '<p>Evil image: <img src="http://evilimageurl"/></p>',
|
||||
name: "The name of a community",
|
||||
short_description: "This is a community",
|
||||
},
|
||||
user,
|
||||
users_section: usersSection,
|
||||
rooms_section: roomsSection,
|
||||
};
|
||||
|
||||
groupId = "+" + Math.random().toString(16).slice(2) + ':domain';
|
||||
groupIdEncoded = encodeURIComponent(groupId);
|
||||
|
||||
rootElement = document.createElement('div');
|
||||
root = ReactDOM.render(<WrappedGroupView groupId={groupId} />, rootElement);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
ReactDOM.unmountComponentAtNode(rootElement);
|
||||
});
|
||||
|
||||
it('should show a spinner when first displayed', function() {
|
||||
ReactTestUtils.findRenderedComponentWithType(root, Spinner);
|
||||
|
||||
// If we don't respond here, the rate limiting done to ensure a maximum of
|
||||
// 3 concurrent network requests for GroupStore will block subsequent requests
|
||||
// in other tests.
|
||||
//
|
||||
// This is a good case for doing the rate limiting somewhere other than the module
|
||||
// scope of GroupStore.js
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
return httpBackend.flush(undefined, undefined, 0);
|
||||
});
|
||||
|
||||
it('should indicate failure after failed /summary', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_error');
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(500, {});
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a group avatar, name, id and short description after successful /summary', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView');
|
||||
|
||||
const avatar = ReactTestUtils.findRenderedComponentWithType(root, sdk.getComponent('avatars.GroupAvatar'));
|
||||
const img = ReactTestUtils.findRenderedDOMComponentWithTag(avatar, 'img');
|
||||
const avatarImgElement = ReactDOM.findDOMNode(img);
|
||||
expect(avatarImgElement).toBeTruthy();
|
||||
expect(avatarImgElement.src).toContain(
|
||||
'https://my.home.server/_matrix/media/r0/thumbnail/' +
|
||||
'someavatarurl?width=28&height=28&method=crop',
|
||||
);
|
||||
|
||||
const name = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_header_name');
|
||||
const nameElement = ReactDOM.findDOMNode(name);
|
||||
expect(nameElement).toBeTruthy();
|
||||
expect(nameElement.textContent).toContain('The name of a community');
|
||||
expect(nameElement.textContent).toContain(groupId);
|
||||
|
||||
const shortDesc = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_header_shortDesc');
|
||||
const shortDescElement = ReactDOM.findDOMNode(shortDesc);
|
||||
expect(shortDescElement).toBeTruthy();
|
||||
expect(shortDescElement.textContent).toBe('This is a community');
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a simple long description after successful /summary', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView');
|
||||
|
||||
const longDesc = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_groupDesc');
|
||||
const longDescElement = ReactDOM.findDOMNode(longDesc);
|
||||
expect(longDescElement).toBeTruthy();
|
||||
expect(longDescElement.textContent).toBe('This is a LONG description.');
|
||||
expect(longDescElement.innerHTML).toBe('<div dir="auto">This is a <b>LONG</b> description.</div>');
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a placeholder if a long description is not set', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
const placeholder = ReactTestUtils
|
||||
.findRenderedDOMComponentWithClass(root, 'mx_GroupView_groupDesc_placeholder');
|
||||
const placeholderElement = ReactDOM.findDOMNode(placeholder);
|
||||
expect(placeholderElement).toBeTruthy();
|
||||
});
|
||||
|
||||
httpBackend
|
||||
.when('GET', '/groups/' + groupIdEncoded + '/summary')
|
||||
.respond(200, summaryResponseWithNoLongDesc);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a complicated long description after successful /summary', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
const longDesc = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_groupDesc');
|
||||
const longDescElement = ReactDOM.findDOMNode(longDesc);
|
||||
expect(longDescElement).toBeTruthy();
|
||||
|
||||
expect(longDescElement.innerHTML).toContain('<h1>This is a more complicated group page</h1>');
|
||||
expect(longDescElement.innerHTML).toContain('<p>With paragraphs</p>');
|
||||
expect(longDescElement.innerHTML).toContain('<ul>');
|
||||
expect(longDescElement.innerHTML).toContain('<li>And lists!</li>');
|
||||
|
||||
const imgSrc = "https://my.home.server/_matrix/media/r0/thumbnail/someimageurl" +
|
||||
"?width=800&height=600&method=scale";
|
||||
expect(longDescElement.innerHTML).toContain('<img src="' + imgSrc + '" ' +
|
||||
'style="max-width:800px;max-height:600px">');
|
||||
});
|
||||
|
||||
httpBackend
|
||||
.when('GET', '/groups/' + groupIdEncoded + '/summary')
|
||||
.respond(200, summaryResponseWithComplicatedLongDesc);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should disallow images with non-mxc URLs', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
const longDesc = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_groupDesc');
|
||||
const longDescElement = ReactDOM.findDOMNode(longDesc);
|
||||
expect(longDescElement).toBeTruthy();
|
||||
|
||||
// If this fails, the URL could be in an img `src`, which is what we care about but
|
||||
// there's no harm in keeping this simple and checking the entire HTML string.
|
||||
expect(longDescElement.innerHTML).not.toContain('evilimageurl');
|
||||
});
|
||||
|
||||
httpBackend
|
||||
.when('GET', '/groups/' + groupIdEncoded + '/summary')
|
||||
.respond(200, summaryResponseWithBadImg);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a RoomDetailList after a successful /summary & /rooms (no rooms returned)', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
const roomDetailList = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_RoomDetailList');
|
||||
const roomDetailListElement = ReactDOM.findDOMNode(roomDetailList);
|
||||
expect(roomDetailListElement).toBeTruthy();
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a RoomDetailList after a successful /summary & /rooms (with a single room)', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
const prom = waitForUpdate(groupView, 4).then(() => {
|
||||
const roomDetailList = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_RoomDetailList');
|
||||
const roomDetailListElement = ReactDOM.findDOMNode(roomDetailList);
|
||||
expect(roomDetailListElement).toBeTruthy();
|
||||
|
||||
const roomDetailListRoomName = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
root,
|
||||
'mx_RoomDirectory_name',
|
||||
);
|
||||
const roomDetailListRoomNameElement = ReactDOM.findDOMNode(roomDetailListRoomName);
|
||||
|
||||
expect(roomDetailListRoomNameElement).toBeTruthy();
|
||||
expect(roomDetailListRoomNameElement.textContent).toEqual('Some room name');
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [{
|
||||
avatar_url: "mxc://someroomavatarurl",
|
||||
canonical_alias: "#somealias:domain",
|
||||
guest_can_join: true,
|
||||
is_public: true,
|
||||
name: "Some room name",
|
||||
num_joined_members: 123,
|
||||
room_id: "!someroomid",
|
||||
topic: "some topic",
|
||||
world_readable: true,
|
||||
}] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it('should show a summary even if /users fails', function() {
|
||||
const groupView = ReactTestUtils.findRenderedComponentWithType(root, GroupView);
|
||||
|
||||
// Only wait for 3 updates in this test since we don't change state for
|
||||
// the /users error case.
|
||||
const prom = waitForUpdate(groupView, 3).then(() => {
|
||||
const shortDesc = ReactTestUtils.findRenderedDOMComponentWithClass(root, 'mx_GroupView_header_shortDesc');
|
||||
const shortDescElement = ReactDOM.findDOMNode(shortDesc);
|
||||
expect(shortDescElement).toBeTruthy();
|
||||
expect(shortDescElement.textContent).toBe('This is a community');
|
||||
});
|
||||
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/summary').respond(200, summaryResponse);
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/users').respond(500, {});
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/invited_users').respond(200, { chunk: [] });
|
||||
httpBackend.when('GET', '/groups/' + groupIdEncoded + '/rooms').respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
});
|
|
@ -48,9 +48,6 @@ jest.mock('../../../../src/utils/space', () => ({
|
|||
showSpacePreferences: jest.fn(),
|
||||
showSpaceSettings: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../../../src/stores/spaces/SpaceStore', () => ({
|
||||
spacesEnabled: true,
|
||||
}));
|
||||
|
||||
describe('<SpaceContextMenu />', () => {
|
||||
const userId = '@test:server';
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import ReactTestUtils from "react-dom/test-utils";
|
||||
import MockHttpBackend from "matrix-mock-request";
|
||||
import * as Matrix from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import sdk from "../../../skinned-sdk";
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
|
||||
const { waitForUpdate } = TestUtils;
|
||||
|
||||
const GroupMemberList = sdk.getComponent("views.groups.GroupMemberList");
|
||||
const WrappedGroupMemberList = TestUtils.wrapInMatrixClientContext(GroupMemberList);
|
||||
|
||||
describe("GroupMemberList", function() {
|
||||
let root;
|
||||
let rootElement;
|
||||
let httpBackend;
|
||||
let summaryResponse;
|
||||
let groupId;
|
||||
let groupIdEncoded;
|
||||
|
||||
// Summary response fields
|
||||
const user = {
|
||||
is_privileged: true, // can edit the group
|
||||
is_public: true, // appear as a member to non-members
|
||||
is_publicised: true, // display flair
|
||||
};
|
||||
const usersSection = {
|
||||
roles: {},
|
||||
total_user_count_estimate: 0,
|
||||
users: [],
|
||||
};
|
||||
const roomsSection = {
|
||||
categories: {},
|
||||
rooms: [],
|
||||
total_room_count_estimate: 0,
|
||||
};
|
||||
|
||||
// Users response fields
|
||||
const usersResponse = {
|
||||
chunk: [
|
||||
{
|
||||
user_id: "@test:matrix.org",
|
||||
displayname: "Test",
|
||||
avatar_url: "mxc://matrix.org/oUxxDyzQOHdVDMxgwFzyCWEe",
|
||||
is_public: true,
|
||||
is_privileged: true,
|
||||
attestation: {},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
httpBackend = new MockHttpBackend();
|
||||
|
||||
Matrix.request(httpBackend.requestFn);
|
||||
|
||||
MatrixClientPeg.get = () => Matrix.createClient({
|
||||
baseUrl: "https://my.home.server",
|
||||
userId: "@me:here",
|
||||
accessToken: "123456789",
|
||||
});
|
||||
|
||||
summaryResponse = {
|
||||
profile: {
|
||||
avatar_url: "mxc://someavatarurl",
|
||||
is_openly_joinable: true,
|
||||
is_public: true,
|
||||
long_description: "This is a <b>LONG</b> description.",
|
||||
name: "The name of a community",
|
||||
short_description: "This is a community",
|
||||
},
|
||||
user,
|
||||
users_section: usersSection,
|
||||
rooms_section: roomsSection,
|
||||
};
|
||||
|
||||
groupId = "+" + Math.random().toString(16).slice(2) + ":domain";
|
||||
groupIdEncoded = encodeURIComponent(groupId);
|
||||
|
||||
rootElement = document.createElement("div");
|
||||
root = ReactDOM.render(<WrappedGroupMemberList groupId={groupId} />, rootElement);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
ReactDOM.unmountComponentAtNode(rootElement);
|
||||
});
|
||||
|
||||
it("should show group member list after successful /users", function() {
|
||||
const groupMemberList = ReactTestUtils.findRenderedComponentWithType(root, GroupMemberList);
|
||||
const prom = waitForUpdate(groupMemberList, 4).then(() => {
|
||||
ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_MemberList");
|
||||
|
||||
const memberList = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_MemberList_joined");
|
||||
const memberListElement = ReactDOM.findDOMNode(memberList);
|
||||
expect(memberListElement).toBeTruthy();
|
||||
const userNameElement = memberListElement.querySelector(".mx_EntityTile_name");
|
||||
expect(userNameElement).toBeTruthy();
|
||||
expect(userNameElement.textContent).toBe("Test");
|
||||
});
|
||||
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/summary").respond(200, summaryResponse);
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/users").respond(200, usersResponse);
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/invited_users").respond(200, { chunk: [] });
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/rooms").respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
|
||||
it("should show error message after failed /users", function() {
|
||||
const groupMemberList = ReactTestUtils.findRenderedComponentWithType(root, GroupMemberList);
|
||||
const prom = waitForUpdate(groupMemberList, 4).then(() => {
|
||||
ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_MemberList");
|
||||
|
||||
const memberList = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_MemberList_joined");
|
||||
const memberListElement = ReactDOM.findDOMNode(memberList);
|
||||
expect(memberListElement).toBeTruthy();
|
||||
expect(memberListElement.textContent).toBe("Failed to load group members");
|
||||
});
|
||||
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/summary").respond(200, summaryResponse);
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/users").respond(500, {});
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/invited_users").respond(200, { chunk: [] });
|
||||
httpBackend.when("GET", "/groups/" + groupIdEncoded + "/rooms").respond(200, { chunk: [] });
|
||||
|
||||
httpBackend.flush(undefined, undefined, 0);
|
||||
return prom;
|
||||
});
|
||||
});
|
|
@ -18,6 +18,7 @@ import React from "react";
|
|||
import { mount } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { ClientWidgetApi, MatrixWidgetType } from "matrix-widget-api";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import "../../../skinned-sdk";
|
||||
import { stubClient, mkStubRoom } from "../../../test-utils";
|
||||
|
@ -30,9 +31,8 @@ import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/Voi
|
|||
import { DefaultTagID } from "../../../../src/stores/room-list/models";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import { VOICE_CHANNEL_ID } from "../../../../src/utils/VoiceChannelUtils";
|
||||
import { mocked } from "jest-mock";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import PlatformPeg from "../../../../src/PlatformPeg";
|
||||
import PlatformPeg from "../../../../src/PlatformPeg";
|
||||
import BasePlatform from "../../../../src/BasePlatform";
|
||||
|
||||
describe("RoomTile", () => {
|
||||
|
|
|
@ -25,7 +25,7 @@ jest.mock('../../../../src/settings/SettingsStore');
|
|||
|
||||
describe('<UiFeatureSettingWrapper>', () => {
|
||||
const defaultProps = {
|
||||
uiFeature: UIFeature.Flair,
|
||||
uiFeature: UIFeature.Feedback,
|
||||
children: <div>test</div>,
|
||||
};
|
||||
const getComponent = (props = {}) => mount(<UiFeatureSettingWrapper {...defaultProps} {...props} />);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
exports[`<UiFeatureSettingWrapper> renders children when setting is truthy 1`] = `
|
||||
<UiFeatureSettingWrapper
|
||||
uiFeature="UIFeature.flair"
|
||||
uiFeature="UIFeature.feedback"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
|
|
|
@ -18,13 +18,13 @@ import { EventEmitter } from "events";
|
|||
import React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import "../../../skinned-sdk";
|
||||
import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test-utils";
|
||||
import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
|
||||
import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import { mocked } from "jest-mock";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
|
||||
const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
|
||||
|
|
|
@ -19,7 +19,6 @@ describe('linkify-matrix', () => {
|
|||
const linkTypesByInitialCharacter = {
|
||||
'#': 'roomalias',
|
||||
'@': 'userid',
|
||||
'+': 'groupid',
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -269,10 +268,6 @@ describe('linkify-matrix', () => {
|
|||
genTests('#');
|
||||
});
|
||||
|
||||
describe('groupid plugin', () => {
|
||||
genTests('+');
|
||||
});
|
||||
|
||||
describe('userid plugin', () => {
|
||||
genTests('@');
|
||||
});
|
||||
|
|
|
@ -68,7 +68,6 @@ export function createTestClient(): MatrixClient {
|
|||
getRoom: jest.fn().mockImplementation(mkStubRoom),
|
||||
getRooms: jest.fn().mockReturnValue([]),
|
||||
getVisibleRooms: jest.fn().mockReturnValue([]),
|
||||
getGroups: jest.fn().mockReturnValue([]),
|
||||
loginFlows: jest.fn(),
|
||||
on: eventEmitter.on.bind(eventEmitter),
|
||||
off: eventEmitter.off.bind(eventEmitter),
|
||||
|
|
|
@ -15,7 +15,6 @@ limitations under the License.
|
|||
|
||||
import { MatrixClientPeg as peg } from '../../../src/MatrixClientPeg';
|
||||
import {
|
||||
makeGroupPermalink,
|
||||
makeRoomPermalink,
|
||||
makeUserPermalink,
|
||||
parsePermalink,
|
||||
|
@ -444,11 +443,6 @@ describe('Permalinks', function() {
|
|||
expect(result).toBe("https://matrix.to/#/@someone:example.org");
|
||||
});
|
||||
|
||||
it('should generate a group permalink', function() {
|
||||
const result = makeGroupPermalink("+community:example.org");
|
||||
expect(result).toBe("https://matrix.to/#/+community:example.org");
|
||||
});
|
||||
|
||||
it('should correctly parse room permalinks with a via argument', () => {
|
||||
const result = parsePermalink("https://matrix.to/#/!room_id:server?via=some.org");
|
||||
expect(result.roomIdOrAlias).toBe("!room_id:server");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue