diff --git a/shared/src/logseq/core/e2e_seed_cli.ml b/shared/src/logseq/core/e2e_seed_cli.ml index 53caaa97..7f817e39 100644 --- a/shared/src/logseq/core/e2e_seed_cli.ml +++ b/shared/src/logseq/core/e2e_seed_cli.ml @@ -60,7 +60,7 @@ let seed_mode conn mode = | Header_navigation -> Seed.seed_header_navigation conn | Composer -> Seed.seed_composer conn (now_ms ()) | Outliner -> Seed.seed_outliner conn (now_ms ()) - | Fixture -> Seed.seed_fixture conn + | Fixture -> Seed.seed_fixture conn (now_ms ()) | Performance -> Seed.seed_performance conn (now_ms ()) | PerformanceSized (journals, blocks) -> Seed.seed_performance_sized conn (now_ms ()) journals blocks diff --git a/shared/src/logseq/core/e2e_seed_data.ml b/shared/src/logseq/core/e2e_seed_data.ml index 1d5ad7d2..33d073ec 100644 --- a/shared/src/logseq/core/e2e_seed_data.ml +++ b/shared/src/logseq/core/e2e_seed_data.ml @@ -27,8 +27,20 @@ let entity_built_in db eid = let transact conn operations = ignore (Ds.transact_conn conn operations : Ds.tx_report) -let reset_user_page_entities conn = +let reset_user_page_entities ?preserve_page_uuid conn = let db = Ds.conn_db conn in + let preserved_page = + Option.bind preserve_page_uuid (fun uuid -> + Ds.entid db "block/uuid" (Ds.Uuid uuid)) + in + let is_preserved eid = + match preserved_page with + | None -> false + | Some page -> + eid = page + || (Ds.Db.datoms db Ds.Eavt ~e:eid ~a:"block/page" () + |> Seq.exists (fun (datom : Ds.datom) -> datom.v = Ds.Ref page)) + in let operations = Ds.Db.datoms db Ds.Aevt ~a:"block/uuid" () |> List.of_seq @@ -36,7 +48,7 @@ let reset_user_page_entities conn = if (entity_has_attr db datom.e "block/journal-day" || entity_has_attr db datom.e "block/page") - && not (entity_built_in db datom.e) + && not (entity_built_in db datom.e || is_preserved datom.e) then Some (Ds.RetractEntity (Ds.Entity_id datom.e)) else None) in @@ -294,8 +306,11 @@ let seed_outliner conn now = ]; ]) -let seed_fixture conn = - reset_user_page_entities conn; +let seed_fixture conn now = + (* The sync server already knows this journal. Removing it from the local + fixture would make startup try to create the same journal again. *) + let today_uuid = Journal.page_uuid (Model.journal_day_for_ms now) in + reset_user_page_entities ~preserve_page_uuid:today_uuid conn; seed conn let performance_page_uuid index = diff --git a/shared/src/logseq/core/e2e_seed_data.mli b/shared/src/logseq/core/e2e_seed_data.mli index 6557e11b..08c73062 100644 --- a/shared/src/logseq/core/e2e_seed_data.mli +++ b/shared/src/logseq/core/e2e_seed_data.mli @@ -20,7 +20,7 @@ val outliner_tag_uuid : string val entity_has_attr : Datascript.db -> int -> string -> bool val entity_built_in : Datascript.db -> int -> bool val transact : Datascript.conn -> Datascript.tx_op list -> unit -val reset_user_page_entities : Datascript.conn -> unit +val reset_user_page_entities : ?preserve_page_uuid:string -> Datascript.conn -> unit val uuid_attr : string -> Datascript.tx_value val string_attr : string -> Datascript.tx_value val int_attr : int -> Datascript.tx_value @@ -61,7 +61,7 @@ val tag_attrs : string -> string -> string -> (string * Datascript.tx_value) list val seed : Datascript.conn -> (unit, string) result val seed_outliner : Datascript.conn -> int -> (unit, string) result -val seed_fixture : Datascript.conn -> (unit, string) result +val seed_fixture : Datascript.conn -> int -> (unit, string) result val performance_page_uuid : int -> string val performance_block_uuid : int -> int -> string val performance_block_title : int -> int -> string diff --git a/shared/test/logseq/e2e_seed_data_test.ml b/shared/test/logseq/e2e_seed_data_test.ml index 0537dd26..027359cf 100644 --- a/shared/test/logseq/e2e_seed_data_test.ml +++ b/shared/test/logseq/e2e_seed_data_test.ml @@ -192,11 +192,27 @@ let outliner_reset_is_idempotent () = let standard_reset_is_idempotent () = let conn = Ds.create_conn ~schema () in for _ = 1 to 2 do - ignore (expect_ok (Seed.seed_fixture conn)) + ignore (expect_ok (Seed.seed_fixture conn 1787893600000)) done; check_eq (Graph.journal_page_count (Ds.conn_db conn)) 8; check_eq (List.length (visible (Ds.conn_db conn))) 18 +let standard_reset_preserves_the_synced_journal_for_today () = + let conn = Ds.create_conn ~schema () in + let now = 1787893600000 in + let today_uuid = Journal.page_uuid (Cache_model.journal_day_for_ms now) in + Seed.seed_current_journal conn now today_uuid Seed.composer_block_uuid + "Synced block"; + Seed.seed_current_journal conn (now - 86400000) Seed.outliner_page_uuid + Seed.outliner_block_uuid "Stale block"; + ignore (expect_ok (Seed.seed_fixture conn now)); + let db = Ds.conn_db conn in + check (exists db today_uuid); + check (exists db Seed.composer_block_uuid); + check (not (exists db Seed.outliner_page_uuid)); + check (not (exists db Seed.outliner_block_uuid)); + check_eq (Graph.journal_page_count db) 9 + let performance_reset_retains_one_hundred_journals () = let conn = Ds.create_conn ~schema () in for _ = 1 to 2 do @@ -315,6 +331,8 @@ let cases = standard_fixture_links_tags_rich_blocks_and_cards; case "outliner reset is idempotent" outliner_reset_is_idempotent; case "standard reset is idempotent" standard_reset_is_idempotent; + case "standard reset preserves the synced journal for today" + standard_reset_preserves_the_synced_journal_for_today; case "performance reset retains one hundred journals" performance_reset_retains_one_hundred_journals; case "performance fixture supports insertion between adjacent blocks" diff --git a/tests/e2e/android-search-navigation.yaml b/tests/e2e/android-search-navigation.yaml index 0f3eefc2..dd4b4d4e 100644 --- a/tests/e2e/android-search-navigation.yaml +++ b/tests/e2e/android-search-navigation.yaml @@ -9,13 +9,14 @@ appId: com.logseq.logseq id: "button.search" - assertVisible: id: "screen.search" -- tapOn: "Search pages and blocks" -- inputText: "E2E Page Target" +- tapOn: + id: "field.search" +- inputText: "Aug 16th, 2026" - extendedWaitUntil: visible: id: "screen.search.results" timeout: 10000 -- assertVisible: "E2E Page Target" +- assertVisible: "Aug 16th, 2026" - tapOn: id: "search.result.e2e10000-0000-4000-8000-000000000007" - extendedWaitUntil: @@ -26,7 +27,7 @@ appId: com.logseq.logseq - pressKey: BACK - assertVisible: id: "screen.search" -- assertVisible: "E2E Page Target 20260816" +- assertVisible: "Aug 16th, 2026" - hideKeyboard - pressKey: BACK - assertVisible: diff --git a/tests/e2e/android-settings.yaml b/tests/e2e/android-settings.yaml index 50577327..28b1c5b5 100644 --- a/tests/e2e/android-settings.yaml +++ b/tests/e2e/android-settings.yaml @@ -3,11 +3,12 @@ appId: com.logseq.logseq - launchApp - extendedWaitUntil: visible: - id: "button.overflow-menu" + id: "button.sidebar" timeout: 30000 - tapOn: - id: "button.overflow-menu" -- tapOn: "Settings" + id: "button.sidebar" +- tapOn: + id: "button.sidebar.settings" - extendedWaitUntil: visible: id: "screen.settings" @@ -26,12 +27,11 @@ appId: com.logseq.logseq id: "button.connection.apply" - extendedWaitUntil: visible: - id: "button.overflow-menu" + id: "button.sidebar.settings" timeout: 10000 - takeScreenshot: "android-settings-dark-theme" - tapOn: - id: "button.overflow-menu" -- tapOn: "Settings" + id: "button.sidebar.settings" - tapOn: id: "picker.settings.appearance" - tapOn: "System" @@ -39,11 +39,10 @@ appId: com.logseq.logseq id: "button.connection.apply" - extendedWaitUntil: visible: - id: "button.overflow-menu" + id: "button.sidebar.settings" timeout: 10000 - tapOn: - id: "button.overflow-menu" -- tapOn: "Settings" + id: "button.sidebar.settings" - extendedWaitUntil: visible: id: "screen.settings" @@ -167,4 +166,4 @@ appId: com.logseq.logseq - tapOn: id: "button.connection.cancel" - assertVisible: - id: "button.overflow-menu" + id: "button.sidebar.settings" diff --git a/tests/e2e/ios-local-graph-setup.yaml b/tests/e2e/ios-local-graph-setup.yaml index 1d0c1b2a..58eb90df 100644 --- a/tests/e2e/ios-local-graph-setup.yaml +++ b/tests/e2e/ios-local-graph-setup.yaml @@ -18,12 +18,14 @@ appId: com.logseq.logseq - tapOn: id: "field.auth.password" - inputText: "__LOGSEQ_E2E_PASSWORD__" - - hideKeyboard + # Submit from the password field without tapping through the sheet. + - pressKey: ENTER - tapOn: - id: "button.auth.submit" + text: "Not Now" + optional: true - extendedWaitUntil: visible: - id: "screen.graph-picker|button.composer.expand" + id: "button.graph-add|button.composer.expand" timeout: 60000 - runFlow: when: diff --git a/tests/e2e/ios-local-realtime-sync.yaml b/tests/e2e/ios-local-realtime-sync.yaml index 7c519558..264c411f 100644 --- a/tests/e2e/ios-local-realtime-sync.yaml +++ b/tests/e2e/ios-local-realtime-sync.yaml @@ -1,7 +1,6 @@ appId: com.logseq.logseq --- -- launchApp: - clearState: true +- launchApp - runFlow: when: visible: @@ -19,16 +18,17 @@ appId: com.logseq.logseq - tapOn: id: "field.auth.password" - inputText: "__LOGSEQ_E2E_PASSWORD__" - - hideKeyboard + - pressKey: ENTER - tapOn: - id: "button.auth.submit" + text: "Not Now" + optional: true - extendedWaitUntil: visible: - id: "screen.graph-picker|button.composer.expand" + id: "button.graph-add|button.composer.expand" timeout: 60000 - extendedWaitUntil: visible: - id: "screen.graph-picker" + id: "button.graph-add" timeout: 30000 - tapOn: "__LOGSEQ_E2E_GRAPH_NAME__" - extendedWaitUntil: @@ -37,9 +37,17 @@ appId: com.logseq.logseq timeout: 30000 - scrollUntilVisible: element: - text: "__LOGSEQ_E2E_DESKTOP_BLOCK__" + id: "outliner.block-action.*" + text: "Edit block __LOGSEQ_E2E_DESKTOP_BLOCK__" direction: DOWN timeout: 30000 +- tapOn: + id: "sync.connected" +- copyTextFrom: + id: "sync.cursor" +- evalScript: ${output.cursorBefore = Number(maestro.copiedText)} +- tapOn: + id: "button.sync.done" - tapOn: id: "button.composer.expand" - tapOn: @@ -47,16 +55,32 @@ appId: com.logseq.logseq - inputText: "__LOGSEQ_E2E_MOBILE_BLOCK__" - tapOn: id: "button.send" +- tapOn: + id: "surface.composer.dismiss" +- tapOn: + id: "sync.connected" - extendedWaitUntil: visible: - id: "sync.cursor-advanced" + id: "sync.pending" + text: "Saved" timeout: 30000 -- assertVisible: "__LOGSEQ_E2E_MOBILE_BLOCK__" +- copyTextFrom: + id: "sync.cursor" +- assertTrue: ${Number(maestro.copiedText) > output.cursorBefore} +- tapOn: + id: "button.sync.done" +- assertVisible: + id: "outliner.block-action.*" + text: "Edit block __LOGSEQ_E2E_MOBILE_BLOCK__" - stopApp - launchApp - extendedWaitUntil: - visible: "__LOGSEQ_E2E_DESKTOP_BLOCK__" + visible: + id: "outliner.block-action.*" + text: "Edit block __LOGSEQ_E2E_DESKTOP_BLOCK__" timeout: 30000 -- assertVisible: "__LOGSEQ_E2E_MOBILE_BLOCK__" +- assertVisible: + id: "outliner.block-action.*" + text: "Edit block __LOGSEQ_E2E_MOBILE_BLOCK__" - assertVisible: id: "sync.connected" diff --git a/tests/e2e/ios-settings-tabs.yaml b/tests/e2e/ios-settings-tabs.yaml index 1c293f74..f546f622 100644 --- a/tests/e2e/ios-settings-tabs.yaml +++ b/tests/e2e/ios-settings-tabs.yaml @@ -4,8 +4,9 @@ appId: com.logseq.logseq file: "__LOGSEQ_E2E_SETUP_FLOW__" - launchApp - tapOn: - id: "button.connection" -- tapOn: "Settings" + id: "button.sidebar" +- tapOn: + id: "button.sidebar.settings" - assertVisible: id: "screen.settings" - tapOn: @@ -24,17 +25,12 @@ appId: com.logseq.logseq - assertVisible: "Flashcards, off" - tapOn: "Settings" - tapOn: "Cancel" -- tapOn: - id: "button.sidebar" - assertNotVisible: id: "link.sidebar.flashcards" - assertVisible: id: "link.sidebar.graphs" - tapOn: - id: "button.sidebar.dismiss" -- tapOn: - id: "button.connection" -- tapOn: "Settings" + id: "button.sidebar.settings" - tapOn: id: "link.settings.tabs" - tapOn: @@ -42,7 +38,5 @@ appId: com.logseq.logseq - assertVisible: "Flashcards, on" - tapOn: "Settings" - tapOn: "Cancel" -- tapOn: - id: "button.sidebar" - assertVisible: id: "link.sidebar.flashcards" diff --git a/tests/e2e/ios-settings-theme-parity.yaml b/tests/e2e/ios-settings-theme-parity.yaml index 79d93cd3..d4466fcb 100644 --- a/tests/e2e/ios-settings-theme-parity.yaml +++ b/tests/e2e/ios-settings-theme-parity.yaml @@ -3,16 +3,19 @@ appId: com.logseq.logseq - runFlow: __LOGSEQ_E2E_SETUP_FLOW__ - extendedWaitUntil: visible: - text: "More" + id: "button.sidebar" timeout: 60000 -- tapOn: "More" -- tapOn: "Settings" +- tapOn: + id: "button.sidebar" +- tapOn: + id: "button.sidebar.settings" - assertVisible: id: "screen.settings" - assertVisible: "Theme" - assertVisible: "Language" - tapOn: id: "picker.settings.language" + point: "90%,50%" - scrollUntilVisible: element: text: "العربية" @@ -20,6 +23,7 @@ appId: com.logseq.logseq - tapOn: "العربية" - tapOn: id: "picker.settings.language" + point: "90%,50%" - scrollUntilVisible: element: text: "System"