From db821620c422e948e5901b653c8d130a86e8836d Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 18 Jun 2024 09:30:33 +0200 Subject: [PATCH] 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 --- server-ce/test/learn-wiki.spec.ts | 7 +++++-- server-ce/test/templates.spec.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server-ce/test/learn-wiki.spec.ts b/server-ce/test/learn-wiki.spec.ts index 5e63266f5f..aff62c0250 100644 --- a/server-ce/test/learn-wiki.spec.ts +++ b/server-ce/test/learn-wiki.spec.ts @@ -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') }) } }) diff --git a/server-ce/test/templates.spec.ts b/server-ce/test/templates.spec.ts index 7f0308542c..e04f07539e 100644 --- a/server-ce/test/templates.spec.ts +++ b/server-ce/test/templates.spec.ts @@ -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') }) }