diff --git a/.github/workflows/browser-tests.js.yml b/.github/workflows/browser-tests.js.yml new file mode 100644 index 00000000..ff808aa1 --- /dev/null +++ b/.github/workflows/browser-tests.js.yml @@ -0,0 +1,18 @@ +name: Browser tests + +on: + push: + branches: [ main ] + pull_request: + +jobs: + browser-tests: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4.1.6 + - run: cp .env.development.prod .env + - run: sudo chown -R 1000:1000 ${GITHUB_WORKSPACE} + - run: docker compose run ui npm install + - run: docker compose --profile browser-tests up -d --wait + - run: docker compose exec -it ui npm run test:e2e diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 30627d88..550318f2 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -28,4 +28,3 @@ jobs: - run: npm run build --if-present - run: npm run lint -- --no-fix - run: npm run test:unit - - run: npm run test:e2e diff --git a/README.md b/README.md index 95a75993..a29018eb 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,13 @@ Backend api mocks live in `/src/backend/mocks/default_handlers.js`. **Note** Firefox blocks service workers as long as we use `localhost` for local development. The only solution is to use chrom(ium) for now. + +### Running browser tests + +```sh +rm -r node_modules +docker compose run ui npm install +docker compose --profile browser-tests up -d +docker compose exec -it ui npm run test:e2e +docker compose --profile browser-tests down +``` diff --git a/docker-compose.yml b/docker-compose.yml index 34ffcb55..a197add3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,5 @@ version: '3.3' + services: ui: env_file: @@ -8,6 +9,22 @@ services: working_dir: /home/node/app volumes: - ./:/home/node/app - command: npm run serve -- --port 8081 + command: npm run serve -- --port 8081 --host ui ports: - 8081:8081 + healthcheck: + test: curl --fail http://ui:8081 || exit 1 + interval: 5s + start_period: 0s + + selenium-firefox: + profiles: [browser-tests] + image: selenium/standalone-firefox:4.21.0 + shm_size: 2gb + ports: + - 4444:4444 + - 7900:7900 + healthcheck: + test: curl --fail http://selenium-firefox:4444 || exit 1 + interval: 5s + start_period: 0s diff --git a/package.json b/package.json index 17e9a5fa..4c4a727a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "test:unit": "vue-cli-service test:unit", - "test:e2e": "vue-cli-service test:e2e", + "test:e2e": "vue-cli-service test:e2e --baseUrl=http://ui:8081/", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/wdio.local.conf.js b/wdio.local.conf.js index 77a8eff6..1c8b5740 100644 --- a/wdio.local.conf.js +++ b/wdio.local.conf.js @@ -8,14 +8,21 @@ exports.config = { /** * config for local testing */ + logLevel: 'debug', + outputDir: '', maxInstances: 1, - services: ['geckodriver'], + hostname: 'selenium-firefox', + port: 4444, + path: '/wd/hub', capabilities: [ { browserName: 'firefox', 'moz:firefoxOptions': { args: ['-headless'] }, + 'alwaysMatch': { + 'moz:debuggerAddress': true + } } ] }