This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Fix checkForPreJoinUISI for thread roots #9803
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
86034b4
Fix blank timeline when thread root is UTD
germain-gg a4fb827
Merge branch 'develop' into gsouquet/blank-timeline-threads
65aaec4
add test for pre join uisi checks and thread roots
germain-gg 661fdd9
ts strict fix
germain-gg c9fbc6c
Merge branch 'develop' into gsouquet/blank-timeline-threads
germain-gg be2871f
Update to timeline panel test
50d45bd
Fixes to TimelinePanel-test
germain-gg 4887b01
Merge branch 'develop' into gsouquet/blank-timeline-threads
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |
limitations under the License. | ||
*/ | ||
|
||
import { render, RenderResult } from "@testing-library/react"; | ||
import { render, RenderResult, waitFor, screen } from "@testing-library/react"; | ||
// eslint-disable-next-line deprecate/import | ||
import { mount, ReactWrapper } from "enzyme"; | ||
import { MessageEvent } from "matrix-events-sdk"; | ||
|
@@ -61,9 +61,9 @@ const newReceipt = (eventId: string, userId: string, readTs: number, fullyReadTs | |
}; | ||
|
||
const getProps = (room: Room, events: MatrixEvent[]): TimelinePanel["props"] => { | ||
const timelineSet = room.getUnfilteredTimelineSet?.() ?? ({ room: room as Room } as EventTimelineSet); | ||
const timelineSet = { room: room as Room } as EventTimelineSet; | ||
const timeline = new EventTimeline(timelineSet); | ||
events.forEach((event) => timeline.addEvent(event, true)); | ||
events.forEach((event) => timeline.addEvent(event, { toStartOfTimeline: true })); | ||
timelineSet.getLiveTimeline = () => timeline; | ||
timelineSet.getTimelineForEvent = () => timeline; | ||
timelineSet.getPendingEvents = () => events; | ||
|
@@ -433,7 +433,7 @@ describe("TimelinePanel", () => { | |
// @ts-ignore | ||
thread.fetchEditsWhereNeeded = () => Promise.resolve(); | ||
await thread.addEvent(reply1, true); | ||
await allThreads.getLiveTimeline().addEvent(thread.rootEvent!, true); | ||
await allThreads.getLiveTimeline().addEvent(thread.rootEvent!, { toStartOfTimeline: true }); | ||
const replyToEvent = jest.spyOn(thread, "replyToEvent", "get"); | ||
|
||
const dom = render( | ||
|
@@ -479,7 +479,7 @@ describe("TimelinePanel", () => { | |
// @ts-ignore | ||
realThread.fetchEditsWhereNeeded = () => Promise.resolve(); | ||
await realThread.addEvent(reply1, true); | ||
await allThreads.getLiveTimeline().addEvent(realThread.rootEvent!, true); | ||
await allThreads.getLiveTimeline().addEvent(realThread.rootEvent!, { toStartOfTimeline: true }); | ||
const replyToEvent = jest.spyOn(realThread, "replyToEvent", "get"); | ||
|
||
// @ts-ignore | ||
|
@@ -517,7 +517,7 @@ describe("TimelinePanel", () => { | |
}); | ||
}); | ||
|
||
it("renders when the last message is an undecryptable thread root", () => { | ||
it("renders when the last message is an undecryptable thread root", async () => { | ||
jest.spyOn(SettingsStore, "getValue").mockImplementation((name) => name === "feature_threadstable"); | ||
|
||
const client = MatrixClientPeg.get(); | ||
|
@@ -527,12 +527,11 @@ describe("TimelinePanel", () => { | |
const authorId = client.getUserId()!; | ||
const room = new Room("roomId", client, authorId, { | ||
lazyLoadMembers: false, | ||
pendingEventOrdering: PendingEventOrdering.Detached, | ||
}); | ||
|
||
const events = mockEvents(room); | ||
const props = { | ||
...getProps(room, events), | ||
}; | ||
const timelineSet = room.getUnfilteredTimelineSet(); | ||
|
||
const { rootEvent } = mkThread({ | ||
room, | ||
|
@@ -543,14 +542,16 @@ describe("TimelinePanel", () => { | |
|
||
events.push(rootEvent); | ||
|
||
events.forEach((event) => timelineSet.getLiveTimeline().addEvent(event, { toStartOfTimeline: true })); | ||
|
||
const roomMembership = mkMembership({ | ||
mship: "join", | ||
prevMship: "join", | ||
user: authorId, | ||
room: room.roomId, | ||
event: true, | ||
skey: "123", | ||
}); | ||
roomMembership.event.state_key = "123"; | ||
|
||
events.push(roomMembership); | ||
|
||
|
@@ -560,8 +561,8 @@ describe("TimelinePanel", () => { | |
const roomState = new RoomState(room.roomId); | ||
jest.spyOn(roomState, "getMember").mockReturnValue(member); | ||
|
||
jest.spyOn(props.timelineSet.getLiveTimeline(), "getState").mockReturnValue(roomState); | ||
props.timelineSet.addLiveEvent(roomMembership, {}); | ||
jest.spyOn(timelineSet.getLiveTimeline(), "getState").mockReturnValue(roomState); | ||
timelineSet.addEventToTimeline(roomMembership, timelineSet.getLiveTimeline(), { toStartOfTimeline: false }); | ||
|
||
for (const event of events) { | ||
jest.spyOn(event, "isDecryptionFailure").mockReturnValue(true); | ||
|
@@ -570,10 +571,11 @@ describe("TimelinePanel", () => { | |
|
||
const { container } = render( | ||
<MatrixClientContext.Provider value={client}> | ||
<TimelinePanel {...props} /> | ||
<TimelinePanel timelineSet={timelineSet} manageReadReceipts={true} sendReadReceiptOnLoad={true} /> | ||
</MatrixClientContext.Provider>, | ||
); | ||
|
||
expect(container.querySelectorAll(".mx_EventTile")).toHaveLength(5); | ||
await waitFor(() => expect(screen.queryByRole("progressbar")).toBeNull()); | ||
await waitFor(() => expect(container.querySelector(".mx_RoomView_MessageList")).not.toBeEmptyDOMElement()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this feels a bit brittle: checking that there are |
||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A side-issue which should be addressed elsewhere, but this will reduce the order of
events
in the resultant timeline, which feels pretty counter-intuitive.