You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Merge remote-tracking branch 'upstream/develop' into feature/call-event-tile
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -22,8 +22,10 @@ import sdk from "../../../skinned-sdk";
|
||||
import { mkEvent, mkStubRoom } from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import * as languageHandler from "../../../../src/languageHandler";
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
|
||||
const TextualBody = sdk.getComponent("views.messages.TextualBody");
|
||||
const _TextualBody = sdk.getComponent("views.messages.TextualBody");
|
||||
const TextualBody = TestUtils.wrapInMatrixClientContext(_TextualBody);
|
||||
|
||||
configure({ adapter: new Adapter() });
|
||||
|
||||
@@ -302,13 +304,12 @@ describe("<TextualBody />", () => {
|
||||
event: true,
|
||||
});
|
||||
|
||||
const wrapper = mount(<TextualBody mxEvent={ev} showUrlPreview={true} />);
|
||||
const wrapper = mount(<TextualBody mxEvent={ev} showUrlPreview={true} onHeightChanged={() => {}} />);
|
||||
expect(wrapper.text()).toBe(ev.getContent().body);
|
||||
|
||||
let widgets = wrapper.find("LinkPreviewWidget");
|
||||
// at this point we should have exactly one widget
|
||||
expect(widgets.length).toBe(1);
|
||||
expect(widgets.at(0).prop("link")).toBe("https://matrix.org/");
|
||||
let widgets = wrapper.find("LinkPreviewGroup");
|
||||
// at this point we should have exactly one link
|
||||
expect(widgets.at(0).prop("links")).toEqual(["https://matrix.org/"]);
|
||||
|
||||
// simulate an event edit and check the transition from the old URL preview to the new one
|
||||
const ev2 = mkEvent({
|
||||
@@ -333,11 +334,9 @@ describe("<TextualBody />", () => {
|
||||
|
||||
// XXX: this is to give TextualBody enough time for state to settle
|
||||
wrapper.setState({}, () => {
|
||||
widgets = wrapper.find("LinkPreviewWidget");
|
||||
// at this point we should have exactly two widgets (not the matrix.org one anymore)
|
||||
expect(widgets.length).toBe(2);
|
||||
expect(widgets.at(0).prop("link")).toBe("https://vector.im/");
|
||||
expect(widgets.at(1).prop("link")).toBe("https://riot.im/");
|
||||
widgets = wrapper.find("LinkPreviewGroup");
|
||||
// at this point we should have exactly two links (not the matrix.org one anymore)
|
||||
expect(widgets.at(0).prop("links")).toEqual(["https://vector.im/", "https://riot.im/"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import { getLineAndNodePosition } from "../../src/editor/caret";
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { createPartCreator } from "./mock";
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { createPartCreator, createRenderer } from "./mock";
|
||||
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { createPartCreator, createRenderer } from "./mock";
|
||||
import { toggleInlineFormat } from "../../src/editor/operations";
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { createPartCreator } from "./mock";
|
||||
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { createPartCreator, createRenderer } from "./mock";
|
||||
|
||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import EditorModel from "../../src/editor/model";
|
||||
import { htmlSerializeIfNeeded } from "../../src/editor/serialize";
|
||||
import { createPartCreator } from "./mock";
|
||||
|
@@ -572,11 +572,11 @@ uploads_path: "{{SYNAPSE_ROOT}}uploads"
|
||||
## Captcha ##
|
||||
# See docs/CAPTCHA_SETUP for full details of configuring this.
|
||||
|
||||
# This Home Server's ReCAPTCHA public key.
|
||||
# This homeserver's ReCAPTCHA public key.
|
||||
#
|
||||
#recaptcha_public_key: "YOUR_PUBLIC_KEY"
|
||||
|
||||
# This Home Server's ReCAPTCHA private key.
|
||||
# This homeserver's ReCAPTCHA private key.
|
||||
#
|
||||
#recaptcha_private_key: "YOUR_PRIVATE_KEY"
|
||||
|
||||
@@ -685,7 +685,7 @@ registration_shared_secret: "{{REGISTRATION_SHARED_SECRET}}"
|
||||
# The list of identity servers trusted to verify third party
|
||||
# identifiers by this server.
|
||||
#
|
||||
# Also defines the ID server which will be called when an account is
|
||||
# Also defines the identity server which will be called when an account is
|
||||
# deactivated (one will be picked arbitrarily).
|
||||
#
|
||||
#trusted_third_party_id_servers:
|
||||
@@ -889,7 +889,7 @@ email:
|
||||
smtp_user: "exampleusername"
|
||||
smtp_pass: "examplepassword"
|
||||
require_transport_security: False
|
||||
notif_from: "Your Friendly %(app)s Home Server <noreply@example.com>"
|
||||
notif_from: "Your Friendly %(app)s homeserver <noreply@example.com>"
|
||||
app_name: Matrix
|
||||
# if template_dir is unset, uses the example templates that are part of
|
||||
# the Synapse distribution.
|
||||
|
23
test/stores/SpaceStore-setup.ts
Normal file
23
test/stores/SpaceStore-setup.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// This needs to be executed before the SpaceStore gets imported but due to ES6 import hoisting we have to do this here.
|
||||
// SpaceStore reads the SettingsStore which needs the localStorage values set at init time.
|
||||
|
||||
localStorage.setItem("mx_labs_feature_feature_spaces", "true");
|
||||
localStorage.setItem("mx_labs_feature_feature_spaces.all_rooms", "true");
|
||||
localStorage.setItem("mx_labs_feature_feature_spaces.space_member_dms", "true");
|
||||
localStorage.setItem("mx_labs_feature_feature_spaces.space_dm_badges", "false");
|
@@ -16,7 +16,9 @@ limitations under the License.
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
|
||||
import "./SpaceStore-setup"; // enable space lab
|
||||
import "../skinned-sdk"; // Must be first for skinning to work
|
||||
import SpaceStore, {
|
||||
UPDATE_INVITED_SPACES,
|
||||
@@ -26,13 +28,10 @@ import SpaceStore, {
|
||||
import { resetAsyncStoreWithClient, setupAsyncStoreWithClient } from "../utils/test-utils";
|
||||
import { mkEvent, mkStubRoom, stubClient } from "../test-utils";
|
||||
import { EnhancedMap } from "../../src/utils/maps";
|
||||
import SettingsStore from "../../src/settings/SettingsStore";
|
||||
import DMRoomMap from "../../src/utils/DMRoomMap";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
||||
|
||||
type MatrixEvent = any; // importing from js-sdk upsets things
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
const mockStateEventImplementation = (events: MatrixEvent[]) => {
|
||||
@@ -79,9 +78,6 @@ const mkSpace = (spaceId: string, children: string[] = []) => {
|
||||
return space;
|
||||
};
|
||||
|
||||
const getValue = jest.fn();
|
||||
SettingsStore.getValue = getValue;
|
||||
|
||||
const getUserIdForRoomId = jest.fn();
|
||||
// @ts-ignore
|
||||
DMRoomMap.sharedInstance = { getUserIdForRoomId };
|
||||
@@ -122,18 +118,6 @@ describe("SpaceStore", () => {
|
||||
beforeEach(() => {
|
||||
jest.runAllTimers();
|
||||
client.getVisibleRooms.mockReturnValue(rooms = []);
|
||||
getValue.mockImplementation(settingName => {
|
||||
switch (settingName) {
|
||||
case "feature_spaces":
|
||||
return true;
|
||||
case "feature_spaces.all_rooms":
|
||||
return true;
|
||||
case "feature_spaces.space_member_dms":
|
||||
return true;
|
||||
case "feature_spaces.space_dm_badges":
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
afterEach(async () => {
|
||||
await resetAsyncStoreWithClient(store);
|
||||
|
@@ -96,6 +96,7 @@ export function createTestClient() {
|
||||
},
|
||||
},
|
||||
decryptEventIfNeeded: () => Promise.resolve(),
|
||||
isUserIgnored: jest.fn().mockReturnValue(false),
|
||||
};
|
||||
}
|
||||
|
||||
|
35
test/utils/AnimationUtils-test.ts
Normal file
35
test/utils/AnimationUtils-test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
|
||||
|
||||
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 { lerp } from "../../src/utils/AnimationUtils";
|
||||
|
||||
describe("lerp", () => {
|
||||
it("correctly interpolates", () => {
|
||||
expect(lerp(0, 100, 0.5)).toBe(50);
|
||||
expect(lerp(50, 100, 0.5)).toBe(75);
|
||||
expect(lerp(0, 1, 0.1)).toBe(0.1);
|
||||
});
|
||||
|
||||
it("clamps the interpolant", () => {
|
||||
expect(lerp(0, 100, 50)).toBe(100);
|
||||
expect(lerp(0, 100, -50)).toBe(0);
|
||||
});
|
||||
|
||||
it("handles negative numbers", () => {
|
||||
expect(lerp(-100, 0, 0.5)).toBe(-50);
|
||||
expect(lerp(100, -100, 0.5)).toBe(0);
|
||||
});
|
||||
});
|
65
test/utils/FixedRollingArray-test.ts
Normal file
65
test/utils/FixedRollingArray-test.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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 { FixedRollingArray } from "../../src/utils/FixedRollingArray";
|
||||
|
||||
describe('FixedRollingArray', () => {
|
||||
it('should seed the array with the given value', () => {
|
||||
const seed = "test";
|
||||
const width = 24;
|
||||
const array = new FixedRollingArray(width, seed);
|
||||
|
||||
expect(array.value.length).toBe(width);
|
||||
expect(array.value.every(v => v === seed)).toBe(true);
|
||||
});
|
||||
|
||||
it('should insert at the correct end', () => {
|
||||
const seed = "test";
|
||||
const value = "changed";
|
||||
const width = 24;
|
||||
const array = new FixedRollingArray(width, seed);
|
||||
array.pushValue(value);
|
||||
|
||||
expect(array.value.length).toBe(width);
|
||||
expect(array.value[0]).toBe(value);
|
||||
});
|
||||
|
||||
it('should roll over', () => {
|
||||
const seed = -1;
|
||||
const width = 24;
|
||||
const array = new FixedRollingArray(width, seed);
|
||||
|
||||
const maxValue = width * 2;
|
||||
const minValue = width; // because we're forcing a rollover
|
||||
for (let i = 0; i <= maxValue; i++) {
|
||||
array.pushValue(i);
|
||||
}
|
||||
|
||||
expect(array.value.length).toBe(width);
|
||||
|
||||
for (let i = 1; i < width; i++) {
|
||||
const current = array.value[i];
|
||||
const previous = array.value[i - 1];
|
||||
expect(previous - current).toBe(1);
|
||||
|
||||
if (i === 1) {
|
||||
expect(previous).toBe(maxValue);
|
||||
} else if (i === width) {
|
||||
expect(current).toBe(minValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user