Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test inserting edit events into the thread timeline "on demand" #3410

Merged
merged 12 commits into from
May 25, 2023

Conversation

andybalaam
Copy link
Contributor

@andybalaam andybalaam commented May 25, 2023

I suggest reviewing commit by commit.

The main point of this change is to get a test in place that will allow us to fix a bug we inserted in #3384 where we added the wrong event to the timeline. This change doesn't fix the bug, but does add a test we can use to validate the fix later.

In order to do this, I had to fix a small problem where fetchEditsWhenNeeded ignored threaded messages. I assume they are not ignored in production, but I am not at all sure. Maybe I've misunderstood what this line of code is for:

// thread.ts line 502
if (event.isRelation()) return; // skip - relations don't get edits

Part of element-hq/element-web#10954


This change is marked as an internal change (Task), so will not be included in the changelog.

While attempting to test a new change, I discovered that the test
"should allow edits to be added to thread timeline" did not actually
fail if its assertions failed. Further, those assertions were incorrect.

So this change fixes the test to create the thread, wait for it to be
initialised, and then add events to it. This simplifies the flow and
ensures the test fails if something unexpected happens.
Modifies fetchEditsWhereNeeded to allow edits of threaded messages. The
code before prevented any relations from fetching edits, but of course
events in threads are relations.

We definitely want thread messages to get their edits fetched, and I
assume this is working in the real code, probably because the event
being looked at is some kind of eventmapped thing that doesn't have
proper relations visible on it.

In tests, if we don't make this change, we can't see edits getting
fetched.
This test demonstrates the current behaviour, which contains a bug - we
don't actually add the right event to the timeline.
@andybalaam andybalaam added the T-Task Tasks for the team like planning label May 25, 2023
@andybalaam andybalaam marked this pull request as ready for review May 25, 2023 03:14
@andybalaam andybalaam requested a review from a team as a code owner May 25, 2023 03:14
@andybalaam andybalaam requested review from germain-gg and robintown and removed request for a team May 25, 2023 03:14
@andybalaam
Copy link
Contributor Author

I suggest we bypass the coverage check since this change adds a test, so can't be bad :-)

Copy link
Member

@robintown robintown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I hit the button after reading only the first commit, but just a small comment anyways

@@ -510,6 +510,45 @@ describe("Thread", () => {
// And the first message has been edited
expect(secondLastEvent.getContent().body).toEqual("edit");
});

it("Adds edits fetched on demand to the thread timeline and applies them", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it("Adds edits fetched on demand to the thread timeline and applies them", async () => {
it("applies edits fetched on demand", async () => {

I'd be more comfortable if this test's title were honest about what it's really testing at the moment ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please forgive me for not doing this.. I promise I'll merge #3398 very very soon.

It was going to topple my tower of PRs :-)

@robintown robintown removed the request for review from germain-gg May 25, 2023 03:44
Base automatically changed from andybalaam/simplify-thread-edit-test to develop May 25, 2023 14:28
@andybalaam
Copy link
Contributor Author

Force merging because the coverage check is not relevant a change that is pure tests.

@andybalaam andybalaam merged commit 711bf47 into develop May 25, 2023
@andybalaam andybalaam deleted the andybalaam/test-inserting-ondemand-edit-event branch May 25, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants