Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add a Cypress test for displaying edited events #9886

Merged
merged 9 commits into from
Jan 12, 2023

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jan 10, 2023

MSC3925 is changing this, so let's make sure it keeps working.


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

MSC3925 is changing this, so let's make sure it keeps working.
@richvdh richvdh added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Jan 10, 2023
@richvdh richvdh marked this pull request as ready for review January 10, 2023 21:41
@richvdh richvdh requested a review from a team as a code owner January 10, 2023 21:41
@richvdh
Copy link
Member Author

richvdh commented Jan 10, 2023

The typescript check is mystifying me: it works locally, and MessageEvent certainly does have a from property. Any suggestions welcome.

cy.get(`[data-event-id="${originalEventId}"]`).then((messageTile) => {
// at this point, the edit event should still be unknown
cy.getClient().then((cli) => {
expect(cli.getRoom(testRoomId).getTimelineForEvent(editEventId)).to.be.null;
Copy link
Member Author

Choose a reason for hiding this comment

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

question for the reviewer: I'm not very happy with all this indentation; it feels like a return to the bad old days of javascript callback hell. Generally I feel like I only half-grok how Cypress is intended to be used :(. Suggestions as to how to make this better would be welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using then to handle the promise, can't we use here async/await to handle the promise flow ?

Copy link
Contributor

@florianduros florianduros Jan 11, 2023

Choose a reason for hiding this comment

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

const win = await cy.window({ log: false })
const bob = await cy.getBot(synapse, { displayName: "Bob", userIdPrefix: "bob_" })
...
cy.joinRoom(testRoomId)
...
const messageTile = await cy.get(`[data-event-id="${originalEventId}"]`)
const cli = await cy.getClient()
...

What do you think about it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it sounds good but doesn't work. The things returned by cy.* aren't real promises, so can't be awaited. cypress-io/cypress#1417 has a whole bunch to say about this.

Copy link
Member

Choose a reason for hiding this comment

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

You might prefer to use an alias and then the cy.get("@aliasname").then(... to reduce nesting.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've managed to clean this up a fair bit, partly with the use of cy.all.

Copy link
Member

Choose a reason for hiding this comment

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

Still tick.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Looks good.

The previous implementation was indecipherable, and didn't actually work.
Restructure the test a bit to reduce the indentation.
because (a) that's cleaner (b) it might fix the rando typescript errors
* Hoist the getClient to the top level, to avoid the random `.wrap(null)`
* Use .should rather than .then, because that's the cypress way
@richvdh
Copy link
Member Author

richvdh commented Jan 11, 2023

The typescript check is mystifying me: it works locally, and MessageEvent certainly does have a from property. Any suggestions welcome.

For the record, the problem was that my branch was out of date with respect to develop (specifically #9882, which removes the import of MatrixEvent) and of course, CI runs on the result of merging develop and the branch.

@richvdh richvdh merged commit 1b5f06b into develop Jan 12, 2023
@richvdh richvdh deleted the rav/msc3925_bundled_edits branch January 12, 2023 10:38
andybalaam pushed a commit to andybalaam/matrix-react-sdk that referenced this pull request Jan 12, 2023
MSC3925 is changing this, so let's make sure it keeps working.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants