From 856b93a5e072b09b4fb964367e8c15563dc6cc3c Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Tue, 20 May 2025 09:39:14 +0100 Subject: [PATCH] Merge pull request #25727 from overleaf/dp-fix-track-changes-e2e-tests Fix broken E2E tests after reviewer role feature flag cleanup GitOrigin-RevId: 9860d546d8a6385554f223bf15c10875089ea130 --- server-ce/test/editor.spec.ts | 136 +----------------------------- server-ce/test/helpers/project.ts | 34 -------- 2 files changed, 1 insertion(+), 169 deletions(-) diff --git a/server-ce/test/editor.spec.ts b/server-ce/test/editor.spec.ts index 648c55a907..62eeeda26b 100644 --- a/server-ce/test/editor.spec.ts +++ b/server-ce/test/editor.spec.ts @@ -1,11 +1,7 @@ import { createNewFile, createProject, - enableLinkSharing, - openFile, openProjectById, - openProjectViaLinkSharingAsUser, - toggleTrackChanges, } from './helpers/project' import { isExcludedBySharding, startWith } from './helpers/config' import { ensureUserExists, login } from './helpers/login' @@ -71,7 +67,7 @@ describe('editor', () => { cy.log('remove word from dictionary') cy.get('button').contains('Menu').click() - cy.get('button').contains('Edit').click() + cy.get('button#dictionary-settings').contains('Edit').click() cy.get('[id="dictionary-modal"]').within(() => { cy.findByText(word) .parent() @@ -92,136 +88,6 @@ describe('editor', () => { }) }) - describe('collaboration', () => { - beforeWithReRunOnTestRetry(function () { - enableLinkSharing().then(({ linkSharingReadAndWrite }) => { - const email = 'collaborator@example.com' - login(email) - openProjectViaLinkSharingAsUser( - linkSharingReadAndWrite, - projectName, - email - ) - }) - - login('user@example.com') - waitForCompileRateLimitCoolOff(() => { - openProjectById(projectId) - }) - }) - - it('track-changes', () => { - cy.log('disable track-changes before populating doc') - toggleTrackChanges(false) - - const fileName = createNewFile() - const oldContent = 'oldContent' - cy.get('.cm-line').type(`${oldContent}\n\nstatic`) - - cy.log('recompile to force flush') - recompile() - - cy.log('enable track-changes for everyone') - toggleTrackChanges(true) - - login('collaborator@example.com') - waitForCompileRateLimitCoolOff(() => { - openProjectById(projectId) - }) - openFile(fileName, 'static') - - cy.log('make changes in main file') - // 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').findByText(oldContent).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') - recompile() - - login('user@example.com') - waitForCompileRateLimitCoolOff(() => { - openProjectById(projectId) - }) - openFile(fileName, 'static') - - cy.log('reject changes') - cy.contains('.toolbar-item', 'Review').click() - cy.get('.cm-content').should('not.contain.text', oldContent) - cy.findByText('Reject change').click({ force: true }) - cy.contains('.toolbar-item', 'Review').click() - - cy.log('recompile to force flush') - recompile() - - cy.log('verify the changes are applied') - cy.get('.cm-content').should('contain.text', oldContent) - - cy.log('disable track-changes for everyone again') - toggleTrackChanges(false) - }) - - it('track-changes rich text', () => { - cy.log('disable track-changes before populating doc') - toggleTrackChanges(false) - - const fileName = createNewFile() - const oldContent = 'oldContent' - cy.get('.cm-line').type(`\\section{{}${oldContent}}\n\nstatic`) - - cy.log('recompile to force flush') - recompile() - - cy.log('enable track-changes for everyone') - toggleTrackChanges(true) - - login('collaborator@example.com') - waitForCompileRateLimitCoolOff(() => { - openProjectById(projectId) - }) - cy.log('enable visual editor and make changes in main file') - cy.findByText('Visual Editor').click() - - openFile(fileName, 'static') - - // 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').findByText(oldContent).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') - recompile() - - login('user@example.com') - waitForCompileRateLimitCoolOff(() => { - openProjectById(projectId) - }) - openFile(fileName, 'static') - - cy.log('reject changes') - cy.contains('.toolbar-item', 'Review').click() - cy.get('.cm-content').should('not.contain.text', oldContent) - cy.findAllByText('Reject change').first().click({ force: true }) - cy.contains('.toolbar-item', 'Review').click() - - cy.log('recompile to force flush') - recompile() - - cy.log('verify the changes are applied in the visual editor') - cy.findByText('Visual Editor').click() - cy.get('.cm-content').should('contain.text', oldContent) - - cy.log('disable track-changes for everyone again') - toggleTrackChanges(false) - }) - }) - describe('editor', () => { it('renders jpg', () => { cy.findByTestId('file-tree').findByText('frog.jpg').click() diff --git a/server-ce/test/helpers/project.ts b/server-ce/test/helpers/project.ts index 662327d6f2..6a2cd74e4a 100644 --- a/server-ce/test/helpers/project.ts +++ b/server-ce/test/helpers/project.ts @@ -215,37 +215,3 @@ export function createNewFile() { return fileName } - -export function toggleTrackChanges(state: boolean) { - cy.findByText('Review').click() - cy.get('.track-changes-menu-button').then(el => { - // when the menu is expanded renders the `expand_more` icon, - // and the `chevron_right` icon when it's collapsed - if (!el.text().includes('expand_more')) { - el.click() - } - }) - - cy.findByText('Everyone') - .parent() - .within(() => { - cy.get('.form-check-input').then(el => { - if (el.prop('checked') === state) return - - const id = uuid() - const alias = `@${id}` - cy.intercept({ - method: 'POST', - url: '**/track_changes', - times: 1, - }).as(id) - if (state) { - cy.get('.form-check-input').check() - } else { - cy.get('.form-check-input').uncheck() - } - cy.wait(alias) - }) - }) - cy.contains('.toolbar-item', 'Review').click() -}