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

🧵 Enable threads by default (#9736)

* Delabs threads

* remove threads reload when labs is toggled

* Fix ts strict

* fix rebase mistake

* remove .only

* fix pr comments

* re-introduce backwards compat

* Fix export test

* Fix SearchREsultTile test

* strict ts
This commit is contained in:
Germain
2022-12-13 15:09:15 +00:00
committed by GitHub
parent 9668a24ca7
commit 2d2755d145
32 changed files with 88 additions and 170 deletions

View File

@@ -169,6 +169,7 @@ describe("TimelinePanel", () => {
const getValueCopy = SettingsStore.getValue;
SettingsStore.getValue = jest.fn().mockImplementation((name: string) => {
if (name === "sendReadReceipts") return true;
if (name === "feature_threadstable") return false;
return getValueCopy(name);
});
@@ -182,6 +183,7 @@ describe("TimelinePanel", () => {
const getValueCopy = SettingsStore.getValue;
SettingsStore.getValue = jest.fn().mockImplementation((name: string) => {
if (name === "sendReadReceipts") return false;
if (name === "feature_threadstable") return false;
return getValueCopy(name);
});
@@ -358,7 +360,7 @@ describe("TimelinePanel", () => {
client.supportsExperimentalThreads = () => true;
const getValueCopy = SettingsStore.getValue;
SettingsStore.getValue = jest.fn().mockImplementation((name: string) => {
if (name === "feature_thread") return true;
if (name === "feature_threadstable") return true;
return getValueCopy(name);
});

View File

@@ -386,6 +386,12 @@ describe("<MessageActionBar />", () => {
});
describe("when threads feature is not enabled", () => {
beforeEach(() => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(setting) => setting !== "feature_threadstable",
);
});
it("does not render thread button when threads does not have server support", () => {
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
Thread.setServerSideSupport(FeatureSupport.None);
@@ -416,7 +422,9 @@ describe("<MessageActionBar />", () => {
describe("when threads feature is enabled", () => {
beforeEach(() => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => setting === "feature_thread");
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(setting) => setting === "feature_threadstable",
);
});
it("renders thread button on own actionable event", () => {

View File

@@ -40,7 +40,7 @@ describe("RoomHeaderButtons-test.tsx", function () {
});
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
if (name === "feature_thread") return true;
if (name === "feature_threadstable") return true;
});
});

View File

@@ -73,7 +73,7 @@ describe("EventTile", () => {
jest.spyOn(client, "getRoom").mockReturnValue(room);
jest.spyOn(client, "decryptEventIfNeeded").mockResolvedValue();
jest.spyOn(SettingsStore, "getValue").mockImplementation((name) => name === "feature_thread");
jest.spyOn(SettingsStore, "getValue").mockImplementation((name) => name === "feature_threadstable");
mxEvent = mkMessage({
room: room.roomId,

View File

@@ -19,14 +19,21 @@ import { SearchResult } from "matrix-js-sdk/src/models/search-result";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { EventType } from "matrix-js-sdk/src/@types/event";
import { render } from "@testing-library/react";
import { Room } from "matrix-js-sdk/src/models/room";
import { createTestClient } from "../../../test-utils";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import { stubClient } from "../../../test-utils";
import SearchResultTile from "../../../../src/components/views/rooms/SearchResultTile";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
const ROOM_ID = "!qPewotXpIctQySfjSy:localhost";
describe("SearchResultTile", () => {
beforeAll(() => {
MatrixClientPeg.get = () => createTestClient();
stubClient();
const cli = MatrixClientPeg.get();
const room = new Room(ROOM_ID, cli, "@bob:example.org");
jest.spyOn(cli, "getRoom").mockReturnValue(room);
});
it("Sets up appropriate callEventGrouper for m.call. events", () => {
@@ -44,7 +51,7 @@ describe("SearchResultTile", () => {
},
event_id: "$144429830826TWwbB:localhost",
origin_server_ts: 1432735824653,
room_id: "!qPewotXpIctQySfjSy:localhost",
room_id: ROOM_ID,
sender: "@example:example.org",
type: "m.room.message",
unsigned: {
@@ -59,7 +66,7 @@ describe("SearchResultTile", () => {
{
type: EventType.CallInvite,
sender: "@user1:server",
room_id: "!qPewotXpIctQySfjSy:localhost",
room_id: ROOM_ID,
origin_server_ts: 1432735824652,
content: { call_id: "call.1" },
event_id: "$1:server",
@@ -69,7 +76,7 @@ describe("SearchResultTile", () => {
{
type: EventType.CallAnswer,
sender: "@user2:server",
room_id: "!qPewotXpIctQySfjSy:localhost",
room_id: ROOM_ID,
origin_server_ts: 1432735824654,
content: { call_id: "call.1" },
event_id: "$2:server",

View File

@@ -80,7 +80,7 @@ exports[`<SecurityUserSettingsTab /> renders settings marked as beta as beta car
class="mx_BetaCard_title"
>
<span>
Threads
Threaded messages
</span>
<span
class="mx_BetaCard_betaPill"
@@ -124,9 +124,6 @@ exports[`<SecurityUserSettingsTab /> renders settings marked as beta as beta car
>
Joining the beta will reload .
</div>
<div
class="mx_BetaCard_faq"
/>
</div>
<div
class="mx_BetaCard_columns_image_wrapper"
@@ -134,7 +131,6 @@ exports[`<SecurityUserSettingsTab /> renders settings marked as beta as beta car
<img
alt=""
class="mx_BetaCard_columns_image"
src="image-file-stub"
/>
</div>
</div>

View File

@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { mocked } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import TypingStore from "../../src/stores/TypingStore";
@@ -31,10 +30,6 @@ jest.mock("../../src/settings/SettingsStore", () => ({
describe("TypingStore", () => {
let typingStore: TypingStore;
let mockClient: MatrixClient;
const settings = {
sendTypingNotifications: true,
feature_thread: false,
};
const roomId = "!test:example.com";
const localRoomId = LOCAL_ROOM_ID_PREFIX + "test";
@@ -45,8 +40,8 @@ describe("TypingStore", () => {
const context = new TestSdkContext();
context.client = mockClient;
typingStore = new TypingStore(context);
mocked(SettingsStore.getValue).mockImplementation((setting: string) => {
return settings[setting];
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
return name === "sendTypingNotifications";
});
});

View File

@@ -45,25 +45,32 @@ interface ITestContent extends IContent {
}
describe("export", function () {
stubClient();
client = MatrixClientPeg.get();
client.getUserId = () => {
return MY_USER_ID;
};
let mockExportOptions: IExportOptions;
let mockRoom: Room;
let ts0: number;
let events: MatrixEvent[];
beforeEach(() => {
stubClient();
client = MatrixClientPeg.get();
client.getUserId = () => {
return MY_USER_ID;
};
const mockExportOptions: IExportOptions = {
numberOfMessages: 5,
maxSize: 100 * 1024 * 1024,
attachmentsIncluded: false,
};
mockExportOptions = {
numberOfMessages: 5,
maxSize: 100 * 1024 * 1024,
attachmentsIncluded: false,
};
function createRoom() {
const room = new Room(generateRoomId(), null, client.getUserId());
return room;
}
const mockRoom = createRoom();
const ts0 = Date.now();
function createRoom() {
const room = new Room(generateRoomId(), null, client.getUserId());
return room;
}
mockRoom = createRoom();
ts0 = Date.now();
events = mkEvents();
jest.spyOn(client, "getRoom").mockReturnValue(mockRoom);
});
function mkRedactedEvent(i = 0) {
return new MatrixEvent({
@@ -218,8 +225,6 @@ describe("export", function () {
return matrixEvents;
}
const events: MatrixEvent[] = mkEvents();
it("checks if the export format is valid", function () {
function isValidFormat(format: string): boolean {
const options: string[] = Object.values(ExportFormat);