Jelajahi Sumber

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
Jakob Ackermann 2 tahun lalu
induk
melakukan
db821620c4
2 mengubah file dengan 10 tambahan dan 4 penghapusan
  1. 5 2
      server-ce/test/learn-wiki.spec.ts
  2. 5 2
      server-ce/test/templates.spec.ts

+ 5 - 2
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')
     })
   }
 })

+ 5 - 2
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')
     })
   }