|
|
@@ -7,6 +7,7 @@ import { startWith } from './helpers/config'
|
|
|
import { dockerCompose, resetData, runScript } from './helpers/hostAdminClient'
|
|
|
import { createProject } from './helpers/project'
|
|
|
import { throttledRecompile } from './helpers/compile'
|
|
|
+import { v4 as uuid } from 'uuid'
|
|
|
|
|
|
const USER = 'user@example.com'
|
|
|
const PROJECT_NAME = 'Old Project'
|
|
|
@@ -22,23 +23,25 @@ describe('Upgrading', function () {
|
|
|
) {
|
|
|
const startOptions = steps.shift()!
|
|
|
|
|
|
- // Reset mongo/redis/on-disk data
|
|
|
before(async () => {
|
|
|
+ cy.log('Reset mongo/redis/on-disk data')
|
|
|
resetCreatedUsersCache()
|
|
|
await resetData()
|
|
|
- })
|
|
|
|
|
|
- // Create old instance
|
|
|
+ cy.log('Create old instance')
|
|
|
+ })
|
|
|
startWith({
|
|
|
pro: true,
|
|
|
version: startOptions.version,
|
|
|
withDataDir: true,
|
|
|
vars: startOptions.vars,
|
|
|
})
|
|
|
+ before(function () {
|
|
|
+ cy.log('Create initial user after deleting it')
|
|
|
+ })
|
|
|
ensureUserExists({ email: USER })
|
|
|
-
|
|
|
- // Populate old instance
|
|
|
before(() => {
|
|
|
+ cy.log('Populate old instance')
|
|
|
login(USER)
|
|
|
|
|
|
cy.visit('/project')
|
|
|
@@ -46,26 +49,25 @@ describe('Upgrading', function () {
|
|
|
newProjectButtonMatcher: startOptions.newProjectButtonMatcher,
|
|
|
})
|
|
|
const recompile = throttledRecompile()
|
|
|
- // // wait for successful compile
|
|
|
+ cy.log('Wait for successful compile')
|
|
|
cy.get('.pdf-viewer').should('contain.text', PROJECT_NAME)
|
|
|
|
|
|
- // Increment the doc version three times
|
|
|
+ cy.log('Increment the doc version three times')
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
- // Add content
|
|
|
+ cy.log('Add content')
|
|
|
cy.findByText('\\maketitle').parent().click()
|
|
|
cy.findByText('\\maketitle')
|
|
|
.parent()
|
|
|
.type(`\n\\section{{}Old Section ${i}}`)
|
|
|
|
|
|
- // Trigger full flush
|
|
|
+ cy.log('Trigger full flush')
|
|
|
recompile()
|
|
|
cy.get('header').findByText('Menu').click()
|
|
|
cy.findByText('Source').click()
|
|
|
- // close editor menu
|
|
|
cy.get('#left-menu-modal').click()
|
|
|
}
|
|
|
|
|
|
- // Check compile and history
|
|
|
+ cy.log('Check compile and history')
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
cy.get('.pdf-viewer').should('contain.text', `Old Section ${i}`)
|
|
|
}
|
|
|
@@ -75,14 +77,15 @@ describe('Upgrading', function () {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- // Upgrades
|
|
|
for (const step of steps) {
|
|
|
before(() => {
|
|
|
+ cy.log(`Upgrade to version ${step.version}`)
|
|
|
+
|
|
|
// Navigate way from editor to avoid redirect to /login when the next instance comes up (which slows down tests)
|
|
|
cy.visit('/project', {})
|
|
|
})
|
|
|
- // Graceful shutdown
|
|
|
before(async function () {
|
|
|
+ cy.log('Graceful shutdown: flush all the things')
|
|
|
this.timeout(20 * 1000)
|
|
|
// Ideally we could use the container shutdown procedure, but it's too slow and unreliable for tests.
|
|
|
// TODO(das7pad): adopt the below after speeding up the graceful shutdown procedure on all supported releases
|
|
|
@@ -126,20 +129,21 @@ describe('Upgrading', function () {
|
|
|
})
|
|
|
const recompile = throttledRecompile()
|
|
|
|
|
|
- // wait for successful compile
|
|
|
+ cy.log('wait for successful compile')
|
|
|
cy.get('.pdf-viewer').should('contain.text', PROJECT_NAME)
|
|
|
cy.get('.pdf-viewer').should('contain.text', 'Old Section 2')
|
|
|
|
|
|
- // // Add more content
|
|
|
+ cy.log('Add more content')
|
|
|
+ const newSection = `New Section ${uuid()}`
|
|
|
cy.findByText('\\maketitle').parent().click()
|
|
|
- cy.findByText('\\maketitle').parent().type('\n\\section{{}New Section}')
|
|
|
+ cy.findByText('\\maketitle').parent().type(`\n\\section{{}${newSection}}`)
|
|
|
|
|
|
- // Check compile and history
|
|
|
+ cy.log('Check compile and history')
|
|
|
recompile()
|
|
|
- cy.get('.pdf-viewer').should('contain.text', 'New Section')
|
|
|
+ cy.get('.pdf-viewer').should('contain.text', newSection)
|
|
|
cy.findByText('History').click()
|
|
|
cy.findByText(/\\section\{Old Section 2}/)
|
|
|
- cy.findByText(/\\section\{New Section}/)
|
|
|
+ cy.findByText(new RegExp(`\\\\section\\{${newSection}}`))
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -170,17 +174,17 @@ describe('Upgrading', function () {
|
|
|
cy.findByText(PROJECT_NAME).click()
|
|
|
const recompile = throttledRecompile()
|
|
|
|
|
|
- // Make a change
|
|
|
+ cy.log('Make a change')
|
|
|
cy.findByText('\\maketitle').parent().click()
|
|
|
cy.findByText('\\maketitle')
|
|
|
.parent()
|
|
|
.type('\n\\section{{}FiveOOne Section}')
|
|
|
|
|
|
- // Trigger flush
|
|
|
+ cy.log('Trigger flush')
|
|
|
recompile()
|
|
|
cy.get('.pdf-viewer').should('contain.text', 'FiveOOne Section')
|
|
|
|
|
|
- // Check for broken history, i.e. not synced with latest edit
|
|
|
+ cy.log('Check for broken history, i.e. not synced with latest edit')
|
|
|
cy.findByText('History').click()
|
|
|
cy.findByText(/\\section\{Old Section 2}/) // wait for lazy loading
|
|
|
cy.findByText(/\\section\{FiveOOne Section}/).should('not.exist')
|
|
|
@@ -212,11 +216,13 @@ describe('Upgrading', function () {
|
|
|
cy.visit('/')
|
|
|
cy.findByText(PROJECT_NAME).click()
|
|
|
|
|
|
- // The edit that was made while the history was broken should be there now.
|
|
|
+ cy.log(
|
|
|
+ 'The edit that was made while the history was broken should be there now.'
|
|
|
+ )
|
|
|
cy.findByText('History').click()
|
|
|
cy.findByText(/\\section\{FiveOOne Section}/)
|
|
|
|
|
|
- // Check indicator of force resync
|
|
|
+ cy.log('Check indicator of force resync')
|
|
|
cy.findByText('Overleaf History System')
|
|
|
})
|
|
|
},
|