Ver Fonte

Merge pull request #34189 from overleaf/mj-fix-flaky-review-panel-tests

[web] Fix flaky <ReviewPanel /> Cypress tests

GitOrigin-RevId: b34dc9a0ca53da5a282513e8fb92297e4b2f702a
Mathias Jakobsen há 2 meses atrás
pai
commit
98bd09c31d

+ 11 - 1
services/web/test/frontend/features/review-panel/review-panel.spec.tsx

@@ -205,6 +205,9 @@ describe('<ReviewPanel />', function () {
       </TestContainer>
     )
 
+    // Wait for the editor to be ready before interacting with it
+    cy.get('.cm-content').should('have.css', 'opacity', '1')
+
     // Open the review panel with keyboard shortcut
     cy.findByText('contentLine 0').type('{command}j', { scrollBehavior: false })
     cy.findByText('contentLine 1').type('{ctrl}j', { scrollBehavior: false })
@@ -726,7 +729,7 @@ describe('<ReviewPanel /> in mini mode', function () {
       },
     ])
 
-    cy.intercept('GET', '/project/*/threads', threads)
+    cy.intercept('GET', '/project/*/threads', threads).as('loadThreads')
 
     cy.intercept('POST', `/project/*/doc/${docId}/metadata`, {})
 
@@ -745,6 +748,10 @@ describe('<ReviewPanel /> in mini mode', function () {
     // Wait for editor
     cy.get('.cm-content').should('have.css', 'opacity', '1')
 
+    // Wait for the threads to load, since mini mode renders conditionally on
+    // the threads/ranges data being present
+    cy.wait('@loadThreads')
+
     // Toggle the review panel twice to ensure data is loaded
     cy.findByText('contentLine 0').type('{command}jj', {
       scrollBehavior: false,
@@ -882,6 +889,9 @@ describe('<ReviewPanel /> for free users', function () {
       </TestContainer>
     )
 
+    // Wait for the editor to be ready before interacting with it
+    cy.get('.cm-content').should('have.css', 'opacity', '1')
+
     cy.findByLabelText('Editing').click()
     cy.findByRole('menu').within(() => {
       cy.findByText(/Reviewing/).click()