The tests that are mentioned in the above issue are failing intermittently because there was an error within the Tiptap code in extension-mention package where the collapseToEnd() is failed to execute. This is because the window.getSelection() returns like there is no selection in the editor. Due to this error is thrown, the tests were failing intermittently.
As mentioned, the getSelection() returns like there is no selection in the editor because the editor is not focused when inserting content via Tiptap's insertContent method from the page object. So when committing a mention node by clicking or using the keyboard to select an option from the mention popup, this error throws. This is identified by having a breakpoint at the line in mention.ts where the tests were failing all the time.
However, in the UI, after adding the @ character and selecting the option from the mention-listbox either using the mouse or keyboard, it works as expected. So in the tests to resolve this intermittent failure, I have focused the editor after the content is inserted so that the selection returns the expected value and does not throw any error just like from the storybook it works.
🧪 Testing
Manually verified by running the tests in a loop locally.
Manually verified by running tests individually and by having a breakpoint at the Tiptap’s mention.ts.
Running the tests a couple of times in the pipeline to verify whether it's intermittent in the actual pipeline.
✅ Checklist
[ ] I have updated the project documentation to reflect my changes or determined no changes are needed.
Pull Request
🤨 Rationale
Fixes #2150
👩💻 Implementation
The tests that are mentioned in the above issue are failing intermittently because there was an error within the Tiptap code in extension-mention package where the
collapseToEnd()
is failed to execute. This is because thewindow.getSelection()
returns like there is no selection in the editor. Due to this error is thrown, the tests were failing intermittently.As mentioned, the
getSelection()
returns like there is no selection in the editor because the editor is not focused when inserting content via Tiptap'sinsertContent
method from the page object. So when committing a mention node by clicking or using the keyboard to select an option from the mention popup, this error throws. This is identified by having a breakpoint at the line in mention.ts where the tests were failing all the time.However, in the UI, after adding the
@
character and selecting the option from the mention-listbox either using the mouse or keyboard, it works as expected. So in the tests to resolve this intermittent failure, I have focused the editor after the content is inserted so that the selection returns the expected value and does not throw any error just like from the storybook it works.🧪 Testing
✅ Checklist