From 52284e622b6a33a05b36445bbc947040d1eae884 Mon Sep 17 00:00:00 2001
From: appleby <86076+appleby@users.noreply.github.com>
Date: Tue, 27 Aug 2024 13:15:50 -0600
Subject: [PATCH] Ensure that CI checks fail if cljs tests fail (#47192)

* Fix typo in expression-clause-normalization-test

s/time-interval/relative-time-interval/

* Add missing table-id to card def to fix failing legacy-ref-test

* Ensure that if yarn test-cljs fails it fails the CI checks

When configured to autorun, the command

   shadow-cljs compile test

will exit success even if test failures occur in the node test. See

   https://github.com/thheller/shadow-cljs/issues/425

In order to ensure our CI checks fail when cljs tests fail, we need to invoke
node directly. To prevent running the tests twice, remove `:autorun true` from
the `:test` target in shadow-cljs.edn.
---
 package.json                   | 2 +-
 shadow-cljs.edn                | 3 +--
 test/metabase/lib/js_test.cljs | 3 ++-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/package.json b/package.json
index a65505a1a88..5d34a51a930 100644
--- a/package.json
+++ b/package.json
@@ -394,7 +394,7 @@
     "storybook": "yarn build:cljs && start-storybook -p 6006",
     "storybook-embedding-sdk": "yarn build:cljs && IS_EMBEDDING_SDK=true start-storybook -p 6006",
     "test": "yarn test-unit && yarn test-timezones && yarn test-cypress",
-    "test-cljs": "yarn && shadow-cljs compile test",
+    "test-cljs": "yarn && shadow-cljs compile test && node target/node-tests.js",
     "test-cypress": "yarn build && ./bin/build-for-test && yarn test-cypress-run",
     "test-cypress-open": "./bin/build-for-test && CYPRESS_FE_HEALTHCHECK=false yarn test-cypress-run --e2e --open",
     "test-cypress-open-no-backend": "E2E_HOST='http://localhost:3000' yarn test-cypress-run --e2e --open",
diff --git a/shadow-cljs.edn b/shadow-cljs.edn
index 5590e6d3503..b35e31a1cad 100644
--- a/shadow-cljs.edn
+++ b/shadow-cljs.edn
@@ -37,5 +37,4 @@
   :test
   {:target    :node-test
    :output-to "target/node-tests.js"
-   :ns-regexp "-test$"
-   :autorun   true}}}
+   :ns-regexp "-test$"}}}
diff --git a/test/metabase/lib/js_test.cljs b/test/metabase/lib/js_test.cljs
index 59822a645e7..ade8aa222fa 100644
--- a/test/metabase/lib/js_test.cljs
+++ b/test/metabase/lib/js_test.cljs
@@ -317,6 +317,7 @@
           :cards [{:id            metric-id
                    :name          "Sum of Cans"
                    :database-id   (meta/id)
+                   :table-id      (meta/id :venues)
                    :dataset-query metric-definition
                    :description   "Number of toucans plus number of pelicans"
                    :type          :metric}]})
@@ -396,7 +397,7 @@
     (lib.js/expression-clause "time-interval" [(meta/field-metadata :products :created-at) 10 "day"] nil)
 
     [:relative-time-interval {} [:field {} int?] 10 :day 10 :month]
-    (lib.js/expression-clause "time-interval" [(meta/field-metadata :products :created-at) 10 "day" 10 "month"] nil)
+    (lib.js/expression-clause "relative-time-interval" [(meta/field-metadata :products :created-at) 10 "day" 10 "month"] nil)
 
     [:relative-datetime {} :current :day]
     (lib.js/expression-clause "relative-datetime" ["current" "day"] nil)
-- 
GitLab