Skip to content

Commit 8d7ce39

Browse files
committed
test(e2e): add asset-blocks-validate-after-init-downloaded-test
1 parent 38e3b99 commit 8d7ce39

File tree

13 files changed

+118
-42
lines changed

13 files changed

+118
-42
lines changed

AGENTS.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
## Repository Layout
2-
- Use clojure-mcp `clojure_inspect_project` to get project structure.
32
- `src/`: Core source code
43
- `src/main/`: The core logic of the application
54
- `src/main/mobile/`: Mobile app code
@@ -21,10 +20,7 @@
2120
- Run single focused unit-test:
2221
- Add the `:focus` keyword to the test case: `(deftest ^:focus test-name ...)`
2322
- `bb dev:test -i focus`
24-
- Run e2e basic tests:
25-
- `bb dev:e2e-basic-test`
26-
- Run e2e rtc extra tests:
27-
- `bb dev:e2e-rtc-extra-test`
23+
- E2E tests files are located in `/clj-e2e`
2824

2925
## Common used cljs keywords
3026
- All commonly used ClojureScript keywords are defined using `logseq.common.defkeywords/defkeyword`.
@@ -37,16 +33,3 @@
3733
- Linters and unit-tests must pass
3834
- Check the review notes listed in `prompts/review.md`.
3935

40-
# *IMPORTANT RULES*
41-
42-
WARNING: The following are non-negotiable, highest-priority instructions. They *MUST* be followed unconditionally in all cases. Failure to comply with these rules will result in task failure.
43-
44-
1. Clojure Code Editing Rules
45-
* Instruction: When editing any .clj, .cljs, or .cljc file, you MUST and ONLY use the clojure-mcp toolkit.
46-
* Prohibition: Absolutely do NOT use any general file writing tools (such as file_edit, file_write) to modify Clojure source files.
47-
* Reason: This is to ensure the integrity of the code structure, avoid syntax errors, and maintain the project's code style.
48-
49-
2. Code Review/Modification Prerequisites
50-
* Instruction: Before EACH “review” or “modification” of the code, you MUST first execute the `clojure_inspect_project` tool.
51-
* Prohibition: Do NOT begin analyzing or modifying code directly without obtaining project-wide information.
52-
* Reason: This is to obtain complete, up-to-date project context, which is the foundation for making correct judgments and modifications.

bb.edn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@
166166
logseq.tasks.dev/e2e-basic-test
167167

168168
dev:e2e-rtc-extra-test
169-
logseq.tasks.dev/e2e-rtc-extra-test
169+
{:doc "Run e2e rtc extra tests. HTTP server should be available at localhost:3001"
170+
:task (clojure {:dir "clj-e2e"} "-X:dev-run-rtc-extra-test")}
171+
172+
dev:e2e-rtc-extra-part2-test
173+
{:doc "Run e2e rtc extra part2 tests. HTTP server should be available at localhost:3001"
174+
:task (clojure {:dir "clj-e2e"} "-X:dev-run-rtc-extra-part2-test")}
170175

171176
dev:gen-malli-kondo-config
172177
logseq.tasks.dev/gen-malli-kondo-config

clj-e2e/AGENTS.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# E2E test Guide
2+
3+
- Source Layout (`src/logseq/e2e/`)
4+
- `assert.clj`: Custom assertion functions
5+
- `block.clj`: Block manipulation helpers
6+
- `config.clj`: Configuration settings
7+
- `const.clj`: Shared constants
8+
- `graph.clj`: Graph management helpers
9+
- `keyboard.clj`: Keyboard shortcut helpers
10+
- `locator.clj`: Playwright locator utilities
11+
- `page.clj`: Page operations helpers
12+
- `playwright_page.clj`: Playwright page initialization
13+
- `rtc.clj`: RTC testing helpers
14+
- `settings.clj`: Logseq settings manipulation
15+
- `util.clj`: General utilities
16+
- Tests (`test/logseq/e2e/`)
17+
- `fixtures.clj`: Test fixtures
18+
- Basic Tests: `*_basic_test.clj`
19+
- RTC Tests: `rtc_*_test.clj`
20+
- Run tests commands (in `clj-e2e` directory)
21+
- `clojure -X:dev-run-rtc-extra-test`
22+
- `clojure -X:dev-run-rtc-extra-part2-test`
23+
- `clojure -X:dev-run-all-basic-test`

clj-e2e/deps.edn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@
2121
:dev {:extra-paths ["dev" "test"]}
2222
:dev-run-rtc-extra-test {:extra-paths ["dev" "test"]
2323
:exec-fn user/run-rtc-extra-test2}
24+
:dev-run-rtc-extra-part2-test {:extra-paths ["dev" "test"]
25+
:exec-fn user/run-rtc-extra-part2-test2}
2426
:dev-run-all-basic-test {:extra-paths ["dev" "test"]
2527
:exec-fn user/run-all-basic-test}}}

clj-e2e/dev/user.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
[logseq.e2e.property-basic-test]
1616
[logseq.e2e.reference-basic-test]
1717
[logseq.e2e.rtc-basic-test]
18+
[logseq.e2e.rtc-extra-part2-test]
1819
[logseq.e2e.rtc-extra-test]
1920
[logseq.e2e.tag-basic-test]
2021
[logseq.e2e.util :as util]
@@ -79,6 +80,11 @@
7980
(run-tests 'logseq.e2e.rtc-extra-test)
8081
(System/exit 0))
8182

83+
(defn run-rtc-extra-part2-test2
84+
[& _args]
85+
(run-tests 'logseq.e2e.rtc-extra-part2-test)
86+
(System/exit 0))
87+
8288
(defn run-editor-basic-test
8389
[]
8490
(->> (future (run-tests 'logseq.e2e.editor-basic-test))

clj-e2e/src/logseq/e2e/const.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
(def *page2
88
"this 'page' means playwright-page, not logseq-page. it points to the client2 when testing rtc"
99
(atom nil))
10+
11+
(def ^:dynamic *graph-name* nil)

clj-e2e/src/logseq/e2e/graph.clj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
(format "div[data-testid='logseq_db_%s']" graph-name)
6060
refresh-all-remote-graphs))
6161

62+
(defn remove-local-graph
63+
[graph-name]
64+
(wait-for-remote-graph graph-name)
65+
(let [action-btn
66+
(.first (w/-query (format "div[data-testid='logseq_db_%s'] .graph-action-btn" graph-name)))]
67+
(w/click action-btn)
68+
(w/click ".delete-local-graph-menu-item")
69+
(w/click "div[role='alertdialog'] button:text('ok')")))
70+
6271
(defn remove-remote-graph
6372
[graph-name]
6473
(wait-for-remote-graph graph-name)
@@ -69,11 +78,11 @@
6978
(w/click "div[role='alertdialog'] button:text('ok')")))
7079

7180
(defn switch-graph
72-
[to-graph-name wait-sync?]
81+
[to-graph-name wait-sync? need-input-password?]
7382
(goto-all-graphs)
7483
(w/click (.last (w/-query (format "div[data-testid='logseq_db_%1$s'] span:has-text('%1$s')" to-graph-name))))
7584
(when wait-sync?
76-
(input-e2ee-password)
85+
(when need-input-password? (input-e2ee-password))
7786
(w/wait-for "button.cloud.on.idle" {:timeout 20000}))
7887
(assert/assert-graph-loaded?))
7988

clj-e2e/src/logseq/e2e/page.clj

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
(k/esc)
1919
(util/search-and-click page-name))))
2020

21+
(defn get-page-name
22+
[]
23+
(util/get-text "div[data-testid='page title'] .block-title-wrap"))
24+
2125
(defn new-page
2226
[title]
2327
;; Question: what's the best way to close all the popups?
@@ -42,17 +46,18 @@
4246
(k/esc))
4347

4448
(defn- set-tag-extends
45-
[extends & [in-retry?]]
46-
(util/wait-timeout 500)
47-
(w/click (loc/filter ".property-value" :has-text "root tag"))
48-
(let [extends-visible? (mapv #(w/visible? (format "div:has(> button):has(div:text('%s'))" %)) extends)]
49-
(if (every? identity extends-visible?)
50-
(doseq [extend extends]
51-
(w/click (format "div:has(> button):has(div:text('%s'))" extend)))
52-
(if in-retry?
53-
(throw (ex-info "parent-tag not found" {:extends extends :visible? extends-visible?}))
54-
(do (k/esc)
55-
(set-tag-extends extends true))))))
49+
[extends & [retry-count]]
50+
(let [retry-count (or retry-count 5)]
51+
(util/wait-timeout 500)
52+
(w/click (loc/filter ".property-value" :has-text "root tag"))
53+
(let [extends-visible? (mapv #(w/visible? (format "div:has(> button):has(div:text('%s'))" %)) extends)]
54+
(if (every? identity extends-visible?)
55+
(doseq [extend extends]
56+
(w/click (format "div:has(> button):has(div:text('%s'))" extend)))
57+
(if (zero? retry-count)
58+
(throw (ex-info "parent-tag not found" {:extends extends :visible? extends-visible?}))
59+
(do (k/esc)
60+
(set-tag-extends extends (dec retry-count))))))))
5661

5762
(defn convert-to-tag
5863
[page-name & {:keys [extends]}]

clj-e2e/test/logseq/e2e/fixtures.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:require [com.climate.claypoole :as cp]
33
[logseq.e2e.assert :as assert]
44
[logseq.e2e.config :as config]
5-
[logseq.e2e.const :refer [*page1 *page2]]
5+
[logseq.e2e.const :refer [*page1 *page2 *graph-name*]]
66
[logseq.e2e.custom-report :as custom-report]
77
[logseq.e2e.graph :as graph]
88
[logseq.e2e.page :as page]
@@ -148,9 +148,10 @@
148148
(graph/new-graph graph-name true))
149149
(w/with-page @*page2
150150
(graph/wait-for-remote-graph graph-name)
151-
(graph/switch-graph graph-name true))
151+
(graph/switch-graph graph-name true true))
152152

153-
(binding [custom-report/*preserve-graph* false]
153+
(binding [custom-report/*preserve-graph* false
154+
*graph-name* graph-name]
154155
(f)
155156
;; cleanup
156157
(if custom-report/*preserve-graph*

clj-e2e/test/logseq/e2e/multi_tabs_basic_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
(w/with-page p2
3535
(util/goto-journals)
3636
(assert/assert-in-normal-mode?)
37-
(graph/switch-graph graph-name false))
37+
(graph/switch-graph graph-name false false))
3838
(w/with-page p3
3939
(util/goto-journals)
4040
(assert/assert-in-normal-mode?)
41-
(graph/switch-graph graph-name false))
41+
(graph/switch-graph graph-name false false))
4242
(w/with-page p1
4343
(util/goto-journals)
4444
(assert/assert-in-normal-mode?)
45-
(graph/switch-graph graph-name false))
45+
(graph/switch-graph graph-name false false))
4646
(let [graph-new-blocks (map #(str graph-name "-b1-" %) (range 5))]
4747
(add-blocks-and-check-on-other-tabs graph-new-blocks p1 [p2 p3])))]
4848
(w/with-page p1

0 commit comments

Comments
 (0)