diff --git a/cypress/e2e/polls/polls.spec.ts b/cypress/e2e/polls/polls.spec.ts index 34f5a7675c..fd8ad33056 100644 --- a/cypress/e2e/polls/polls.spec.ts +++ b/cypress/e2e/polls/polls.spec.ts @@ -77,7 +77,6 @@ describe("Polls", () => { }; beforeEach(() => { - cy.enableLabsFeature("feature_thread"); cy.window().then((win) => { win.localStorage.setItem("mx_lhs_size", "0"); // Collapse left panel for these tests }); diff --git a/cypress/e2e/threads/threads.spec.ts b/cypress/e2e/threads/threads.spec.ts index 3277c740bf..6736df35b1 100644 --- a/cypress/e2e/threads/threads.spec.ts +++ b/cypress/e2e/threads/threads.spec.ts @@ -19,17 +19,10 @@ limitations under the License. import { SynapseInstance } from "../../plugins/synapsedocker"; import { MatrixClient } from "../../global"; -function markWindowBeforeReload(): void { - // mark our window object to "know" when it gets reloaded - cy.window().then((w) => (w.beforeReload = true)); -} - describe("Threads", () => { let synapse: SynapseInstance; beforeEach(() => { - // Default threads to ON for this spec - cy.enableLabsFeature("feature_thread"); cy.window().then((win) => { win.localStorage.setItem("mx_lhs_size", "0"); // Collapse left panel for these tests }); @@ -44,35 +37,6 @@ describe("Threads", () => { cy.stopSynapse(synapse); }); - it("should reload when enabling threads beta", () => { - markWindowBeforeReload(); - - // Turn off - cy.openUserSettings("Labs").within(() => { - // initially the new property is there - cy.window().should("have.prop", "beforeReload", true); - - cy.leaveBeta("Threads"); - cy.wait(1000); - // after reload the property should be gone - cy.window().should("not.have.prop", "beforeReload"); - }); - - cy.get(".mx_MatrixChat", { timeout: 15000 }); // wait for the app - markWindowBeforeReload(); - - // Turn on - cy.openUserSettings("Labs").within(() => { - // initially the new property is there - cy.window().should("have.prop", "beforeReload", true); - - cy.joinBeta("Threads"); - cy.wait(1000); - // after reload the property should be gone - cy.window().should("not.have.prop", "beforeReload"); - }); - }); - it("should be usable for a conversation", () => { let bot: MatrixClient; cy.getBot(synapse, { diff --git a/res/css/views/messages/_MessageActionBar.pcss b/res/css/views/messages/_MessageActionBar.pcss index 345fcb5cb7..04ef242f93 100644 --- a/res/css/views/messages/_MessageActionBar.pcss +++ b/res/css/views/messages/_MessageActionBar.pcss @@ -118,13 +118,6 @@ limitations under the License. color: $primary-content; } - &.mx_MessageActionBar_threadButton { - .mx_Indicator { - background: $links; - animation-iteration-count: infinite; - } - } - &.mx_MessageActionBar_favouriteButton_fillstar { color: var(--MessageActionBar-star-button-color); } diff --git a/res/img/betas/threads.png b/res/img/betas/threads.png deleted file mode 100644 index f34fb5f895..0000000000 Binary files a/res/img/betas/threads.png and /dev/null differ diff --git a/src/MatrixClientPeg.ts b/src/MatrixClientPeg.ts index f88898dd17..04c38a36ce 100644 --- a/src/MatrixClientPeg.ts +++ b/src/MatrixClientPeg.ts @@ -233,7 +233,7 @@ class MatrixClientPegClass implements IMatrixClientPeg { opts.pendingEventOrdering = PendingEventOrdering.Detached; opts.lazyLoadMembers = true; opts.clientWellKnownPollPeriod = 2 * 60 * 60; // 2 hours - opts.experimentalThreadSupport = SettingsStore.getValue("feature_thread"); + opts.experimentalThreadSupport = SettingsStore.getValue("feature_threadstable"); if (SettingsStore.getValue("feature_sliding_sync")) { const proxyUrl = SettingsStore.getValue("feature_sliding_sync_proxy_url"); diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 93d434b244..16cdabc2a1 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -287,7 +287,7 @@ export default class MessagePanel extends React.Component { // and we check this in a hot code path. This is also cached in our // RoomContext, however we still need a fallback for roomless MessagePanels. this._showHiddenEvents = SettingsStore.getValue("showHiddenEventsInTimeline"); - this.threadsEnabled = SettingsStore.getValue("feature_thread"); + this.threadsEnabled = SettingsStore.getValue("feature_threadstable"); this.showTypingNotificationsWatcherRef = SettingsStore.watchSetting( "showTypingNotifications", diff --git a/src/components/structures/RoomSearchView.tsx b/src/components/structures/RoomSearchView.tsx index 0e44a16818..81e76ddfb9 100644 --- a/src/components/structures/RoomSearchView.tsx +++ b/src/components/structures/RoomSearchView.tsx @@ -33,6 +33,7 @@ import ResizeNotifier from "../../utils/ResizeNotifier"; import MatrixClientContext from "../../contexts/MatrixClientContext"; import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks"; import RoomContext from "../../contexts/RoomContext"; +import SettingsStore from "../../settings/SettingsStore"; const DEBUG = false; let debuglog = function (msg: string) {}; @@ -98,7 +99,7 @@ export const RoomSearchView = forwardRef( return b.length - a.length; }); - if (client.supportsExperimentalThreads()) { + if (SettingsStore.getValue("feature_threadstable")) { // Process all thread roots returned in this batch of search results // XXX: This won't work for results coming from Seshat which won't include the bundled relationship for (const result of results.results) { diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index ef57465d3b..da13e32894 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1177,7 +1177,7 @@ export class RoomView extends React.Component { CHAT_EFFECTS.forEach((effect) => { if (containsEmoji(ev.getContent(), effect.emojis) || ev.getContent().msgtype === effect.msgType) { // For initial threads launch, chat effects are disabled see #19731 - if (!SettingsStore.getValue("feature_thread") || !ev.isRelation(THREAD_RELATION_TYPE.name)) { + if (!SettingsStore.getValue("feature_threadstable") || !ev.isRelation(THREAD_RELATION_TYPE.name)) { dis.dispatch({ action: `effects.${effect.command}` }); } } diff --git a/src/components/structures/ThreadPanel.tsx b/src/components/structures/ThreadPanel.tsx index 793b6f93f5..51990a739d 100644 --- a/src/components/structures/ThreadPanel.tsx +++ b/src/components/structures/ThreadPanel.tsx @@ -249,7 +249,7 @@ const ThreadPanel: React.FC = ({ roomId, onClose, permalinkCreator }) => const openFeedback = shouldShowFeedback() ? () => { Modal.createDialog(BetaFeedbackDialog, { - featureId: "feature_thread", + featureId: "feature_threadstable", }); } : null; diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index a066272bdb..72063cab14 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -1683,7 +1683,7 @@ class TimelinePanel extends React.Component { is very tied to the main room timeline, we are forcing the timeline to send read receipts for threaded events */ const isThreadTimeline = this.context.timelineRenderingType === TimelineRenderingType.Thread; - if (SettingsStore.getValue("feature_thread") && isThreadTimeline) { + if (SettingsStore.getValue("feature_threadstable") && isThreadTimeline) { return 0; } const index = this.state.events.findIndex((ev) => ev.getId() === evId); diff --git a/src/components/views/context_menus/MessageContextMenu.tsx b/src/components/views/context_menus/MessageContextMenu.tsx index b175ea0593..f0c27defde 100644 --- a/src/components/views/context_menus/MessageContextMenu.tsx +++ b/src/components/views/context_menus/MessageContextMenu.tsx @@ -71,11 +71,7 @@ const ReplyInThreadButton = ({ mxEvent, closeMenu }: IReplyInThreadButton) => { if (Boolean(relationType) && relationType !== RelationType.Thread) return null; const onClick = (): void => { - if (!localStorage.getItem("mx_seen_feature_thread")) { - localStorage.setItem("mx_seen_feature_thread", "true"); - } - - if (!SettingsStore.getValue("feature_thread")) { + if (!SettingsStore.getValue("feature_threadstable")) { dis.dispatch({ action: Action.ViewUserSettings, initialTabId: UserTab.Labs, @@ -644,7 +640,7 @@ export default class MessageContextMenu extends React.Component rightClick && contentActionable && canSendMessages && - SettingsStore.getValue("feature_thread") && + SettingsStore.getValue("feature_threadstable") && Thread.hasServerSideSupport && timelineRenderingType !== TimelineRenderingType.Thread ) { diff --git a/src/components/views/messages/MessageActionBar.tsx b/src/components/views/messages/MessageActionBar.tsx index 7052b971c3..3cac66a79c 100644 --- a/src/components/views/messages/MessageActionBar.tsx +++ b/src/components/views/messages/MessageActionBar.tsx @@ -56,7 +56,6 @@ import { Key } from "../../../Keyboard"; import { ALTERNATE_KEY_NAME } from "../../../accessibility/KeyboardShortcuts"; import { UserTab } from "../dialogs/UserTab"; import { Action } from "../../../dispatcher/actions"; -import SdkConfig from "../../../SdkConfig"; import { ShowThreadPayload } from "../../../dispatcher/payloads/ShowThreadPayload"; import useFavouriteMessages from "../../../hooks/useFavouriteMessages"; import { GetRelationsForEvent } from "../rooms/EventTile"; @@ -204,8 +203,7 @@ const ReplyInThreadButton = ({ mxEvent }: IReplyInThreadButton) => { const relationType = mxEvent?.getRelation()?.rel_type; const hasARelation = !!relationType && relationType !== RelationType.Thread; - const firstTimeSeeingThreads = !localStorage.getItem("mx_seen_feature_thread"); - const threadsEnabled = SettingsStore.getValue("feature_thread"); + const threadsEnabled = SettingsStore.getValue("feature_threadstable"); if (!threadsEnabled && !Thread.hasServerSideSupport) { // hide the prompt if the user would only have degraded mode @@ -217,11 +215,7 @@ const ReplyInThreadButton = ({ mxEvent }: IReplyInThreadButton) => { e.preventDefault(); e.stopPropagation(); - if (firstTimeSeeingThreads) { - localStorage.setItem("mx_seen_feature_thread", "true"); - } - - if (!SettingsStore.getValue("feature_thread")) { + if (!SettingsStore.getValue("feature_threadstable")) { dis.dispatch({ action: Action.ViewUserSettings, initialTabId: UserTab.Labs, @@ -257,7 +251,7 @@ const ReplyInThreadButton = ({ mxEvent }: IReplyInThreadButton) => { {!hasARelation && (
- {SettingsStore.getValue("feature_thread") + {SettingsStore.getValue("feature_threadstable") ? _t("Beta feature") : _t("Beta feature. Click to learn more.")}
@@ -273,7 +267,6 @@ const ReplyInThreadButton = ({ mxEvent }: IReplyInThreadButton) => { onContextMenu={onClick} > - {firstTimeSeeingThreads && !threadsEnabled &&
} ); }; @@ -393,21 +386,6 @@ export default class MessageActionBar extends React.PureComponent { ); rightPanelPhaseButtons.set( RightPanelPhases.ThreadPanel, - SettingsStore.getValue("feature_thread") ? ( + SettingsStore.getValue("feature_threadstable") ? ( } } - if (SettingsStore.getValue("feature_thread")) { + if (SettingsStore.getValue("feature_threadstable")) { this.props.mxEvent.on(ThreadEvent.Update, this.updateThread); if (this.thread && !this.supportsThreadNotifications) { @@ -469,7 +469,7 @@ export class UnwrappedEventTile extends React.Component if (this.props.showReactions) { this.props.mxEvent.removeListener(MatrixEventEvent.RelationsCreated, this.onReactionsCreated); } - if (SettingsStore.getValue("feature_thread")) { + if (SettingsStore.getValue("feature_threadstable")) { this.props.mxEvent.off(ThreadEvent.Update, this.updateThread); } this.threadState?.off(NotificationStateEvents.Update, this.onThreadStateUpdate); @@ -496,7 +496,7 @@ export class UnwrappedEventTile extends React.Component }; private get thread(): Thread | null { - if (!SettingsStore.getValue("feature_thread")) { + if (!SettingsStore.getValue("feature_threadstable")) { return null; } diff --git a/src/components/views/rooms/SearchResultTile.tsx b/src/components/views/rooms/SearchResultTile.tsx index 41fd3b9779..ee13f4eda1 100644 --- a/src/components/views/rooms/SearchResultTile.tsx +++ b/src/components/views/rooms/SearchResultTile.tsx @@ -67,7 +67,7 @@ export default class SearchResultTile extends React.Component { const layout = SettingsStore.getValue("layout"); const isTwelveHour = SettingsStore.getValue("showTwelveHourTimestamps"); const alwaysShowTimestamps = SettingsStore.getValue("alwaysShowTimestamps"); - const threadsEnabled = SettingsStore.getValue("feature_thread"); + const threadsEnabled = SettingsStore.getValue("feature_threadstable"); const timeline = result.context.getTimeline(); for (let j = 0; j < timeline.length; j++) { diff --git a/src/components/views/rooms/SendMessageComposer.tsx b/src/components/views/rooms/SendMessageComposer.tsx index cbe010ec75..69ac235efa 100644 --- a/src/components/views/rooms/SendMessageComposer.tsx +++ b/src/components/views/rooms/SendMessageComposer.tsx @@ -436,7 +436,7 @@ export class SendMessageComposer extends React.ComponentLearn more.": "Threads help keep conversations on-topic and easy to track. Learn more.", - "How can I start a thread?": "How can I start a thread?", - "Use “%(replyInThread)s” when hovering over a message.": "Use “%(replyInThread)s” when hovering over a message.", - "Reply in thread": "Reply in thread", - "How can I leave the beta?": "How can I leave the beta?", - "To leave, return to this page and use the “%(leaveTheBeta)s” button.": "To leave, return to this page and use the “%(leaveTheBeta)s” button.", - "Leave the beta": "Leave the beta", "Rich text editor": "Rich text editor", "Use rich text instead of Markdown in the message composer. Plain text mode coming soon.": "Use rich text instead of Markdown in the message composer. Plain text mode coming soon.", "Render simple counters in room header": "Render simple counters in room header", @@ -2322,6 +2316,7 @@ "Error processing audio message": "Error processing audio message", "View live location": "View live location", "React": "React", + "Reply in thread": "Reply in thread", "Can't create a thread from an event with an existing relation": "Can't create a thread from an event with an existing relation", "Beta feature": "Beta feature", "Beta feature. Click to learn more.": "Beta feature. Click to learn more.", @@ -3198,6 +3193,7 @@ "Beta": "Beta", "Leaving the beta will reload %(brand)s.": "Leaving the beta will reload %(brand)s.", "Joining the beta will reload %(brand)s.": "Joining the beta will reload %(brand)s.", + "Leave the beta": "Leave the beta", "Join the beta": "Join the beta", "Updated %(humanizedUpdateTime)s": "Updated %(humanizedUpdateTime)s", "Live until %(expiryTime)s": "Live until %(expiryTime)s", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 7451406c20..3a4a6ef8c3 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -255,15 +255,15 @@ export const SETTINGS: { [setting: string]: ISetting } = { supportedLevels: LEVELS_FEATURE, default: false, }, - "feature_thread": { + "feature_threadstable": { isFeature: true, labsGroup: LabGroup.Messaging, controller: new ThreadBetaController(), - displayName: _td("Threaded messaging"), + displayName: _td("Threaded messages"), supportedLevels: LEVELS_FEATURE, - default: false, + default: true, betaInfo: { - title: _td("Threads"), + title: _td("Threaded messages"), caption: () => ( <>

{_t("Keep discussions organised with threads.")}

@@ -282,28 +282,6 @@ export const SETTINGS: { [setting: string]: ISetting } = {

), - faq: () => - SdkConfig.get().bug_report_endpoint_url && ( - <> -

{_t("How can I start a thread?")}

-

- {_t("Use “%(replyInThread)s” when hovering over a message.", { - replyInThread: _t("Reply in thread"), - })} -

-

{_t("How can I leave the beta?")}

-

- {_t("To leave, return to this page and use the “%(leaveTheBeta)s” button.", { - leaveTheBeta: _t("Leave the beta"), - })} -

- - ), - feedbackLabel: "thread-feedback", - feedbackSubheading: _td( - "Thank you for trying the beta, " + "please go into as much detail as you can so we can improve it.", - ), - image: require("../../res/img/betas/threads.png"), requiresRefresh: true, }, }, diff --git a/src/stores/TypingStore.ts b/src/stores/TypingStore.ts index eda408f84f..4895b5594a 100644 --- a/src/stores/TypingStore.ts +++ b/src/stores/TypingStore.ts @@ -65,7 +65,7 @@ export default class TypingStore { if (SettingsStore.getValue("lowBandwidth")) return; // Disable typing notification for threads for the initial launch // before we figure out a better user experience for them - if (SettingsStore.getValue("feature_thread") && threadId) return; + if (SettingsStore.getValue("feature_threadstable") && threadId) return; let currentTyping = this.typingStates[roomId]; if ((!isTyping && !currentTyping) || (currentTyping && currentTyping.isTyping === isTyping)) { diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index b1ed89a80a..b9e218b369 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -278,10 +278,10 @@ export default class RightPanelStore extends ReadyWatchingStore { // (A nicer fix could be to indicate, that the right panel is loading if there is missing state data and re-emit if the data is available) switch (card.phase) { case RightPanelPhases.ThreadPanel: - if (!SettingsStore.getValue("feature_thread")) return false; + if (!SettingsStore.getValue("feature_threadstable")) return false; break; case RightPanelPhases.ThreadView: - if (!SettingsStore.getValue("feature_thread")) return false; + if (!SettingsStore.getValue("feature_threadstable")) return false; if (!card.state.threadHeadEvent) { logger.warn("removed card from right panel because of missing threadHeadEvent in card state"); } diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index 4ad4feaa52..6aa72b9a9b 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -236,7 +236,7 @@ export class StopGapWidgetDriver extends WidgetDriver { // For initial threads launch, chat effects are disabled // see #19731 const isNotThread = content["m.relates_to"].rel_type !== THREAD_RELATION_TYPE.name; - if (!SettingsStore.getValue("feature_thread") || isNotThread) { + if (!SettingsStore.getValue("feature_threadstable") || isNotThread) { dis.dispatch({ action: `effects.${effect.command}` }); } } diff --git a/src/utils/Reply.ts b/src/utils/Reply.ts index c6f1778c04..b6ee476bf6 100644 --- a/src/utils/Reply.ts +++ b/src/utils/Reply.ts @@ -176,7 +176,7 @@ export function makeReplyMixIn(ev?: MatrixEvent): IEventRelation { }; if (ev.threadRootId) { - if (SettingsStore.getValue("feature_thread")) { + if (SettingsStore.getValue("feature_threadstable")) { mixin.is_falling_back = false; } else { // Clients that do not offer a threading UI should behave as follows when replying, for best interaction @@ -203,7 +203,7 @@ export function shouldDisplayReply(event: MatrixEvent): boolean { const relation = event.getRelation(); if ( - SettingsStore.getValue("feature_thread") && + SettingsStore.getValue("feature_threadstable") && relation?.rel_type === THREAD_RELATION_TYPE.name && relation?.is_falling_back ) { diff --git a/src/utils/exportUtils/HtmlExport.tsx b/src/utils/exportUtils/HtmlExport.tsx index e732ec0efa..2c7d6aebd6 100644 --- a/src/utils/exportUtils/HtmlExport.tsx +++ b/src/utils/exportUtils/HtmlExport.tsx @@ -62,7 +62,7 @@ export default class HTMLExporter extends Exporter { this.mediaOmitText = !this.exportOptions.attachmentsIncluded ? _t("Media omitted") : _t("Media omitted - file size limit exceeded"); - this.threadsEnabled = SettingsStore.getValue("feature_thread"); + this.threadsEnabled = SettingsStore.getValue("feature_threadstable"); } protected async getRoomAvatar() { diff --git a/test/components/structures/TimelinePanel-test.tsx b/test/components/structures/TimelinePanel-test.tsx index e7b5b3ed50..cf1a518846 100644 --- a/test/components/structures/TimelinePanel-test.tsx +++ b/test/components/structures/TimelinePanel-test.tsx @@ -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); }); diff --git a/test/components/views/messages/MessageActionBar-test.tsx b/test/components/views/messages/MessageActionBar-test.tsx index d3eeb0e3b6..a3a3ffe141 100644 --- a/test/components/views/messages/MessageActionBar-test.tsx +++ b/test/components/views/messages/MessageActionBar-test.tsx @@ -386,6 +386,12 @@ describe("", () => { }); 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("", () => { 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", () => { diff --git a/test/components/views/right_panel/RoomHeaderButtons-test.tsx b/test/components/views/right_panel/RoomHeaderButtons-test.tsx index 76e33f9b2c..f9a3572aa8 100644 --- a/test/components/views/right_panel/RoomHeaderButtons-test.tsx +++ b/test/components/views/right_panel/RoomHeaderButtons-test.tsx @@ -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; }); }); diff --git a/test/components/views/rooms/EventTile-test.tsx b/test/components/views/rooms/EventTile-test.tsx index d0fe524d02..bebec2efc8 100644 --- a/test/components/views/rooms/EventTile-test.tsx +++ b/test/components/views/rooms/EventTile-test.tsx @@ -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, diff --git a/test/components/views/rooms/SearchResultTile-test.tsx b/test/components/views/rooms/SearchResultTile-test.tsx index bb214e2ada..6fef60bea2 100644 --- a/test/components/views/rooms/SearchResultTile-test.tsx +++ b/test/components/views/rooms/SearchResultTile-test.tsx @@ -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", diff --git a/test/components/views/settings/tabs/user/__snapshots__/LabsUserSettingsTab-test.tsx.snap b/test/components/views/settings/tabs/user/__snapshots__/LabsUserSettingsTab-test.tsx.snap index b2ff84a823..d152f9bc37 100644 --- a/test/components/views/settings/tabs/user/__snapshots__/LabsUserSettingsTab-test.tsx.snap +++ b/test/components/views/settings/tabs/user/__snapshots__/LabsUserSettingsTab-test.tsx.snap @@ -80,7 +80,7 @@ exports[` renders settings marked as beta as beta car class="mx_BetaCard_title" > - Threads + Threaded messages renders settings marked as beta as beta car > Joining the beta will reload .
-
renders settings marked as beta as beta car
diff --git a/test/stores/TypingStore-test.ts b/test/stores/TypingStore-test.ts index 436ea14a4b..d34b9362ac 100644 --- a/test/stores/TypingStore-test.ts +++ b/test/stores/TypingStore-test.ts @@ -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"; }); }); diff --git a/test/utils/export-test.tsx b/test/utils/export-test.tsx index f01416a181..44317418de 100644 --- a/test/utils/export-test.tsx +++ b/test/utils/export-test.tsx @@ -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);