Merge pull request #18955 from overleaf/jpa-re-use-label-value

[server-ce] re-use label values for exists/does not exist tests

GitOrigin-RevId: 9ab48a9622294d6f42057cf8d151a06a454a63a2
This commit is contained in:
Jakob Ackermann 2024-06-18 09:30:33 +02:00 committed by Copybot
parent e549e44ca7
commit db821620c4
2 changed files with 10 additions and 4 deletions

View file

@ -9,6 +9,9 @@ describe('LearnWiki', function () {
const WITHOUT_PROJECTS_USER = 'user-without-projects@example.com'
const REGULAR_USER = 'user@example.com'
// Re-use value for "exists" and "does not exist" tests
const LABEL_LEARN_LATEX = 'Learn LaTeX with a tutorial'
ensureUserExists({ email: WITHOUT_PROJECTS_USER })
ensureUserExists({ email: REGULAR_USER })
@ -29,7 +32,7 @@ describe('LearnWiki', function () {
it('should display a tutorial link in the welcome page', () => {
login(WITHOUT_PROJECTS_USER)
cy.visit('/project')
cy.findByText('Learn LaTeX with a tutorial')
cy.findByText(LABEL_LEARN_LATEX)
})
it('should render wiki page', () => {
@ -94,7 +97,7 @@ describe('LearnWiki', function () {
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')
cy.findByText(LABEL_LEARN_LATEX).should('not.exist')
})
}
})

View file

@ -7,6 +7,9 @@ const ADMIN_USER = 'admin@example.com'
const REGULAR_USER = 'user@example.com'
const TEMPLATES_USER = 'templates@example.com'
// Re-use value for "exists" and "does not exist" tests
const LABEL_BROWSE_TEMPLATES = 'Browse templates'
describe('Templates', () => {
ensureUserExists({ email: TEMPLATES_USER })
ensureUserExists({ email: WITHOUT_PROJECTS_USER })
@ -39,7 +42,7 @@ describe('Templates', () => {
it('should show templates link on welcome page', () => {
login(WITHOUT_PROJECTS_USER)
cy.visit('/')
cy.findByText('Browse templates').click()
cy.findByText(LABEL_BROWSE_TEMPLATES).click()
cy.url().should('match', /\/templates$/)
})
@ -230,7 +233,7 @@ describe('Templates', () => {
login(WITHOUT_PROJECTS_USER)
cy.visit('/')
cy.findByText(/new project/i) // wait for lazy loading
cy.findByText('Browse templates').should('not.exist')
cy.findByText(LABEL_BROWSE_TEMPLATES).should('not.exist')
})
}