From 968bf1b38c1111573f36491dfd100a330a408be0 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Tue, 14 May 2024 11:55:32 +0200 Subject: [PATCH 1/3] fix: cypress tests --- backend/ypovoli/settings.py | 4 ++-- frontend/cypress.config.js | 2 +- test.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/ypovoli/settings.py b/backend/ypovoli/settings.py index ca8d8152..259f96d6 100644 --- a/backend/ypovoli/settings.py +++ b/backend/ypovoli/settings.py @@ -46,8 +46,8 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = environ.get("DJANGO_DEBUG", "False").lower() in ["true", "1", "t"] DOMAIN_NAME = environ.get("DJANGO_DOMAIN_NAME", "localhost") -ALLOWED_HOSTS = [DOMAIN_NAME] -CSRF_TRUSTED_ORIGINS = ["https://" + DOMAIN_NAME] +ALLOWED_HOSTS = [DOMAIN_NAME, "nginx"] +CSRF_TRUSTED_ORIGINS = ["https://" + DOMAIN_NAME, "https://nginx"] # Application definition INSTALLED_APPS = [ diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 6b759d73..83abcaba 100644 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'cypress'; export default defineConfig({ e2e: { - baseUrl: 'http://nginx', + baseUrl: 'https://nginx', specPattern: 'src/test/e2e/**/*.cy.{js,jsx,ts,tsx}', }, }); diff --git a/test.sh b/test.sh index 91cb140d..500e6073 100755 --- a/test.sh +++ b/test.sh @@ -92,7 +92,7 @@ fi exit_code=0 echo "-----------------" -if [ $vitest_exit -ne 0 ] || [ $django_exit -ne 0 ]; then +if [ $cypress_exit -ne 0 ] || [ $vitest_exit -ne 0 ] || [ $django_exit -ne 0 ]; then echo "Tests failed:" if [ $cypress_exit -ne 0 ]; then echo " - Cypress" From 4fc0caed31e3742b74471c12337491250f94952d Mon Sep 17 00:00:00 2001 From: Topvennie Date: Tue, 14 May 2024 12:32:05 +0200 Subject: [PATCH 2/3] chore: reduce docker image size --- frontend/Dockerfile.cypress | 8 ++++++++ test.yml | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 frontend/Dockerfile.cypress diff --git a/frontend/Dockerfile.cypress b/frontend/Dockerfile.cypress new file mode 100644 index 00000000..951a6f98 --- /dev/null +++ b/frontend/Dockerfile.cypress @@ -0,0 +1,8 @@ +ARG CHROME_VERSION="114.0.5735.133-1" +ARG NODE_VERSION="18.17.1" + +FROM cypress/factory + +WORKDIR /e2e + +RUN npm install --save-dev cypress diff --git a/test.yml b/test.yml index 0f274abd..439fb502 100644 --- a/test.yml +++ b/test.yml @@ -52,6 +52,8 @@ services: command: sh -c "./setup.sh && python manage.py runsslserver 0.0.0.0:8000" volumes: - $BACKEND_DIR:/code + depends_on: + - redis celery: <<: *common-keys-selab_test @@ -89,7 +91,12 @@ services: cypress: <<: *common-keys-selab_test container_name: cypress - image: cypress/included:cypress-12.17.3-node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 + build: + context: $FRONTEND_DIR + dockerfile: Dockerfile.cypress + command: "npm run cypress:test" working_dir: /e2e volumes: - ${FRONTEND_DIR}:/e2e + depends_on: + - frontend From 0d316df163842cda221cc1f22a43b21ce9b3b213 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Tue, 14 May 2024 13:07:12 +0200 Subject: [PATCH 3/3] chore: npm install cypress --- frontend/Dockerfile.cypress | 4 ---- test.yml | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/Dockerfile.cypress b/frontend/Dockerfile.cypress index 951a6f98..509d7ca1 100644 --- a/frontend/Dockerfile.cypress +++ b/frontend/Dockerfile.cypress @@ -2,7 +2,3 @@ ARG CHROME_VERSION="114.0.5735.133-1" ARG NODE_VERSION="18.17.1" FROM cypress/factory - -WORKDIR /e2e - -RUN npm install --save-dev cypress diff --git a/test.yml b/test.yml index 439fb502..05051584 100644 --- a/test.yml +++ b/test.yml @@ -94,9 +94,10 @@ services: build: context: $FRONTEND_DIR dockerfile: Dockerfile.cypress - command: "npm run cypress:test" + command: sh -c "npm install && npm run cypress:test" working_dir: /e2e volumes: - ${FRONTEND_DIR}:/e2e + - /e2e/node_modules depends_on: - frontend