-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1658 from compdemocracy/1392/fix-cypress-tests
fix cypress tests
- Loading branch information
Showing
67 changed files
with
1,955 additions
and
5,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,32 @@ | ||
# Changes to workflow name require changes to badge URL in README.md | ||
name: E2E Tests | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
paths-ignore: | ||
- "**.md" | ||
branches: [edge] | ||
paths-ignore: ["**.md"] | ||
|
||
pull_request: | ||
paths-ignore: | ||
- "**.md" | ||
paths-ignore: ["**.md"] | ||
|
||
jobs: | ||
cypress-run: | ||
# Platform recommended in cypress-io/github-action docs. | ||
runs-on: ubuntu-20.04 | ||
env: | ||
# Use native docker command within docker-compose | ||
COMPOSE_DOCKER_CLI_BUILD: 1 | ||
# Use buildkit to speed up docker command | ||
DOCKER_BUILDKIT: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
# This ensures only the most recently push commit will keep running. | ||
- name: Cancel other active runs of this workflow | ||
uses: rokroskar/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
# This step helps us know when to skip future steps, particularly if | ||
# we're on a fork where upstream secrets won't be available. | ||
- name: Ensure secrets available | ||
- uses: actions/checkout@v3 | ||
- uses: isbang/[email protected] | ||
env: | ||
GOOGLE_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_CREDENTIALS_BASE64 }} | ||
run: | | ||
if [ -n "$GOOGLE_CREDENTIALS_BASE64" ]; then | ||
echo "DO_COMMENT_TRANSLATION=true" >> $GITHUB_ENV | ||
fi | ||
- name: Enable comment translation | ||
if: env.DO_COMMENT_TRANSLATION | ||
run: | | ||
echo GOOGLE_CREDENTIALS_BASE64=${{ secrets.GOOGLE_CREDENTIALS_BASE64 }} >> server/docker-dev.env | ||
echo SHOULD_USE_TRANSLATION_API=true >> server/docker-dev.env | ||
- name: Set server configuration | ||
run: | | ||
# Test email transport failovers | ||
# mailgun: unconfigured transport (will fail) | ||
# aws-ses: unconfigured transport (will fail) | ||
# nonexistent: nonexistent transport (will fail) | ||
# maildev: catch-all dev email server running in container (will work) | ||
echo EMAIL_TRANSPORT_TYPES=mailgun,aws-ses,nonexistent,maildev >> server/docker-dev.env | ||
- name: Ensure embed test html is served | ||
run: cp e2e/cypress/fixtures/html/embed.html client-admin/public/embed.html | ||
|
||
- name: Serve app via docker-compose | ||
run: docker compose up --detach | ||
|
||
- name: "Run Cypress tests: default" | ||
uses: cypress-io/github-action@v2 | ||
env: | ||
CYPRESS_BASE_URL: https://localhost | ||
with: | ||
working-directory: ./e2e | ||
# Ignore all tests with pattern *.secrets.spec.js | ||
spec: "**/polis/**/!(*.secrets).spec.js" | ||
browser: chrome | ||
|
||
- name: "Run Cypress tests: comment translation" | ||
if: env.DO_COMMENT_TRANSLATION | ||
uses: cypress-io/github-action@v2 | ||
env: | ||
CYPRESS_BASE_URL: https://localhost | ||
compose-file: | | ||
docker-compose.yml | ||
docker-compose.test.yml | ||
compose-flags: "--env-file test.env" | ||
- uses: cypress-io/[email protected] | ||
with: | ||
install: false | ||
working-directory: ./e2e | ||
spec: "**/comment-translation.secrets.spec.js" | ||
# Prevent cypress from discarding screenshots/videos from default test run. | ||
config: "trashAssetsBeforeRuns=false" | ||
browser: chrome | ||
|
||
# NOTE: screenshots will be generated only if E2E test failed | ||
# thus we store screenshots only on failures | ||
- name: Save screenshot artefacts | ||
uses: actions/[email protected] | ||
if: failure() | ||
with: | ||
name: cypress-screenshots | ||
path: e2e/cypress/screenshots | ||
|
||
# Test run video was always captured, so this action uses "always()" condition | ||
- name: Save video artefacts | ||
uses: actions/[email protected] | ||
if: always() | ||
with: | ||
name: cypress-videos | ||
path: e2e/cypress/videos | ||
|
||
- name: Check status of containers | ||
if: failure() | ||
run: docker compose ps | ||
|
||
- name: 'Check logs: server' | ||
if: failure() | ||
run: docker compose logs server | ||
|
||
- name: 'Check logs: nginx-proxy' | ||
if: failure() | ||
run: docker compose logs nginx-proxy | ||
config: baseUrl=http://localhost | ||
spec: cypress/e2e/!(third-party)/**/*.cy.js | ||
working-directory: e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
// Copyright (C) 2012-present, The Authors. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// build may prepend 'devWithPreprod' | ||
|
||
let urlPrefix = document.location.protocol + '//' + document.location.hostname | ||
|
||
if (document.location.port) { | ||
urlPrefix = urlPrefix + ':' + document.location.port | ||
} | ||
|
||
urlPrefix = urlPrefix + '/' | ||
const urlPrefix = `${document.location.protocol}//${document.location.host}/` | ||
|
||
export default { | ||
urlPrefix: urlPrefix | ||
urlPrefix, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
// Copyright (C) 2012-present, The Authors. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// build may prepend 'devWithPreprod' | ||
|
||
let urlPrefix = document.location.protocol + '//' + document.location.hostname | ||
|
||
if (document.location.port) { | ||
urlPrefix = urlPrefix + ':' + document.location.port | ||
} | ||
|
||
urlPrefix = urlPrefix + '/' | ||
const urlPrefix = `${document.location.protocol}//${document.location.host}/`; | ||
|
||
module.exports = { | ||
urlPrefix: urlPrefix, | ||
} | ||
urlPrefix, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.