From 0ecb266e3238d71a4cfe101635831d43e1c9e7d7 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 26 Jun 2024 16:29:37 +0200 Subject: [PATCH] Merge pull request #19165 from overleaf/jpa-test-history-download [server-ce] add tests for downloading a project zip from the history GitOrigin-RevId: 95b0047e7d4cce7f6708d116bf2065d634a76ae4 --- server-ce/test/history.spec.ts | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/server-ce/test/history.spec.ts b/server-ce/test/history.spec.ts index 6e13c805d3..6b851a8cd3 100644 --- a/server-ce/test/history.spec.ts +++ b/server-ce/test/history.spec.ts @@ -22,10 +22,24 @@ describe('History', function () { }) } + function downloadVersion(name: string) { + cy.log(`download version ${JSON.stringify(name)}`) + cy.findByText('Labels').click() + cy.findByText(name) + .parent() + .parent() + .parent() + .parent() + .within(() => { + cy.get('.history-version-dropdown-menu-btn').click() + cy.findByText('Download this version').click() + }) + } + const CLASS_ADDITION = 'ol-cm-addition-marker' const CLASS_DELETION = 'ol-cm-deletion-marker' - it('should support labels and comparison', () => { + it('should support labels, comparison and download', () => { cy.visit('/project') createProject('labels') const recompile = throttledRecompile() @@ -80,5 +94,32 @@ describe('History', function () { cy.findByText('% added').should('not.have.class', CLASS_ADDITION) cy.findByText('% more').should('not.exist') }) + + downloadVersion('Before removal') + cy.task('readFileInZip', { + pathToZip: `cypress/downloads/labels (Version 2).zip`, + fileToRead: 'main.tex', + }) + .should('contain', '% added') + .should('contain', '% to be removed') + .should('not.contain', '% more') + + downloadVersion('After removal') + cy.task('readFileInZip', { + pathToZip: `cypress/downloads/labels (Version 3).zip`, + fileToRead: 'main.tex', + }) + .should('contain', '% added') + .should('not.contain', '% to be removed') + .should('not.contain', '% more') + + downloadVersion('Current state') + cy.task('readFileInZip', { + pathToZip: `cypress/downloads/labels (Version 4).zip`, + fileToRead: 'main.tex', + }) + .should('contain', '% added') + .should('not.contain', '% to be removed') + .should('contain', '% more') }) })