From 959fa06148ffd66fe9fae034b3aa2546a3aa0b97 Mon Sep 17 00:00:00 2001
From: Jakob Ackermann <jakob.ackermann@overleaf.com>
Date: Fri, 9 Feb 2024 11:27:26 +0000
Subject: [PATCH] Merge pull request #17009 from
 overleaf/ae-file-tree-classname

Remove duplicate className from Angular file tree

GitOrigin-RevId: 238b1ad8631b5a861361113679a9f1f8a66da6ea
---
 package-lock.json                                |  3 +--
 package.json                                     |  1 +
 server-ce/.eslintrc                              |  6 +++++-
 .../test/create-and-compile-project.spec.ts      | 16 +++++-----------
 .../app/views/project/editor/file-tree-react.pug |  2 +-
 .../file-tree/components/file-tree-root.tsx      |  6 +++++-
 services/web/package.json                        |  1 -
 7 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 70ba86f2b4..ce158c1d6b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -43,6 +43,7 @@
         "eslint-config-standard": "^17.0.0",
         "eslint-plugin-chai-expect": "^3.0.0",
         "eslint-plugin-chai-friendly": "^0.7.2",
+        "eslint-plugin-cypress": "^2.15.1",
         "eslint-plugin-import": "^2.26.0",
         "eslint-plugin-mocha": "^10.1.0",
         "eslint-plugin-node": "^11.1.0",
@@ -46237,7 +46238,6 @@
         "es6-promise": "^4.2.8",
         "escodegen": "^2.0.0",
         "eslint-config-standard-jsx": "^11.0.0",
-        "eslint-plugin-cypress": "^2.15.1",
         "eslint-plugin-jsx-a11y": "^6.7.1",
         "eslint-plugin-react": "^7.32.2",
         "eslint-plugin-react-hooks": "^4.6.0",
@@ -55100,7 +55100,6 @@
         "es6-promise": "^4.2.8",
         "escodegen": "^2.0.0",
         "eslint-config-standard-jsx": "^11.0.0",
-        "eslint-plugin-cypress": "^2.15.1",
         "eslint-plugin-jsx-a11y": "^6.7.1",
         "eslint-plugin-react": "^7.32.2",
         "eslint-plugin-react-hooks": "^4.6.0",
diff --git a/package.json b/package.json
index 639c5107ea..ee8cb227b7 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
     "eslint-config-standard": "^17.0.0",
     "eslint-plugin-chai-expect": "^3.0.0",
     "eslint-plugin-chai-friendly": "^0.7.2",
+    "eslint-plugin-cypress": "^2.15.1",
     "eslint-plugin-import": "^2.26.0",
     "eslint-plugin-mocha": "^10.1.0",
     "eslint-plugin-node": "^11.1.0",
diff --git a/server-ce/.eslintrc b/server-ce/.eslintrc
index 492adda154..3a2bb3247c 100644
--- a/server-ce/.eslintrc
+++ b/server-ce/.eslintrc
@@ -13,5 +13,9 @@
   "rules": {
     // Do not allow importing of implicit dependencies.
     "import/no-extraneous-dependencies": "error"
-  }
+  },
+  "overrides": [
+    // Extra rules for Cypress tests
+    { "files": ["**/*.spec.ts"], "extends": ["plugin:cypress/recommended"] }
+  ]
 }
diff --git a/server-ce/test/create-and-compile-project.spec.ts b/server-ce/test/create-and-compile-project.spec.ts
index c3eea10c60..a875fb1d55 100644
--- a/server-ce/test/create-and-compile-project.spec.ts
+++ b/server-ce/test/create-and-compile-project.spec.ts
@@ -8,11 +8,10 @@ describe('Project creation and compilation', function () {
     // this is the first project created, the welcome screen is displayed instead of the project list
     createProject('test-project', { isFirstProject: true })
     cy.url().should('match', /\/project\/[a-fA-F0-9]{24}/)
-    cy.findByText('\\maketitle')
-      .parent()
-      .click()
-      .type('\n\\section{{}Test Section}')
+    cy.findByText('\\maketitle').parent().click()
+    cy.findByText('\\maketitle').parent().type('\n\\section{{}Test Section}')
     // Wait for the PDF compilation throttling
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
     cy.wait(3000)
     cy.findByText('Recompile').click()
     cy.get('.pdf-viewer').should('contain.text', 'Test Section')
@@ -62,10 +61,7 @@ describe('Project creation and compilation', function () {
       cy.findByLabelText('Select a File').select('frog.jpg')
       cy.findByText('Create').click()
     })
-    // FIXME: should be aria-labeled or data-test-id
-    cy.get('.file-tree').first().within(() => {
-      cy.findByText('frog.jpg').click()
-    })
+    cy.findByTestId('file-tree').findByText('frog.jpg').click()
     cy.findByText('Another project')
       .should('have.attr', 'href')
       .then(href => {
@@ -121,9 +117,7 @@ describe('Project creation and compilation', function () {
       cy.url().should('include', targetProjectId)
     })
 
-    cy.get('.file-tree').first().within(() => {
-      cy.findByText('frog.jpg').click()
-    })
+    cy.findByTestId('file-tree').findByText('frog.jpg').click()
     cy.findByText('Another project')
       .should('have.attr', 'href')
       .then(href => {
diff --git a/services/web/app/views/project/editor/file-tree-react.pug b/services/web/app/views/project/editor/file-tree-react.pug
index 9db18c5130..8895a86161 100644
--- a/services/web/app/views/project/editor/file-tree-react.pug
+++ b/services/web/app/views/project/editor/file-tree-react.pug
@@ -8,7 +8,7 @@ aside.editor-sidebar.full-size(
 	vertical-resizable-panes-resize-on="left-pane-resize-all"
 )
 
-	.file-tree(
+	div(
 		ng-controller="ReactFileTreeController"
 		vertical-resizable-top
 	)
diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-root.tsx b/services/web/frontend/js/features/file-tree/components/file-tree-root.tsx
index 93642db1cf..75e5c2a3c7 100644
--- a/services/web/frontend/js/features/file-tree/components/file-tree-root.tsx
+++ b/services/web/frontend/js/features/file-tree/components/file-tree-root.tsx
@@ -49,7 +49,11 @@ const FileTreeRoot = React.memo<{
   if (!isReady) return null
 
   return (
-    <div className="file-tree" ref={setFileTreeContainer}>
+    <div
+      className="file-tree"
+      data-testid="file-tree"
+      ref={setFileTreeContainer}
+    >
       {fileTreeContainer && (
         <FileTreeContext
           refProviders={refProviders}
diff --git a/services/web/package.json b/services/web/package.json
index 38dff5f95d..f196862658 100644
--- a/services/web/package.json
+++ b/services/web/package.json
@@ -284,7 +284,6 @@
     "es6-promise": "^4.2.8",
     "escodegen": "^2.0.0",
     "eslint-config-standard-jsx": "^11.0.0",
-    "eslint-plugin-cypress": "^2.15.1",
     "eslint-plugin-jsx-a11y": "^6.7.1",
     "eslint-plugin-react": "^7.32.2",
     "eslint-plugin-react-hooks": "^4.6.0",
-- 
GitLab