From 70a5687a8eaff02bfe46a1ade48e080a588106c7 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen.haas@lakedrops.com>
Date: Fri, 18 Nov 2022 13:22:29 +0100
Subject: [PATCH] docker/cypress#1 Update to Cypress 11.1.0 and provide default
 cypress config files

---
 src/Handler.php                               | 19 ++++++++++++++++++-
 templates/tests/cypress.config.js.twig        | 10 ++++++++++
 .../tests/cypress/support/commands.js.twig    |  0
 templates/tests/cypress/support/e2e.js.twig   |  2 ++
 4 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 templates/tests/cypress.config.js.twig
 create mode 100644 templates/tests/cypress/support/commands.js.twig
 create mode 100644 templates/tests/cypress/support/e2e.js.twig

diff --git a/src/Handler.php b/src/Handler.php
index cfd7484..f427b84 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -186,7 +186,7 @@ class Handler extends BaseHandler {
       ],
       'cypress' => [
         'enable' => $this->env->receiveGlobal('CYPRESS', 'Cypress', '0'),
-        'version' => '10.10.0',
+        'version' => '11.1.0',
       ],
     ];
   }
@@ -557,6 +557,23 @@ class Handler extends BaseHandler {
         'dest' => $projectRoot . '/tests',
       ],
     ];
+    if ($this->config->readValue(['cypress', 'enable'])) {
+      $files['cypress.config.js'] = [
+        'source' => 'tests/',
+        'dest' => $projectRoot . '/tests',
+        'add2git' => TRUE,
+      ];
+      $files['commands.js'] = [
+        'source' => 'tests/cypress/support/',
+        'dest' => $projectRoot . '/tests/cypress/support',
+        'add2git' => TRUE,
+      ];
+      $files['e2e.js'] = [
+        'source' => 'tests/cypress/support/',
+        'dest' => $projectRoot . '/tests/cypress/support',
+        'add2git' => TRUE,
+      ];
+    }
     if (getenv('LAKEDROPS_BUILD_NG') === 'yes') {
       if ($this->config->readValue(['backup', 'enable'])) {
         $files['config.yaml'] = [
diff --git a/templates/tests/cypress.config.js.twig b/templates/tests/cypress.config.js.twig
new file mode 100644
index 0000000..b882417
--- /dev/null
+++ b/templates/tests/cypress.config.js.twig
@@ -0,0 +1,10 @@
+const { defineConfig } = require('cypress')
+
+module.exports = defineConfig({
+  e2e: {
+    watchForFileChanges: false,
+    setupNodeEvents(on, config) {
+      // implement node event listeners here
+    },
+  }
+})
diff --git a/templates/tests/cypress/support/commands.js.twig b/templates/tests/cypress/support/commands.js.twig
new file mode 100644
index 0000000..e69de29
diff --git a/templates/tests/cypress/support/e2e.js.twig b/templates/tests/cypress/support/e2e.js.twig
new file mode 100644
index 0000000..45530a3
--- /dev/null
+++ b/templates/tests/cypress/support/e2e.js.twig
@@ -0,0 +1,2 @@
+import '/e2escaffold/commands'
+import './commands'
-- 
GitLab