From 648e52b6c9ffa0973a85a4eb822dbf1c4c48df19 Mon Sep 17 00:00:00 2001
From: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Date: Wed, 6 Dec 2023 16:31:59 +0100
Subject: [PATCH] add cypress workflow

---
 .github/workflows/cypress.yml          | 26 +++++++++++++
 formule-demo/cypress/e2e/builder.cy.ts |  6 +--
 formule-demo/vite.config.ts            |  3 +-
 yarn.lock                              | 53 ++++++++++++--------------
 4 files changed, 54 insertions(+), 34 deletions(-)
 create mode 100644 .github/workflows/cypress.yml

diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml
new file mode 100644
index 0000000..206c7cc
--- /dev/null
+++ b/.github/workflows/cypress.yml
@@ -0,0 +1,26 @@
+name: Cypress
+
+on:
+  push:
+    branch: master
+  pull_request:
+
+jobs:
+  cypress-run:
+    runs-on: ubuntu-22.04
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+      - name: Install formule dependencies
+        run: yarn install --frozen-lockfile
+      - name: Link
+        run: yarn link-local && cd formule-demo && yarn link-local-lib
+      - name: Install formule-demo dependencies
+        working-directory: ./formule-demo
+        run: yarn install --frozen-lockfile
+      - name: Cypress run
+        uses: cypress-io/github-action@v6
+        with:
+          working-directory: ./formule-demo
+          install: false
+          start: yarn dev
diff --git a/formule-demo/cypress/e2e/builder.cy.ts b/formule-demo/cypress/e2e/builder.cy.ts
index 577ce17..52584ea 100644
--- a/formule-demo/cypress/e2e/builder.cy.ts
+++ b/formule-demo/cypress/e2e/builder.cy.ts
@@ -2,7 +2,7 @@
 
 describe("test basic functionality", () => {
   beforeEach(() => {
-    cy.visit("localhost:3000");
+    cy.visit("localhost:3030");
   });
 
   it("allows drag and drop to the SchemaTree", () => {
@@ -133,9 +133,7 @@ describe("test basic functionality", () => {
     cy.get("input#root_ui\\:options_mask").clearTypeBlur("BA-00/a")
     cy.get("@myfield").focus()
     cy.get("@myfield").should("have.value", "B_-__/_")
-    cy.get("@myfield").clearTypeBlur("Xyz")
-    cy.get("@myfield").should("have.value", "BX-__/_")
-    cy.get("@myfield").clearTypeBlur("NWW5j34r")
+    cy.get("@myfield").type("NWW5j34r")
     cy.get("@myfield").should("have.value", "BN-53/r")
 
     // TODO test also suggestion endpoint, after that feature is migrated to formule
diff --git a/formule-demo/vite.config.ts b/formule-demo/vite.config.ts
index 8c58810..557ad89 100644
--- a/formule-demo/vite.config.ts
+++ b/formule-demo/vite.config.ts
@@ -11,7 +11,8 @@ export default defineConfig({
   },
   server: {
     // Needed for cypress to be able to access the dev server
-    host: true
+    host: true,
+    port: 3030,
   },
   // Enables hmr in development without having to rebuild the library
   resolve: {
diff --git a/yarn.lock b/yarn.lock
index 126379e..42b4ae9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -43,14 +43,14 @@
     classnames "^2.2.6"
     rc-util "^5.31.1"
 
-"@ant-design/pro-layout@7.16.4":
-  version "7.16.4"
-  resolved "https://registry.yarnpkg.com/@ant-design/pro-layout/-/pro-layout-7.16.4.tgz#1d0040eed59ac99d4d78bd6f7d90709881f581e2"
-  integrity sha512-A3iWPLUBl28Phe/Itu8dNoxT+Ci3+Zh04x5q7zeiEJdlFIRmIqotFBvANqFf1ndQovt+SqwkSFfi/GqH7EnN3w==
+"@ant-design/pro-layout@^7.16.4":
+  version "7.17.16"
+  resolved "https://registry.yarnpkg.com/@ant-design/pro-layout/-/pro-layout-7.17.16.tgz#124d87d4b602994a395de34caf814304e2c4b72a"
+  integrity sha512-nBQbAJEUkGqQNBqT30FcbcNXHepxySj/O7est1+2iXPXeVeyQYLHBJXcdvCrUrMty6ev3loG8K+6L3DXQkJ/5Q==
   dependencies:
     "@ant-design/icons" "^5.0.0"
-    "@ant-design/pro-provider" "2.11.1"
-    "@ant-design/pro-utils" "2.12.6"
+    "@ant-design/pro-provider" "2.13.5"
+    "@ant-design/pro-utils" "2.15.2"
     "@babel/runtime" "^7.18.0"
     "@umijs/route-utils" "^4.0.0"
     "@umijs/use-params" "^1.0.9"
@@ -61,14 +61,12 @@
     rc-resize-observer "^1.1.0"
     rc-util "^5.0.6"
     swr "^2.0.0"
-    use-json-comparison "^1.0.3"
-    use-media-antd-query "^1.1.0"
     warning "^4.0.3"
 
-"@ant-design/pro-provider@2.11.1":
-  version "2.11.1"
-  resolved "https://registry.yarnpkg.com/@ant-design/pro-provider/-/pro-provider-2.11.1.tgz#063b1157766a571fd2c06a6db4f52a5590976ffd"
-  integrity sha512-A7zXZ+58IGVuIAGvo8Hia9Wz0TFfFMo+tIv16Pu2RF9sMdGg4pE5M87qT7+45TkKodWpnpBd4cIte3jfY5v/LQ==
+"@ant-design/pro-provider@2.13.5":
+  version "2.13.5"
+  resolved "https://registry.yarnpkg.com/@ant-design/pro-provider/-/pro-provider-2.13.5.tgz#4f2a14ec21a014fc334e8a56741433ff06b02be6"
+  integrity sha512-ZVmzY2cq4nUvgmAlfgyCAaSZYV2l3n/upIQPXPj8sYcT+N/Pt1CeSVkkgW6By3EqokF6apWdIFU7hZMK2rNhrg==
   dependencies:
     "@ant-design/cssinjs" "^1.11.1"
     "@babel/runtime" "^7.18.0"
@@ -76,17 +74,19 @@
     rc-util "^5.0.1"
     swr "^2.0.0"
 
-"@ant-design/pro-utils@2.12.6":
-  version "2.12.6"
-  resolved "https://registry.yarnpkg.com/@ant-design/pro-utils/-/pro-utils-2.12.6.tgz#a2eac2a756d574614f9d8f3438788dbe922488d8"
-  integrity sha512-zBCD+uH0dZFM+ThRNDKHfLNCFfBa1vL/2KlPGGAOEIphx/Lt2PREELAHE6GnurlDEmNuBQFtAAV8Pgs9ccMeRg==
+"@ant-design/pro-utils@2.15.2":
+  version "2.15.2"
+  resolved "https://registry.yarnpkg.com/@ant-design/pro-utils/-/pro-utils-2.15.2.tgz#d8a6cdd506842ea0d6d6cabb85e2e247bc096977"
+  integrity sha512-kzMT658CGrQqoihKPlZhbnRioovwMhM59vqqVXuT6A+IuyxJhs5pxN73C6sN2+ZoeYCo/Gewnfn9v1/2vHU2Zg==
   dependencies:
     "@ant-design/icons" "^5.0.0"
-    "@ant-design/pro-provider" "2.11.1"
+    "@ant-design/pro-provider" "2.13.5"
     "@babel/runtime" "^7.18.0"
     classnames "^2.3.2"
-    dayjs "^1.11.9"
+    dayjs "^1.11.10"
+    lodash.merge "^4.6.2"
     rc-util "^5.0.6"
+    safe-stable-stringify "^2.4.3"
     swr "^2.0.0"
 
 "@ant-design/react-slick@~1.0.2":
@@ -1545,7 +1545,7 @@ date-fns@2.x:
   dependencies:
     "@babel/runtime" "^7.21.0"
 
-dayjs@1.x, dayjs@^1.11.1, dayjs@^1.11.9:
+dayjs@1.x, dayjs@^1.11.1, dayjs@^1.11.10:
   version "1.11.10"
   resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0"
   integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==
@@ -3520,6 +3520,11 @@ run-parallel@^1.1.9:
   dependencies:
     queue-microtask "^1.2.2"
 
+safe-stable-stringify@^2.4.3:
+  version "2.4.3"
+  resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz#138c84b6f6edb3db5f8ef3ef7115b8f55ccbf886"
+  integrity sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==
+
 "safer-buffer@>= 2.1.2 < 3.0.0":
   version "2.1.2"
   resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
@@ -3827,16 +3832,6 @@ uri-js@^4.2.2:
   dependencies:
     punycode "^2.1.0"
 
-use-json-comparison@^1.0.3:
-  version "1.0.6"
-  resolved "https://registry.yarnpkg.com/use-json-comparison/-/use-json-comparison-1.0.6.tgz#a012bbc258ce745db1f56745dc653f575226cb21"
-  integrity sha512-xPadt5yMRbEmVfOSGFSMqjjICrq7nLbfSH3rYIXsrtcuFX7PmbYDN/ku8ObBn3v8o/yZelO1OxUS5+5TI3+fUw==
-
-use-media-antd-query@^1.1.0:
-  version "1.1.0"
-  resolved "https://registry.yarnpkg.com/use-media-antd-query/-/use-media-antd-query-1.1.0.tgz#f083ad7e292c1c0261b6bbfaac0edc3e0920d85d"
-  integrity sha512-B6kKZwNV4R+l4Rl11sWO7HqOay9alzs1Vp1b4YJqjz33YxbltBCZtt/yxXxkXN9rc1S7OeEL/GbwC30Wmqhw6Q==
-
 use-sync-external-store@^1.0.0, use-sync-external-store@^1.2.0:
   version "1.2.0"
   resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"