Browse Source

Merge pull request #19234 from overleaf/jpa-ae-fix-typing

[server-ce] work around "clicking" by cy.type() in editor tests

GitOrigin-RevId: ffb3d7d77a98a3f6359414b5e93f9682c56ef2cd
Jakob Ackermann 2 years ago
parent
commit
33b208d4d5
1 changed files with 8 additions and 2 deletions
  1. 8 2
      server-ce/test/editor.spec.ts

+ 8 - 2
server-ce/test/editor.spec.ts

@@ -149,8 +149,14 @@ describe('editor', () => {
 
       cy.log('enable visual editor and make changes in main file')
       cy.findByText('Visual Editor').click()
-      cy.contains('Introduction').dblclick()
-      cy.contains('Introduction').type('{del}{enter}{enter}')
+
+      // cy.type() "clicks" in the center of the selected element before typing. This "click" discards the text as selected by the dblclick.
+      // Go down to the lower level event based typing, the frontend tests in web use similar events.
+      cy.get('.cm-editor').as('editor')
+      cy.get('@editor').contains('Introduction').dblclick()
+      cy.get('@editor').trigger('keydown', { key: 'Delete' })
+      cy.get('@editor').trigger('keydown', { key: 'Enter' })
+      cy.get('@editor').trigger('keydown', { key: 'Enter' })
 
       cy.log('recompile to force flush')
       cy.findByText('Recompile').click()