I have a small application to test on cypress. It has a editor for user to add description and stuff. The user can make the text bold, italic etc. The user can also remove the formatting added so far on the text. But to remove the formatting the text should be selected like we normally do in any word editor.
My question is how can I test this feature while keeping the text selected.
A simple code example would be as follows:
<p>This is the description text</p>
So far I have got this but this does not keep the text selected of course, any idea how to cater this?
cy.get('p').contains('This is the description text');
cy.get('.remove-formats').click();
cy.get('.tools')
.within(() => cy.get('button').should('not.have.class', 'is-active'));
What change should I make in the first line that the text stays selected when the second line executes as I want the remove formats to be performed on the text only. Any help would be appreciated.
Edit:
The text editor is very simple just like the one we have for stackoverflow.

Similar to how we need to select the text first and then click bold to get the text bold, otherwise it does not imply to the text. How would I structure cypress tests for this? I have selected the text through dblclick() but as soon as I click on any option to test that feature the text does not stay selected in cypress tests.
You can use double click to select the text.
cy.contains('This is the description text').dblclick()
You can also use a combination of ctrl+A
cy.contains('This is the description text').click().type('{ctrl+a}')