2024-07-10 10:00:41 -04:00
|
|
|
import { isExcludedBySharding, startWith } from './helpers/config'
|
2024-05-30 03:13:24 -04:00
|
|
|
import { ensureUserExists, login } from './helpers/login'
|
2024-05-30 05:50:51 -04:00
|
|
|
import { v4 as uuid } from 'uuid'
|
2024-05-30 03:13:24 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
|
2024-05-30 05:50:51 -04:00
|
|
|
const WITHOUT_PROJECTS_USER = 'user-without-projects@example.com'
|
|
|
|
const REGULAR_USER = 'user@example.com'
|
|
|
|
|
2024-06-18 03:30:33 -04:00
|
|
|
// Re-use value for "exists" and "does not exist" tests
|
|
|
|
const LABEL_LEARN_LATEX = 'Learn LaTeX with a tutorial'
|
|
|
|
|
2024-05-30 05:50:51 -04:00
|
|
|
ensureUserExists({ email: WITHOUT_PROJECTS_USER })
|
|
|
|
ensureUserExists({ email: REGULAR_USER })
|
|
|
|
|
2024-05-30 03:13:24 -04:00
|
|
|
describe('enabled in Pro', () => {
|
2024-07-10 10:00:41 -04:00
|
|
|
if (isExcludedBySharding('PRO_CUSTOM_2')) return
|
2024-05-30 03:13:24 -04:00
|
|
|
startWith({
|
|
|
|
pro: true,
|
|
|
|
vars: {
|
|
|
|
OVERLEAF_PROXY_LEARN: 'true',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should add a documentation entry to the nav bar', () => {
|
2024-05-30 05:50:51 -04:00
|
|
|
login(REGULAR_USER)
|
2024-05-30 03:13:24 -04:00
|
|
|
cy.visit('/project')
|
|
|
|
cy.get('nav').findByText('Documentation')
|
|
|
|
})
|
|
|
|
|
2024-05-30 05:50:51 -04:00
|
|
|
it('should display a tutorial link in the welcome page', () => {
|
|
|
|
login(WITHOUT_PROJECTS_USER)
|
|
|
|
cy.visit('/project')
|
2024-06-18 03:30:33 -04:00
|
|
|
cy.findByText(LABEL_LEARN_LATEX)
|
2024-05-30 05:50:51 -04:00
|
|
|
})
|
|
|
|
|
2024-05-30 03:13:24 -04:00
|
|
|
it('should render wiki page', () => {
|
2024-05-30 05:50:51 -04:00
|
|
|
login(REGULAR_USER)
|
2024-05-30 03:13:24 -04:00
|
|
|
cy.visit(UPLOADING_A_PROJECT_URL)
|
|
|
|
// Wiki content
|
|
|
|
cy.get('.page').findByText('Uploading a project')
|
|
|
|
cy.get('.page').contains(/how to create an Overleaf project/)
|
|
|
|
cy.get('img[alt="Creating a new project on Overleaf"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.and((el: any) => {
|
|
|
|
expect(el[0].naturalWidth, 'renders image').to.be.greaterThan(0)
|
|
|
|
})
|
|
|
|
// Wiki navigation
|
|
|
|
cy.get('.contents').findByText('Copying a project')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should navigate back and forth', function () {
|
2024-05-30 05:50:51 -04:00
|
|
|
login(REGULAR_USER)
|
2024-05-30 03:13:24 -04:00
|
|
|
cy.visit(COPYING_A_PROJECT_URL)
|
|
|
|
cy.get('.page').findByText('Copying a project')
|
|
|
|
cy.get('.contents').findByText('Uploading a project').click()
|
|
|
|
cy.url().should('contain', UPLOADING_A_PROJECT_URL)
|
|
|
|
cy.get('.page').findByText('Uploading a project')
|
|
|
|
cy.get('.contents').findByText('Copying a project').click()
|
|
|
|
cy.url().should('contain', COPYING_A_PROJECT_URL)
|
|
|
|
cy.get('.page').findByText('Copying a project')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('disabled in Pro', () => {
|
2024-07-10 10:00:41 -04:00
|
|
|
if (isExcludedBySharding('PRO_DEFAULT_1')) return
|
2024-05-30 03:13:24 -04:00
|
|
|
startWith({ pro: true })
|
|
|
|
checkDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('unavailable in CE', () => {
|
2024-07-10 10:00:41 -04:00
|
|
|
if (isExcludedBySharding('CE_CUSTOM_1')) return
|
2024-05-30 03:13:24 -04:00
|
|
|
startWith({
|
|
|
|
pro: false,
|
|
|
|
vars: {
|
|
|
|
OVERLEAF_PROXY_LEARN: 'true',
|
|
|
|
},
|
|
|
|
})
|
2024-05-30 05:50:51 -04:00
|
|
|
|
2024-05-30 03:13:24 -04:00
|
|
|
checkDisabled()
|
|
|
|
})
|
|
|
|
|
|
|
|
function checkDisabled() {
|
|
|
|
it('should not add a documentation entry to the nav bar', () => {
|
2024-05-30 05:50:51 -04:00
|
|
|
login(REGULAR_USER)
|
2024-05-30 03:13:24 -04:00
|
|
|
cy.visit('/project')
|
|
|
|
cy.findByText('Documentation').should('not.exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should not render wiki page', () => {
|
2024-05-30 05:50:51 -04:00
|
|
|
login(REGULAR_USER)
|
2024-05-30 03:13:24 -04:00
|
|
|
cy.visit(COPYING_A_PROJECT_URL, {
|
|
|
|
failOnStatusCode: false,
|
|
|
|
})
|
|
|
|
cy.findByText('Not found')
|
|
|
|
})
|
2024-05-30 05:50:51 -04:00
|
|
|
|
|
|
|
it('should not display a tutorial link in the welcome page', () => {
|
|
|
|
login(WITHOUT_PROJECTS_USER)
|
|
|
|
cy.visit('/project')
|
2024-06-18 03:30:33 -04:00
|
|
|
cy.findByText(LABEL_LEARN_LATEX).should('not.exist')
|
2024-05-30 05:50:51 -04:00
|
|
|
})
|
2024-05-30 03:13:24 -04:00
|
|
|
}
|
|
|
|
})
|