[CE/SP] Add e2e tests for tutorial links in welcome page (#18471)

* [CE/SP] Add e2e tests for tutorial links in welcome page

The Welcome page should only display a tutorial link
in Server Pro when wiki is enabled

GitOrigin-RevId: 26f8b60a34bb86c0f9edc3b479e8304cc48842b7
This commit is contained in:
Miguel Serrano 2024-05-30 11:50:51 +02:00 committed by Copybot
parent 2f5bcebcdd
commit 266d3d2a2e
3 changed files with 51 additions and 13 deletions

View file

@ -1,10 +1,17 @@
import { startWith } from './helpers/config'
import { ensureUserExists, login } from './helpers/login'
import { v4 as uuid } from 'uuid'
describe('LearnWiki', function () {
const COPYING_A_PROJECT_URL = '/learn/how-to/Copying_a_project'
const UPLOADING_A_PROJECT_URL = '/learn/how-to/Uploading_a_project'
const WITHOUT_PROJECTS_USER = 'user-without-projects@example.com'
const REGULAR_USER = 'user@example.com'
ensureUserExists({ email: WITHOUT_PROJECTS_USER })
ensureUserExists({ email: REGULAR_USER })
describe('enabled in Pro', () => {
startWith({
pro: true,
@ -12,16 +19,21 @@ describe('LearnWiki', function () {
OVERLEAF_PROXY_LEARN: 'true',
},
})
ensureUserExists({ email: 'user@example.com' })
it('should add a documentation entry to the nav bar', () => {
login('user@example.com')
login(REGULAR_USER)
cy.visit('/project')
cy.get('nav').findByText('Documentation')
})
it('should display a tutorial link in the welcome page', () => {
login(WITHOUT_PROJECTS_USER)
cy.visit('/project')
cy.findByText('Learn LaTeX with a tutorial')
})
it('should render wiki page', () => {
login('user@example.com')
login(REGULAR_USER)
cy.visit(UPLOADING_A_PROJECT_URL)
// Wiki content
cy.get('.page').findByText('Uploading a project')
@ -36,7 +48,7 @@ describe('LearnWiki', function () {
})
it('should navigate back and forth', function () {
login('user@example.com')
login(REGULAR_USER)
cy.visit(COPYING_A_PROJECT_URL)
cy.get('.page').findByText('Copying a project')
cy.get('.contents').findByText('Uploading a project').click()
@ -60,24 +72,29 @@ describe('LearnWiki', function () {
OVERLEAF_PROXY_LEARN: 'true',
},
})
checkDisabled()
})
function checkDisabled() {
ensureUserExists({ email: 'user@example.com' })
it('should not add a documentation entry to the nav bar', () => {
login('user@example.com')
login(REGULAR_USER)
cy.visit('/project')
cy.findByText('Documentation').should('not.exist')
})
it('should not render wiki page', () => {
login('user@example.com')
login(REGULAR_USER)
cy.visit(COPYING_A_PROJECT_URL, {
failOnStatusCode: false,
})
cy.findByText('Not found')
})
it('should not display a tutorial link in the welcome page', () => {
login(WITHOUT_PROJECTS_USER)
cy.visit('/project')
cy.findByText('Learn LaTeX with a tutorial').should('not.exist')
})
}
})

View file

@ -8,13 +8,15 @@
"dependencies": {
"@isomorphic-git/lightning-fs": "^4.6.0",
"@testing-library/cypress": "^10.0.1",
"@types/uuid": "^9.0.8",
"body-parser": "^1.20.2",
"celebrate": "^15.0.3",
"cypress": "13.6.6",
"express": "^4.19.2",
"isomorphic-git": "^1.25.10",
"js-yaml": "^4.1.0",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"uuid": "^9.0.1"
}
},
"node_modules/@babel/code-frame": {
@ -210,6 +212,14 @@
"node": ">= 6"
}
},
"node_modules/@cypress/request/node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/@cypress/xvfb": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@cypress/xvfb/-/xvfb-1.2.4.tgz",
@ -335,6 +345,11 @@
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.5.tgz",
"integrity": "sha512-tAe4Q+OLFOA/AMD+0lq8ovp8t3ysxAOeaScnfNdZpUxaGl51ZMDEITxkvFl1STudQ58mz6gzVGl9VhMKhwRnZQ=="
},
"node_modules/@types/uuid": {
"version": "9.0.8",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz",
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA=="
},
"node_modules/@types/yauzl": {
"version": "2.10.2",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.2.tgz",
@ -3273,9 +3288,13 @@
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"bin": {
"uuid": "dist/bin/uuid"
}

View file

@ -11,12 +11,14 @@
"dependencies": {
"@isomorphic-git/lightning-fs": "^4.6.0",
"@testing-library/cypress": "^10.0.1",
"@types/uuid": "^9.0.8",
"body-parser": "^1.20.2",
"celebrate": "^15.0.3",
"cypress": "13.6.6",
"express": "^4.19.2",
"isomorphic-git": "^1.25.10",
"js-yaml": "^4.1.0",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"uuid": "^9.0.1"
}
}