From 4cd832804b361d614bd89466b398617b6c4c822c Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen.haas@lakedrops.com> Date: Wed, 21 Sep 2022 11:38:31 +0200 Subject: [PATCH] Integrate Cypress testing --- .ahoy.l3d.yml | 4 ++++ ahoy.cypress.yml | 19 +++++++++++++++++++ src/Handler.php | 4 ++++ templates/docker-compose.yml.twig | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 ahoy.cypress.yml diff --git a/.ahoy.l3d.yml b/.ahoy.l3d.yml index 796649b..de2b769 100644 --- a/.ahoy.l3d.yml +++ b/.ahoy.l3d.yml @@ -20,3 +20,7 @@ commands: imports: - ahoy.traefik.yml usage: Traefik commands + cypress: + imports: + - ahoy.cypress.yml + usage: Cypress diff --git a/ahoy.cypress.yml b/ahoy.cypress.yml new file mode 100644 index 0000000..ab370dd --- /dev/null +++ b/ahoy.cypress.yml @@ -0,0 +1,19 @@ +ahoyapi: v2 +commands: + on: + cmd: | + CYPRESS=1 + echo "CYPRESS=1" >>.env + env -i $(cat .env | xargs) >.env + composer lakedrops:docker4drupal --no-interaction + ahoy d4d up cypress + usage: Turn on Cypress + off: + cmd: | + CYPRESS=0 + echo "CYPRESS=0" >>.env + env -i $(cat .env | xargs) >.env + composer lakedrops:docker4drupal --no-interaction + echo "You may have to close the Cypress window manually" + ahoy d4d stop cypress + usage: Turn off Cypress diff --git a/src/Handler.php b/src/Handler.php index 67c18eb..20befa6 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -184,6 +184,10 @@ class Handler extends BaseHandler { 'yearly' => 30, ], ], + 'cypress' => [ + 'enable' => $this->env->receiveGlobal('CYPRESS', 'Cypress', '0'), + 'version' => '10.8.0', + ], ]; } diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig index b28c44a..c496527 100644 --- a/templates/docker-compose.yml.twig +++ b/templates/docker-compose.yml.twig @@ -520,3 +520,22 @@ services: env_file: ../backup/.env {% endif %} {% endif %} +{% if cypress.enable|default(0) %} + + cypress: + image: 'cypress/included:{{ cypress.version }}' + environment: + - CYPRESS_baseUrl={{ projectprotocol }}://{{ projectdomain }}{{ projectport }} +{% if not drupal.live|default(0) %} + - DISPLAY=:0 + network_mode: host +{% endif %} + working_dir: '/e2e' + volumes: + - {{ projectroot }}/tests/:/e2e +{% if not drupal.live|default(0) %} + - ~/.Xauthority:/root/.Xauthority:ro + entrypoint: cypress open --project /e2e + user: '1000' +{% endif %} +{% endif %} -- GitLab