Merge pull request #19399 from overleaf/jpa-tweak-server-pro-tests

[server-pro] make e2e tests more robust

GitOrigin-RevId: 81bb5673a95b47d8193700bd4b2d6510688e6656
This commit is contained in:
Jakob Ackermann 2024-07-15 10:45:38 +02:00 committed by Copybot
parent 136214f37a
commit dcce1271bc
2 changed files with 25 additions and 35 deletions

View file

@ -2,7 +2,6 @@ import { createProject } from './helpers/project'
import { isExcludedBySharding, startWith } from './helpers/config' import { isExcludedBySharding, startWith } from './helpers/config'
import { ensureUserExists, login } from './helpers/login' import { ensureUserExists, login } from './helpers/login'
import { v4 as uuid } from 'uuid' import { v4 as uuid } from 'uuid'
import { beforeWithReRunOnTestRetry } from './helpers/beforeWithReRunOnTestRetry'
describe('editor', () => { describe('editor', () => {
if (isExcludedBySharding('PRO_DEFAULT_1')) return if (isExcludedBySharding('PRO_DEFAULT_1')) return
@ -66,13 +65,11 @@ describe('editor', () => {
}) })
describe('collaboration', () => { describe('collaboration', () => {
let projectName: string
let projectId: string let projectId: string
let resumeUserSession: () => void let resumeUserSession: () => void
let resumeCollaboratorSession: () => void let resumeCollaboratorSession: () => void
beforeEach(() => { beforeEach(() => {
projectName = `project-${uuid()}`
resumeUserSession = login('user@example.com') resumeUserSession = login('user@example.com')
cy.visit(`/project`) cy.visit(`/project`)
createProject('test-editor', { type: 'Example Project' }).then( createProject('test-editor', { type: 'Example Project' }).then(
@ -80,7 +77,6 @@ describe('editor', () => {
projectId = id projectId = id
cy.log('make project shareable') cy.log('make project shareable')
cy.visit(`/project/${projectId}`)
cy.findByText('Share').click() cy.findByText('Share').click()
cy.findByText('Turn on link sharing').click() cy.findByText('Turn on link sharing').click()
@ -93,6 +89,10 @@ describe('editor', () => {
resumeCollaboratorSession = login('collaborator@example.com') resumeCollaboratorSession = login('collaborator@example.com')
cy.visit(linkSharingReadAndWrite) cy.visit(linkSharingReadAndWrite)
cy.get('button').contains('Join Project').click() cy.get('button').contains('Join Project').click()
cy.log(
'navigate to project dashboard to avoid cross session requests from editor'
)
cy.visit('/project')
}) })
resumeUserSession() resumeUserSession()
@ -116,8 +116,13 @@ describe('editor', () => {
cy.visit(`/project/${projectId}`) cy.visit(`/project/${projectId}`)
cy.log('make changes in main file') cy.log('make changes in main file')
cy.contains('\\maketitle').dblclick() // cy.type() "clicks" in the center of the selected element before typing. This "click" discards the text as selected by the dblclick.
cy.contains('\\maketitle').type('{del}{enter}{enter}') // 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('\\maketitle').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.log('recompile to force flush')
cy.findByText('Recompile').click() cy.findByText('Recompile').click()
@ -125,12 +130,13 @@ describe('editor', () => {
resumeUserSession() resumeUserSession()
cy.visit(`/project/${projectId}`) cy.visit(`/project/${projectId}`)
cy.log('accept changes') cy.log('reject changes')
cy.findByText('Review').click() cy.findByText('Review').click()
cy.findByText('Accept').click() cy.get('.cm-content').should('not.contain.text', '\\maketitle')
cy.findByText('Reject').click({ force: true })
cy.log('verify the changes are applied') cy.log('verify the changes are applied')
cy.get('.cm-content').should('not.contain.text', '\\maketitle') cy.get('.cm-content').should('contain.text', '\\maketitle')
}) })
it('track-changes rich text', () => { it('track-changes rich text', () => {
@ -165,7 +171,7 @@ describe('editor', () => {
resumeUserSession() resumeUserSession()
cy.visit(`/project/${projectId}`) cy.visit(`/project/${projectId}`)
cy.log('accept changes') cy.log('reject changes')
cy.findByText('Review').click() cy.findByText('Review').click()
cy.get('.cm-content').should('not.contain.text', 'Introduction') cy.get('.cm-content').should('not.contain.text', 'Introduction')
cy.findAllByText('Reject').first().click({ force: true }) cy.findAllByText('Reject').first().click({ force: true })
@ -177,19 +183,10 @@ describe('editor', () => {
}) })
describe('editor', () => { describe('editor', () => {
let projectId: string
beforeWithReRunOnTestRetry(() => {
login('user@example.com')
cy.visit(`/project`)
createProject(`project-${uuid()}`, { type: 'Example Project' }).then(
(id: string) => (projectId = id)
)
})
beforeEach(() => { beforeEach(() => {
login('user@example.com') login('user@example.com')
cy.visit(`/project/${projectId}`) cy.visit(`/project`)
createProject(`project-${uuid()}`, { type: 'Example Project' })
// wait until the main document is rendered // wait until the main document is rendered
cy.findByText(/Loading/).should('not.exist') cy.findByText(/Loading/).should('not.exist')
}) })
@ -218,12 +215,8 @@ describe('editor', () => {
projectName = `project-${uuid()}` projectName = `project-${uuid()}`
login('user@example.com') login('user@example.com')
cy.visit(`/project`) cy.visit(`/project`)
createProject(projectName, { type: 'Example Project' }).then( createProject(projectName, { type: 'Example Project' })
(id: string) => { cy.get('button').contains('New file').click({ force: true })
cy.visit(`/project/${id}`)
cy.get('button').contains('New file').click({ force: true })
}
)
}) })
it('can upload file', () => { it('can upload file', () => {
@ -254,12 +247,8 @@ describe('editor', () => {
projectName = `project-${uuid()}` projectName = `project-${uuid()}`
login('user@example.com') login('user@example.com')
cy.visit(`/project`) cy.visit(`/project`)
createProject(projectName, { type: 'Example Project' }).then( createProject(projectName, { type: 'Example Project' })
(id: string) => { cy.get('button').contains('Menu').click()
cy.visit(`/project/${id}`)
cy.get('button').contains('Menu').click()
}
)
}) })
it('can download project sources', () => { it('can download project sources', () => {

View file

@ -1,4 +1,5 @@
import { isExcludedBySharding, startWith } from './helpers/config' import { isExcludedBySharding, startWith } from './helpers/config'
import { createProject } from './helpers/project'
describe('SAML', () => { describe('SAML', () => {
if (isExcludedBySharding('PRO_CUSTOM_1')) return if (isExcludedBySharding('PRO_CUSTOM_1')) return
@ -32,7 +33,7 @@ describe('SAML', () => {
cy.get('button[type="submit"]').click() cy.get('button[type="submit"]').click()
}) })
cy.findByText('Create a new project') createProject('via SAML')
}) })
}) })
@ -62,6 +63,6 @@ describe('LDAP', () => {
cy.get('input[name="password"]').type('fry') cy.get('input[name="password"]').type('fry')
cy.get('button[type="submit"]').click() cy.get('button[type="submit"]').click()
cy.findByText('Create a new project') createProject('via LDAP')
}) })
}) })