diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index eeddc015c07..a3d11541c98 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -107,6 +107,34 @@ jobs: exit 1 fi working-directory: print + + e2e-lint: + name: 'Lint: e2e (Prettier)' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + + - uses: actions/setup-node@v3 + with: + node-version: '20.5.0' + + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - run: npm ci --no-audit + working-directory: e2e + + - run: | + result=$(npm run lint:check:prettier) + echo $result + if echo $result | grep -E "Code style issues found"; then + exit 1 + fi + working-directory: e2e api-tests: name: 'Tests: API' @@ -390,6 +418,7 @@ jobs: - api-cs-check - frontend-eslint - print-eslint + - e2e-lint - api-tests - frontend-tests - print-tests diff --git a/docker-compose.yml b/docker-compose.yml index 12c9ca6acdf..981392ab8f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -161,6 +161,7 @@ services: environment: - DISPLAY volumes: + - ./.prettierrc:/.prettierrc - ./e2e:/e2e:delegated - /tmp/.X11-unix:/tmp/.X11-unix:rw network_mode: host diff --git a/e2e/.eslintrc.js b/e2e/.eslintrc.js deleted file mode 100644 index a3e436bc3cf..00000000000 --- a/e2e/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - plugins: ['cypress'], - env: { - mocha: true, - 'cypress/globals': true, - }, - rules: { - strict: 'off', - }, -} diff --git a/e2e/README.md b/e2e/README.md index d86d5ec4da3..fbab4894dfb 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -6,6 +6,7 @@ If not, please follow the documentation links in the README.md in the root of th ## Option A: Run end-to-end tests in Docker container (headless) ### Preparation + ```shell # Only necessary on Mac OS: install xhost. Restart your Mac after this. brew cask install xquartz @@ -16,24 +17,29 @@ xhost local:root ``` ### Run all e2e tests + ```shell docker compose --profile e2e run --rm e2e ``` ### Run a specific e2e test + ```shell docker compose --profile e2e run --rm e2e --spec specs/login.cy.js ``` ### Run tests using a specific browser + Supported browsers: `chrome`, `edge`, `electron` (default), `firefox` + ```shell docker compose --profile e2e run --rm e2e --browser chrome ``` ### Open the cypress UI and visually see the tests run + ```shell -docker compose --profile e2e run --entrypoint "cypress open --project ." e2e +docker compose --profile e2e run --rm --entrypoint "cypress open --project ." e2e ``` ## Option B: Run end-to-end tests locally @@ -57,3 +63,9 @@ npm run cypress:run docker compose up -d npm run cypress:open ``` + +### Run lint + +```shell +docker compose run --rm --entrypoint="npm run lint" e2e +``` diff --git a/e2e/package.json b/e2e/package.json index ba5b6e3defc..6159523ce6b 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -4,7 +4,10 @@ "scripts": { "cypress:open": "cypress open", "cypress:run": "cypress run", - "lint": "prettier --write '**/*.js'" + "lint": "npm run lint:prettier", + "lint:check": "npm run lint:check:prettier", + "lint:prettier": "prettier --write --ignore-path .gitignore **/*.{js,json,md}", + "lint:check:prettier": "prettier --check --ignore-path .gitignore **/*.{js,json,md}" }, "devDependencies": { "cypress": "12.17.3", @@ -24,4 +27,4 @@ "prettier/prettier": "error" } } -} \ No newline at end of file +} diff --git a/e2e/specs/nuxtPrint.cy.js b/e2e/specs/nuxtPrint.cy.js index b07aa3cd9c2..18de29029dd 100644 --- a/e2e/specs/nuxtPrint.cy.js +++ b/e2e/specs/nuxtPrint.cy.js @@ -46,7 +46,9 @@ describe('Nuxt print test', () => { cy.get('button:contains("Download PDF (layout #1)")').click() const downloadsFolder = Cypress.config('downloadsFolder') - cy.readFile(path.join(downloadsFolder, 'Pfila-2023.pdf'), { timeout: 30000 }) + cy.readFile(path.join(downloadsFolder, 'Pfila-2023.pdf'), { + timeout: 30000, + }) cy.moveDownloads() }) }) diff --git a/e2e/specs/reactPrint.cy.js b/e2e/specs/reactPrint.cy.js index 4d84302d0eb..ceb4955bbf4 100644 --- a/e2e/specs/reactPrint.cy.js +++ b/e2e/specs/reactPrint.cy.js @@ -13,7 +13,9 @@ describe('React print test', () => { cy.get('button:contains("Download PDF (layout #2)")').click() const downloadsFolder = Cypress.config('downloadsFolder') - cy.readFile(path.join(downloadsFolder, 'Pfila-2023.pdf'), { timeout: 30000 }) + cy.readFile(path.join(downloadsFolder, 'Pfila-2023.pdf'), { + timeout: 30000, + }) cy.moveDownloads() }) })