Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 2c8fd73

Browse files
committed
setup cypress test in gitlab job
1 parent 722ac53 commit 2c8fd73

File tree

6 files changed

+43
-19
lines changed

6 files changed

+43
-19
lines changed

.gitlab-ci.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ variables:
1414
AWSAccessKeyId: $AWS_ACCESS_KEY_ID
1515
AWSSecretAccessKey: $AWS_SECRET_ACCESS_KEY
1616

17-
Build Documentation:
17+
.Build Documentation:
1818
image: node:latest
1919
stage: documentation
2020
script:
@@ -105,6 +105,25 @@ Build Documentation:
105105
after_script:
106106
- echo "Build backend complete"
107107

108+
# gitlab-runner exec docker "e2e cypress tests without docker-compose"
109+
e2e cypress tests without docker-compose:
110+
stage: integration
111+
image: localhost:5000/backend:latest
112+
services:
113+
- postgres:latest
114+
- redis:latest
115+
before_script:
116+
- /start_asgi.sh &
117+
- sleep 10
118+
script:
119+
- $(npm bin)/cypress run
120+
- exit 0
121+
artifacts:
122+
paths:
123+
- cypress/videos/
124+
- tests/screenshots/
125+
expire_in: 7 days
126+
108127
.e2e cypress tests with docker-compose:
109128
stage: integration
110129
image: docker:stable

backend/backend/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from django.conf import settings
1717
from django.conf.urls.static import static
1818
from django.contrib import admin
19-
from django.urls import include, path
19+
from django.urls import include, path, re_path
2020

2121
from core.views import index_view
2222

@@ -32,4 +32,7 @@
3232
urlpatterns = urlpatterns + [
3333
path('', index_view, name='index'),
3434
path('admin/__debug__/', include(debug_toolbar.urls)),
35+
# catch all rule so that we can navigate to
36+
# routes in vue app other than "/"
37+
re_path(r'^(?!js)(?!css)(?!statics)(?!fonts)(?!service\-worker\.js)(?!manifest\.json)(?!precache).*', index_view, name='index') # noqa
3538
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

backend/scripts/prod/Dockerfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ ADD backend /code/
2828

2929
# this stage is used for integration testing
3030
FROM production as gitlab-ci
31-
# cypress dependencies
32-
# RUN apt-get -qq update
33-
# RUN apt-get -qq install -y xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
34-
# add static files from build
31+
# update and install nodejs
3532
COPY --from=build-stage /app/dist/pwa/index.html /code/templates/
36-
# COPY --from=build-stage /app/dist/pwa /code/static
3733
COPY --from=build-stage /app/dist/pwa /static
38-
# index.html is listed here
39-
RUN ls /code/templates/ -al
40-
# also tried this, but still nothing in the templates directory when the container is started
41-
RUN cp /static/index.html /code/templates/index.html
34+
35+
COPY cypress.json /code
36+
37+
RUN mkdir /code/cypress
38+
COPY cypress/ /code/cypress/
39+
40+
RUN apt-get -qq update && apt-get -y install nodejs npm
41+
RUN node -v
42+
43+
# npm installs automatically
44+
RUN npm -v
45+
# cypress dependencies
46+
RUN apt-get -qq install -y xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
47+
48+
RUN npm install cypress
49+

compose/test.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ services:
3030
context: ../
3131
dockerfile: backend/scripts/prod/Dockerfile
3232
ports:
33-
- "8000:8000"
3433
- "9000:9000"
3534
command: /start_asgi.sh
3635
volumes:
@@ -52,11 +51,6 @@ services:
5251
- GITHUB_SECRET=${GITHUB_SECRET}
5352
- GOOGLE_OAUTH2_KEY=${GOOGLE_OAUTH2_KEY}
5453
- GOOGLE_OAUTH2_SECRET=${GOOGLE_OAUTH2_SECRET}
55-
56-
# # for Quasar
57-
# - HTTP_PROTOCOL=http
58-
# - WS_PROTOCOL=ws
59-
# - DOMAIN_NAME=${DOMAIN_NAME}
6054
depends_on:
6155
- postgres
6256
- redis

cypress.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"baseUrl": "http://0.0.0.0"
2+
"baseUrl": "http://localhost:9000"
33
}

cypress/integration/test_login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Test Login', function() {
77
cy.get("#password").clear();
88
cy.get("#password").type("password");
99
cy.get("#login-btn").click();
10-
cy.wait(1000); // wait for 1 second
10+
// cy.wait(1000); // wait for 1 second
1111
cy.getCookie('user-token').should('exist');
1212
});
1313
});

0 commit comments

Comments
 (0)