From e9334e0259157a1350a97890ada544c7b454286f Mon Sep 17 00:00:00 2001
From: wojteknowacki <124166231+wojteknowacki@users.noreply.github.com>
Date: Tue, 24 Oct 2023 09:44:51 +0200
Subject: [PATCH] cypress process on CI crash fix (#4363)

* bump cypress action version, moved experimental memory handle to main config

* wip

* switch to electron browser

* harcoded cypress v to 12.17 and numTestsKeptInMemory: 0

* switch back to chrome

* package json change: cypress:12.17.0 -> ^12.17.0

* switch to elektron browser

* typo in nightly workflow

* nightly workflow update - changed chrome to electron

* added changeset
---
 .changeset/soft-hornets-relax.md    |  5 +++++
 .github/actions/e2e/action.yml      |  2 +-
 .github/workflows/tests-nightly.yml | 16 ++++++++--------
 cypress.config.js                   |  4 ++--
 package-lock.json                   | 18 +++++++++---------
 package.json                        |  2 +-
 6 files changed, 26 insertions(+), 21 deletions(-)
 create mode 100644 .changeset/soft-hornets-relax.md

diff --git a/.changeset/soft-hornets-relax.md b/.changeset/soft-hornets-relax.md
new file mode 100644
index 00000000000..f9d0b5a439a
--- /dev/null
+++ b/.changeset/soft-hornets-relax.md
@@ -0,0 +1,5 @@
+---
+"saleor-dashboard": patch
+---
+
+Change e2e default browser to electron
diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml
index 68fc60de97f..d2c1cf931d5 100644
--- a/.github/actions/e2e/action.yml
+++ b/.github/actions/e2e/action.yml
@@ -53,7 +53,7 @@ runs:
   using: "composite"
   steps:
     - name: e2e with reports
-      uses: cypress-io/github-action@v5
+      uses: cypress-io/github-action@v6
       with:
         install: ${{inputs.install}}
         browser: ${{inputs.browser}}
diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml
index 905c622a323..c9fda1fe255 100644
--- a/.github/workflows/tests-nightly.yml
+++ b/.github/workflows/tests-nightly.yml
@@ -31,10 +31,10 @@ on:
       browser:
         required: true
         description: "Browser"
-        default: "chrome"
+        default: "electron"
         type: choice
         options:
-          - chrome
+          - electron
           - firefox
           - all
 
@@ -161,12 +161,12 @@ jobs:
       - name: Cypress install
         id: cypress-install
         if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch'}}
-        uses: cypress-io/github-action@v5
+        uses: cypress-io/github-action@v6
         with:
           runTests: false
 
-      - name: Cypress run chrome
-        id: cypress-chrome
+      - name: Cypress run electron
+        id: cypress-electron
         if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch' && contains(fromJSON('["chrome", "all"]'), steps.get-browsers.outputs.result) && ! cancelled() }}
         uses: ./.github/actions/e2e
         with:
@@ -186,7 +186,7 @@ jobs:
           splitIndex: ${{ strategy.job-index }}
           commitInfoMessage: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
           install: false
-          browser: chrome
+          browser: electron
 
       - name: Cypress run firefox
         id: cypress-firefox
@@ -308,7 +308,7 @@ jobs:
       - name: Cypress run - automatically
         id: cypress
         continue-on-error: true
-        uses: cypress-io/github-action@v5
+        uses: cypress-io/github-action@v6
         env:
           API_URI: ${{ needs.get-environment-variables.outputs.url }}graphql/
           APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
@@ -329,7 +329,7 @@ jobs:
         with:
           install: false
           parallel: true
-          group: "UI - Chrome"
+          group: "UI - Electron"
           record: true
           tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, ${{ needs.get-environment-variables.outputs.url }}
 
diff --git a/cypress.config.js b/cypress.config.js
index eff2c428187..384450108a5 100644
--- a/cypress.config.js
+++ b/cypress.config.js
@@ -13,6 +13,8 @@ module.exports = defineConfig({
   viewportHeight: 660,
   screenshotsFolder: "cypress/reports/mochareports",
   screenshotOnRunFailure: true,
+  experimentalMemoryManagement: true,
+  numTestsKeptInMemory: 0,
   retries: {
     runMode: 2,
     openMode: 0,
@@ -25,8 +27,6 @@ module.exports = defineConfig({
     env: {
       grepFilterSpecs: true,
       grepOmitFiltered: true,
-      numTestsKeptInMemory: 10,
-      experimentalMemoryManagement: true,
     },
     baseUrl: process.env.BASE_URL,
     async setupNodeEvents(on, config) {
diff --git a/package-lock.json b/package-lock.json
index cc9ad05e26f..090f4e33f71 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -230,7 +230,7 @@
         "@types/jest": "^26.0.14",
         "@types/setup-polly-jest": "^0.5.0",
         "chromatic": "^6.17.4",
-        "cypress": "^12.4.0",
+        "cypress": "12.17.0",
         "cypress-file-upload": "^5.0.8",
         "cypress-mailhog": "^1.3.0",
         "cypress-mochawesome-reporter": "^3.5.1",
@@ -16512,13 +16512,13 @@
       }
     },
     "node_modules/cypress": {
-      "version": "12.17.2",
-      "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.17.2.tgz",
-      "integrity": "sha512-hxWAaWbqQBzzMuadSGSuQg5PDvIGOovm6xm0hIfpCVcORsCAj/gF2p0EvfnJ4f+jK2PCiDgP6D2eeE9/FK4Mjg==",
+      "version": "12.17.0",
+      "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.17.0.tgz",
+      "integrity": "sha512-nq0ug8Zrjq/2khHU1PTNxg+3/n1oqtmAFCxwQhS6QzkQ4mR6RLitX+cGIOuIMfnEbDAtVub0hZh661FOA16JxA==",
       "hasInstallScript": true,
       "optional": true,
       "dependencies": {
-        "@cypress/request": "^2.88.11",
+        "@cypress/request": "^2.88.10",
         "@cypress/xvfb": "^1.2.4",
         "@types/node": "^14.14.31",
         "@types/sinonjs__fake-timers": "8.1.1",
@@ -48089,12 +48089,12 @@
       }
     },
     "cypress": {
-      "version": "12.17.2",
-      "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.17.2.tgz",
-      "integrity": "sha512-hxWAaWbqQBzzMuadSGSuQg5PDvIGOovm6xm0hIfpCVcORsCAj/gF2p0EvfnJ4f+jK2PCiDgP6D2eeE9/FK4Mjg==",
+      "version": "12.17.0",
+      "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.17.0.tgz",
+      "integrity": "sha512-nq0ug8Zrjq/2khHU1PTNxg+3/n1oqtmAFCxwQhS6QzkQ4mR6RLitX+cGIOuIMfnEbDAtVub0hZh661FOA16JxA==",
       "optional": true,
       "requires": {
-        "@cypress/request": "^2.88.11",
+        "@cypress/request": "^2.88.10",
         "@cypress/xvfb": "^1.2.4",
         "@types/node": "^14.14.31",
         "@types/sinonjs__fake-timers": "8.1.1",
diff --git a/package.json b/package.json
index b489ec441d9..cb53e252707 100644
--- a/package.json
+++ b/package.json
@@ -233,7 +233,7 @@
     "@types/jest": "^26.0.14",
     "@types/setup-polly-jest": "^0.5.0",
     "chromatic": "^6.17.4",
-    "cypress": "^12.4.0",
+    "cypress": "^12.17.0",
     "cypress-file-upload": "^5.0.8",
     "cypress-mailhog": "^1.3.0",
     "cypress-mochawesome-reporter": "^3.5.1",