From 74728ae2bc7e5c81365a70e0e596c1c18a340dc4 Mon Sep 17 00:00:00 2001 From: Junyi Du Date: Tue, 16 May 2023 16:18:46 +0800 Subject: [PATCH 01/11] Enhance: version control settings description update (#9373) * enhance: remove version control entry blocker * ui: version control text box update Co-authored-by: Gabriel Horner <97210743+logseq-cldwalker@users.noreply.github.com> --------- Co-authored-by: Gabriel Horner <97210743+logseq-cldwalker@users.noreply.github.com> --- src/main/frontend/components/settings.cljs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/frontend/components/settings.cljs b/src/main/frontend/components/settings.cljs index 294947e25f..fa22c986df 100644 --- a/src/main/frontend/components/settings.cljs +++ b/src/main/frontend/components/settings.cljs @@ -667,14 +667,20 @@ [] [:div.panel-wrap [:div.text-sm.my-4 + (ui/admonition + :tip + [:p "If you have Logseq Sync enabled, you can view a page's edit history directly. This section is for tech-savvy only."]) + [:span.text-sm.opacity-50.my-4 + "To view page's edit history, click the three horizontal dots in the top-right corner and select \"View page history\"."] + [:br][:br] [:span.text-sm.opacity-50.my-4 - "You can view a page's edit history by clicking the three horizontal dots " - "in the top-right corner and selecting \"View page history\". " - "Logseq uses "] + "For professional users, Logseq also supports using "] [:a {:href "https://git-scm.com/" :target "_blank"} "Git"] [:span.text-sm.opacity-50.my-4 - " for version control."]] + " for version control."] + [:span.text-sm.opacity-50.my-4 + "Use Git at your own risk as general Git issues are not supported by the Logseq team"]] [:br] (switch-git-auto-commit-row t) (git-auto-commit-seconds t) @@ -827,9 +833,7 @@ [[:general "general" (t :settings-page/tab-general) (ui/icon "adjustments")] [:editor "editor" (t :settings-page/tab-editor) (ui/icon "writing")] - (when (and - (util/electron?) - (not (file-sync-handler/synced-file-graph? current-repo))) + (when (util/electron?) [:git "git" (t :settings-page/tab-version-control) (ui/icon "history")]) ;; (when (util/electron?) From c119b1eeb58bc5c6a51ac405649bc9f981a4ae73 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Mon, 15 May 2023 18:22:06 +0300 Subject: [PATCH 02/11] fix multiselect right click on converted shape --- .../core/src/lib/tools/TLSelectTool/states/ContextMenuState.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ContextMenuState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ContextMenuState.ts index 0810525ee4..63bfe65098 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ContextMenuState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ContextMenuState.ts @@ -17,11 +17,10 @@ export class ContextMenuState< onEnter = (info: TLEventInfo) => { const { selectedIds, - selectedShapes, inputs: { shiftKey }, } = this.app - if (info.type === TLTargetType.Shape && !selectedShapes.has(info.shape)) { + if (info.type === TLTargetType.Shape && !selectedIds.has(info.shape.id)) { const shape = this.app.getParentGroup(info.shape) ?? info.shape if (shiftKey) { this.app.setSelectedShapes([...Array.from(selectedIds.values()), shape.id]) From ad5757de61f19a7337a0095fe0956c8538f63137 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Mon, 15 May 2023 18:22:22 +0300 Subject: [PATCH 03/11] fix: undo/redo of converted shapes --- tldraw/packages/core/src/lib/TLApi/TLApi.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tldraw/packages/core/src/lib/TLApi/TLApi.ts b/tldraw/packages/core/src/lib/TLApi/TLApi.ts index 78ff6d6258..90d91e113e 100644 --- a/tldraw/packages/core/src/lib/TLApi/TLApi.ts +++ b/tldraw/packages/core/src/lib/TLApi/TLApi.ts @@ -428,6 +428,7 @@ export class TLApi Date: Mon, 15 May 2023 18:22:44 +0300 Subject: [PATCH 04/11] fix: context bar actions of converted shapes --- .../src/components/ContextBar/contextBarActionFactory.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx index 5136393259..344690a971 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx @@ -103,7 +103,7 @@ const AutoResizingAction = observer(() => { className="tl-button" pressed={pressed} onPressedChange={v => { - shapes.forEach(s => { + app.selectedShapesArray.forEach(s => { if (s.props.type === 'logseq-portal') { s.update({ isAutoResizing: v, @@ -253,7 +253,7 @@ const NoFillAction = observer(() => { const app = useApp() const shapes = filterShapeByAction('NoFill') const handleChange = React.useCallback((v: boolean) => { - shapes.forEach(s => s.update({ noFill: v })) + app.selectedShapesArray.forEach(s => s.update({ noFill: v })) app.persist() }, []) @@ -279,14 +279,14 @@ const SwatchAction = observer(() => { >('Swatch') const handleSetColor = React.useCallback((color: string) => { - shapes.forEach(s => { + app.selectedShapesArray.forEach(s => { s.update({ fill: color, stroke: color }) }) app.persist() }, []) const handleSetOpacity = React.useCallback((opacity: number) => { - shapes.forEach(s => { + app.selectedShapesArray.forEach(s => { s.update({ opacity: opacity }) }) app.persist() From e5de374471c3c23726ae84965b39ff1ac8e5f370 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Mon, 15 May 2023 18:55:50 +0300 Subject: [PATCH 05/11] chore: add tests --- e2e-tests/whiteboards.spec.ts | 19 +++++++++++++++++++ .../src/lib/shapes/EllipseShape.tsx | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/e2e-tests/whiteboards.spec.ts b/e2e-tests/whiteboards.spec.ts index c012363c11..fd3c203398 100644 --- a/e2e-tests/whiteboards.spec.ts +++ b/e2e-tests/whiteboards.spec.ts @@ -159,6 +159,25 @@ test('undo the delete action', async ({ page }) => { await expect(page.locator('.logseq-tldraw .tl-line-container')).toHaveCount(1) }) +test('convert the first rectangle to ellipse', async ({ page }) => { + await page.keyboard.press('Escape') + await page.waitForTimeout(1000) + await page.click('.logseq-tldraw .tl-box-container:first-of-type') + await page.click('.tl-context-bar .tl-geometry-tools-pane-anchor') + await page.click('.tl-context-bar .tl-geometry-toolbar [data-tool=ellipse]') + + await expect(page.locator('.logseq-tldraw .tl-ellipse-container')).toHaveCount(1) + await expect(page.locator('.logseq-tldraw .tl-box-container')).toHaveCount(1) +}) + +test('undo the conversion', async ({ page }) => { + await page.keyboard.press(modKey + '+z') + + await expect(page.locator('.logseq-tldraw .tl-box-container')).toHaveCount(2) + await expect(page.locator('.logseq-tldraw .tl-ellipse-container')).toHaveCount(0) +}) + + test('locked elements should not be removed', async ({ page }) => { await page.keyboard.press('Escape') await page.waitForTimeout(1000) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx index 3fb4a3c512..3dd3019e0c 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx @@ -98,7 +98,8 @@ export class EllipseShape extends TLEllipseShape { ) return ( -
+
Date: Mon, 15 May 2023 19:27:19 +0300 Subject: [PATCH 06/11] revert unneeded change --- .../src/components/ContextBar/contextBarActionFactory.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx index 344690a971..e950737bfb 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx @@ -103,7 +103,7 @@ const AutoResizingAction = observer(() => { className="tl-button" pressed={pressed} onPressedChange={v => { - app.selectedShapesArray.forEach(s => { + shapes.forEach(s => { if (s.props.type === 'logseq-portal') { s.update({ isAutoResizing: v, From 25d1d9eae20fa64a8eea4098e823cb093a89cf0b Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Tue, 16 May 2023 13:44:30 +0300 Subject: [PATCH 07/11] revert mobile? fn --- src/main/frontend/extensions/tldraw.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/frontend/extensions/tldraw.cljs b/src/main/frontend/extensions/tldraw.cljs index 3b6ae9df5e..ff96171fde 100644 --- a/src/main/frontend/extensions/tldraw.cljs +++ b/src/main/frontend/extensions/tldraw.cljs @@ -100,7 +100,7 @@ :getBlockPageName #(:block/name (model/get-block-page (state/get-current-repo) (parse-uuid %))) :exportToImage (fn [page-name options] (state/set-modal! #(export/export-blocks page-name (merge (js->clj options :keywordize-keys true) {:whiteboard? true})))) :isWhiteboardPage model/whiteboard-page? - :isMobile (util/mobile?) + :isMobile util/mobile? :saveAsset save-asset-handler :makeAssetUrl editor-handler/make-asset-url :copyToClipboard (fn [text, html] (util/copy-to-clipboard! text :html html)) From f5309270620855f112d2ec0f170b9bd20475f66b Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Tue, 16 May 2023 14:05:52 +0300 Subject: [PATCH 08/11] chore: add and fix e2e tests --- e2e-tests/whiteboards.spec.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e-tests/whiteboards.spec.ts b/e2e-tests/whiteboards.spec.ts index fd3c203398..ff4c19a841 100644 --- a/e2e-tests/whiteboards.spec.ts +++ b/e2e-tests/whiteboards.spec.ts @@ -163,6 +163,7 @@ test('convert the first rectangle to ellipse', async ({ page }) => { await page.keyboard.press('Escape') await page.waitForTimeout(1000) await page.click('.logseq-tldraw .tl-box-container:first-of-type') + await page.mouse.move(0, 0) // move mouse to trigger a rerender of the context bar await page.click('.tl-context-bar .tl-geometry-tools-pane-anchor') await page.click('.tl-context-bar .tl-geometry-toolbar [data-tool=ellipse]') @@ -170,6 +171,19 @@ test('convert the first rectangle to ellipse', async ({ page }) => { await expect(page.locator('.logseq-tldraw .tl-box-container')).toHaveCount(1) }) +test('change the color of the ellipse', async ({ page }) => { + await page.click('.tl-context-bar .tl-color-bg') + await page.click('.tl-context-bar .tl-color-palette .bg-red-500') + + await expect(page.locator('.logseq-tldraw .tl-ellipse-container ellipse:last-of-type')).toHaveAttribute('fill', 'var(--ls-wb-background-color-red)') +}) + +test('undo the color switch', async ({ page }) => { + await page.keyboard.press(modKey + '+z') + + await expect(page.locator('.logseq-tldraw .tl-ellipse-container ellipse:last-of-type')).toHaveAttribute('fill', 'var(--ls-wb-background-color-default)') +}) + test('undo the conversion', async ({ page }) => { await page.keyboard.press(modKey + '+z') @@ -177,7 +191,6 @@ test('undo the conversion', async ({ page }) => { await expect(page.locator('.logseq-tldraw .tl-ellipse-container')).toHaveCount(0) }) - test('locked elements should not be removed', async ({ page }) => { await page.keyboard.press('Escape') await page.waitForTimeout(1000) From afdb5c259b8339953fc5e95a7238731036471fe4 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Tue, 16 May 2023 14:06:40 +0300 Subject: [PATCH 09/11] fix: test description --- e2e-tests/whiteboards.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/whiteboards.spec.ts b/e2e-tests/whiteboards.spec.ts index ff4c19a841..36158ff680 100644 --- a/e2e-tests/whiteboards.spec.ts +++ b/e2e-tests/whiteboards.spec.ts @@ -184,7 +184,7 @@ test('undo the color switch', async ({ page }) => { await expect(page.locator('.logseq-tldraw .tl-ellipse-container ellipse:last-of-type')).toHaveAttribute('fill', 'var(--ls-wb-background-color-default)') }) -test('undo the conversion', async ({ page }) => { +test('undo the shape conversion', async ({ page }) => { await page.keyboard.press(modKey + '+z') await expect(page.locator('.logseq-tldraw .tl-box-container')).toHaveCount(2) From f8cc5996254c5c69f8f3cd4d118c76ac5e2ca377 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Tue, 16 May 2023 14:07:56 +0300 Subject: [PATCH 10/11] style: run prettier --- .../src/components/ContextBar/contextBarActionFactory.tsx | 4 +--- tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx index e950737bfb..ce6f2197f1 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx @@ -133,9 +133,7 @@ const LogseqPortalViewModeAction = observer(() => {
{collapsed ? 'Expand' : 'Collapse'}
) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx index 3dd3019e0c..9930befbf7 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/EllipseShape.tsx @@ -98,8 +98,11 @@ export class EllipseShape extends TLEllipseShape { ) return ( -
+
Date: Tue, 16 May 2023 14:25:26 -0400 Subject: [PATCH 11/11] Document repl test workflow as a followup to #9372 Also organized unit test sections more --- docs/dev-practices.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 1be7496a6e..281f23fb51 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -139,7 +139,17 @@ By convention, a namespace's tests are found at a corresponding namespace of the same name with an added `-test` suffix. For example, tests for `frontend.db.model` are found in `frontend.db.model-test`. -There are a couple different ways to develop with tests: +There are a couple different ways to run tests: + +* [Focus tests](#focus-tests) - Run one or more tests from the CLI +* [Autorun tests](#autorun-tests) - Autorun tests from the CLI +* [Repl tests](#repl-tests) - Run tests from REPL + +There a couple types of tests and they can overlap with each other: + +* [Database tests](#database-tests) - Tests that involve a datascript DB. +* [Performance tests](#performance-tests) - Tests that aim to measure and enforce a performance characteristic. +* [Async tests](#async-tests) - Tests that run async code and require some helpers. #### Focus Tests @@ -166,6 +176,15 @@ To run tests automatically on file save, run `clojure -M:test watch test the `:ns-regexp` option e.g. `clojure -M:test watch test --config-merge '{:autorun true :ns-regexp "frontend.util.page-property-test"}'`. +#### REPL tests + +Most unit tests e.g. ones that are browser compatible and don't require node libraries, can be run from the REPL. To do so: + +* Start a REPL for your editor. See [here for an example](https://github.com/logseq/logseq/blob/master/docs/develop-logseq.md#repl-setup). +* Load a test namespace. +* Run `(cljs.test/run-tests)` to run tests for the current test namespace. + + #### Database tests To write a test that uses a datascript db: @@ -188,7 +207,7 @@ To write a performance test: For examples of these tests, see `frontend.db.query-dsl-test` and `frontend.db.model-test`. -### Async Unit Testing +#### Async Tests Async unit testing is well supported in ClojureScript. https://clojurescript.org/tools/testing#async-testing is a good guide for how to