Browse Source

test(rtc): add block-update-test, add more fixtures

rcmerci 1 year ago
parent
commit
a72e3a75bc

+ 12 - 0
src/rtc_e2e_test/block_update_test.cljs

@@ -0,0 +1,12 @@
+(ns block-update-test
+  (:require [cljs.test :as t :refer [deftest]]
+            [fixture]))
+
+(t/use-fixtures :once
+  fixture/install-some-consts
+  fixture/install-example-db-fixture
+  fixture/clear-test-remote-graphs-fixture
+  fixture/build-two-conns-by-download-example-graph-fixture)
+
+(deftest insert-blocks-test
+  )

+ 3 - 0
src/rtc_e2e_test/const.cljs

@@ -4,5 +4,8 @@
 (def test-token "TEST-TOKEN")
 (def test-graph-name "TEST-REPO")
 (def test-repo "logseq_db_TEST-REPO")
+
 (def downloaded-test-graph-name "TEST-REPO-downloaded")
 (def downloaded-test-repo "logseq_db_TEST-REPO-downloaded")
+(def downloaded-test-graph-name2 "TEST-REPO-2-downloaded")
+(def downloaded-test-repo2 "logseq_db_TEST-REPO-2-downloaded")

+ 1 - 1
src/rtc_e2e_test/download_upload_test.cljs

@@ -23,7 +23,7 @@
       (println :example-db-block-count (count (d/datoms @(helper/get-example-test-conn) :avet :block/uuid)))
       (let [{:keys [graph-uuid]} (m/? helper/new-task--upload-example-graph)]
         (m/? (helper/new-task--wait-creating-graph graph-uuid))
-        (m/? (helper/new-task--download-graph graph-uuid))
+        (m/? (helper/new-task--download-graph graph-uuid const/downloaded-test-graph-name))
         (let [conn (helper/get-downloaded-test-conn)]
           (println :repos (keys @worker-state/*datascript-conns))
           (println :block-count (count (d/datoms @conn :avet :block/uuid)))))

+ 19 - 3
src/rtc_e2e_test/fixture.cljs

@@ -29,8 +29,24 @@
   {:before
    #(t/async
      done
-     (c.m/run-task
+     (c.m/run-task-throw
       (m/sp
-       (m/? helper/new-task--clear-all-test-remote-graphs)
-       (done))
+        (m/? helper/new-task--clear-all-test-remote-graphs)
+        (done))
       :clear-test-remote-graphs))})
+
+(def build-two-conns-by-download-example-graph-fixture
+  {:before
+   #(t/async
+     done
+     (c.m/run-task-throw
+      (m/sp
+        (swap! worker-state/*datascript-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2)
+        (let [{:keys [graph-uuid]} (m/? helper/new-task--upload-example-graph)]
+          (m/? (helper/new-task--wait-creating-graph graph-uuid))
+          (m/? (helper/new-task--download-graph graph-uuid const/downloaded-test-graph-name))
+          (m/? (helper/new-task--download-graph graph-uuid const/downloaded-test-graph-name2))
+          (done)))
+      :build-two-conns-by-download-example-graph-fixture))
+   :after
+   #(swap! worker-state/*datascript-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2)})

+ 2 - 2
src/rtc_e2e_test/helper.cljs

@@ -32,7 +32,7 @@
         (m/? (rtc.core/new-task--delete-graph const/test-token (:graph-uuid graph)))))))
 
 (defn new-task--download-graph
-  [graph-uuid]
+  [graph-uuid graph-name]
   (m/sp
     (let [download-info-uuid (m/? (rtc.core/new-task--request-download-graph const/test-token graph-uuid))
           result (m/? (rtc.core/new-task--wait-download-info-ready const/test-token download-info-uuid graph-uuid 60000))
@@ -44,7 +44,7 @@
       (when (= result :timeout)
         (throw (ex-info "wait download-info-ready timeout" {})))
       (m/? (rtc.core/new-task--download-graph-from-s3
-            graph-uuid const/downloaded-test-graph-name download-info-s3-url)))))
+            graph-uuid graph-name download-info-s3-url)))))
 
 (defn get-downloaded-test-conn
   []