Skip to content

Commit

Permalink
e2e: run lint and add check
Browse files Browse the repository at this point in the history
Use shared .prettierrc from root.
docker compose run --rm --entrypoint="npm run lint" e2e
Remove eslintrc conflicting with the eslint config in package.json.
Add check in CI.
  • Loading branch information
BacLuc committed Aug 5, 2023
1 parent 5585942 commit 003b102
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 15 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -390,6 +418,7 @@ jobs:
- api-cs-check
- frontend-eslint
- print-eslint
- e2e-lint
- api-tests
- frontend-tests
- print-tests
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ services:
environment:
- DISPLAY
volumes:
- ./.prettierrc:/.prettierrc
- ./e2e:/e2e:delegated
- /tmp/.X11-unix:/tmp/.X11-unix:rw
network_mode: host
Expand Down
10 changes: 0 additions & 10 deletions e2e/.eslintrc.js

This file was deleted.

14 changes: 13 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
```
7 changes: 5 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -24,4 +27,4 @@
"prettier/prettier": "error"
}
}
}
}
4 changes: 3 additions & 1 deletion e2e/specs/nuxtPrint.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
4 changes: 3 additions & 1 deletion e2e/specs/reactPrint.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})

0 comments on commit 003b102

Please sign in to comment.