Skip to content

test(outliner): the outliner core cases mutation testing found no test checked - #13673

Open
yuxi-liu-wired wants to merge 18 commits into
logseq:masterfrom
yuxi-liu-wired:test/outliner-core-edges
Open

yuxi-liu-wired wants to merge 18 commits into
logseq:masterfrom
yuxi-liu-wired:test/outliner-core-edges

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing of deps/outliner/src/logseq/outliner/core.cljs: 492 one-line changes (=/not=, and/or, when/when-not, if/if-not, first/last, nil?/some?, seq/empty?, a dropped not, true/false, >/>= and so on). The app's outliner tests and the outliner library's own suite caught 263; 229 left every test passing. This adds a test for the ones that change what a user sees; each new test passes here and fails on its change. Of the 229, the tests here catch 173; 4 more are caught once #13675 makes the page cleanup on edit work; 48 change nothing a test can see (the two branches give the same entity, a log line, an assert on bad data, a check another check repeats); 2 guard moving a property value up or down at its edge, whose behavior the nbb run cannot show (see the correction below); 2 are in code of an open pull request (#13606), not on master.

What the new tests pin down, by function:

  • save-block: a new title renames a page (:block/name); the title of another page is refused; a block title may hold a /; a warning is cleared when the title changes and kept otherwise; a markdown heading marker is dropped except in a code block; a block's uuid cannot change; an inline tag deleted from the title is removed; the block's and its page's updated-at are bumped; a block gets no page name; a page the new title refers to is created; :db/other-tx is transacted.
  • indent-outdent-blocks: an indent goes after the last child of the block above, as a child of a block with no children, and expands a collapsed block; a non-consecutive selection does not indent; an outdent to the original parent goes after it; a direct outdent takes the right siblings after its own children; a property value is not outdented.
  • get-target-block, get-target-block-page: a target given by its uuid alone; a move up whose target is the first block's grandparent; an insert at the top, at the bottom, at the bottom of a block with no children; an indent or outdent onto a linked block; a sibling of a nested page lands on the page it is nested in.
  • insert-blocks and its helpers: new timestamps; an existing block given by its db id alone brings its content; a paste drops an asset block, another insert keeps it; one block after an empty block keeps that block; pasting a copied page links to the existing page; a map with a page name is a page; without keep-uuid? a new uuid; the history keeps the inserted uuids and the pages the insert creates; blocks next to a numbered list item take its list type; a template insert points refs between its own blocks at the new blocks.
  • delete-blocks: deleting the value of a property with a default value empties the property; deleting two of its values deletes both; a non-consecutive selection deletes each block.
  • remove-orphaned-page-refs!: of a block's old refs, only the empty page the new title no longer references is retracted; a new ref given by its db id alone or by its name keeps its page (with the or of its name lookup made an and, that page, still referenced, was retracted); a page another block references stays.
  • Tags: matching-ref-for-tag, fix-tag-ids (including a tag whose ref differs only in case), add-missing-tag-idents, inline-tag-disallowed?, remove-disallowed-inline-classes, remove-tags-when-title-changed.
  • Order: get-block-orders, compare-order-paths, outline-order-path, get-top-level-blocks.
  • resolve-refs-dedup: two refs to one new page create it once; #Movie and #movie are two classes.
  • Moves: a block moved to another page takes its children and grandchildren along; the first value of a property does not move up out of it. Leaf property values: a default value takes no child.

The library cases are in deps/outliner/test/logseq/outliner/core_edges_test.cljs (pnpm test in deps/outliner). The cases that call save-block, or rely on an entity counting as a map, are in src/test/logseq/outliner/entity_ops_test.cljs: under nbb an entity is not map? and save-block's merge into an entity fails.

For whoever knows the intent:

  • core.cljs line 513: validate-block-title runs for (or (ldb/page? block-entity) (ldb/object? block-entity)), but both checks it makes act on pages only, so the object half validates nothing: two blocks tagged #Person can be given the same title.
  • Correction: an earlier version of this description said move-blocks-up-down! on the second value of a many-valued property leaves the values as they were. That was the nbb test run, where an entity has no :block/_raw-parent and a property value never finds its siblings. In the app, moving the second value up turns it into an ordinary child of the block and drops it from the property; that is a separate fix with its own test.

Also added since: property values moved and inserted (a block moved next to a value becomes a value; a paste drops a block's property origin, an insert keeps it), a collapse that does not bump updated-at, a new inline tag that becomes a class, a page nested under a block, and a move up onto a collapsed block.

@yuxi-liu-wired yuxi-liu-wired changed the title test(outliner): cases of the outliner core no test checked test(outliner): the outliner core cases mutation testing found no test checked Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired
yuxi-liu-wired force-pushed the test/outliner-core-edges branch 5 times, most recently from 5f41465 to b9328d9 Compare October 22, 2026 11:01
@yuxi-liu-wired
yuxi-liu-wired force-pushed the test/outliner-core-edges branch 5 times, most recently from 056429a to 122211c Compare October 31, 2026 11:00
@yuxi-liu-wired
yuxi-liu-wired force-pushed the test/outliner-core-edges branch from 122211c to ab89df7 Compare November 3, 2026 12:00
@yuxi-liu-wired
yuxi-liu-wired force-pushed the test/outliner-core-edges branch 7 times, most recently from 29338b6 to d3f9872 Compare November 18, 2026 14:37
A one-line change to any of these lines of deps/outliner/src/logseq/outliner/core.cljs left every test passing; each new test fails on its change:

- matching-ref-for-tag: the ref whose title is the tag's in the same case wins, else the first ref
- fix-tag-ids: a tag takes the uuid of the ref with its name; a tag given as a db id is looked up first
- add-missing-tag-idents: an existing tag is left alone; a new one gets an ident, extends Root and is no longer a page
- inline-tag-disallowed?: a built-in page named by title alone
- url-property-value-forbidden-target?: a URL value takes no child
- page-updated-at-tx: a page keeps the created-at it has
- get-target-block-page: a sibling of a nested page lands on the page it is nested in
- get-target-block: an insert at the bottom goes after the last child; a move up takes the parent of the first moved block
- save-block: a new title renames a page (its :block/name), the title of another page is refused, a block title may hold a slash (page title characters are checked for pages only)

The save-block and copy cases are in src/test (logseq.outliner.entity-ops-test): save-block merges into an entity, which the outliner library's nbb test run cannot do.
A save clears a warning when the title changes and keeps it otherwise; drops a markdown heading marker except in a code block; refuses a new uuid for a block; removes an inline tag deleted from the title; bumps the block's and its page's updated-at; gives a block no page name; creates a page its new title refers to; transacts its :db/other-tx.
An indent goes after the last child of the block above, as a child of a block with no children, and expands a collapsed block; two blocks indent together; a non-consecutive selection does not indent; an outdent to the original parent goes after it; a direct outdent takes the right siblings after its own children; a property value block is not outdented.
…ndent

A target given by its uuid alone; a move up whose target is the first block's grandparent stays under it; an insert at the top of a block goes in as its first child, at the bottom of a block with no children as its child; an indent onto a linked block goes after the last child of the block it links, an outdent onto it takes the linked block itself.
remove-orphaned-page-refs!: of a block's old refs, only the empty page the new title no longer references is retracted; a new ref given by its db id alone or by its name keeps its page; unchanged refs retract nothing; a page another block references stays.
An inserted block gets new timestamps; an existing block given by its db id alone brings its content; a paste drops an asset block, another insert keeps it; one block inserted after an empty block keeps that block; the insert's history keeps the inserted uuids.
Deleting the value of a property that has a default value sets the property to the empty placeholder; deleting two of its values deletes both; a non-consecutive selection deletes each block.
…the title

remove-disallowed-inline-classes: a built-in page used as an inline tag is dropped from a block's tags and turned back into text in its title, whether the tags are given as a db id, a [:block/uuid] lookup or entities; an allowed tag stays; a disallowed tag the title does not use stays; a page, and a map with a page name, are returned as they are.
get-block-orders: kept orders that fall at the target stay, children's too; kept top-level orders below the target or above its right sibling get new ones at the target, in their order, while children keep theirs; without keep each block gets its own new order at the target; as children, orders go before the first child. compare-order-paths: equal, empty, prefix and differing paths. outline-order-path: a block's path ends with its parent's order and its own; a property value has none.
Blocks inserted next to a numbered list item take its list type, a block with its own keeps it, and as children they follow the first child; a template insert points refs between its own blocks at the new blocks; a copied block does not take the source db id.
…r page

An inline tag deleted from a title is retracted, one still in it or never inline stays; a tag whose ref differs only in case is dropped; a class given by its ident alone is a disallowed inline tag; a property's default value takes no child while a sibling of a URL value of a many-valued property is allowed; a block moved to another page takes its children and grandchildren along; the first value of a property does not move up out of it; a paste through insert-blocks! keeps its op.
resolve-refs-dedup: two refs to one new page create it once; #Movie and #movie are two classes; a ref to an existing page reuses it; a new journal ref creates a journal.
get-top-level-blocks: two siblings given back to front come out front to back; a last child and its parent's next sibling given back to front come out in page order.
…n insert

Pasting a copied page links to the existing page instead of making another; a map with a page name is inserted as a page with no :block/page; without keep-uuid? an inserted block gets a new uuid; the insert's history carries the pages it creates in the refs.
…lapsed block

container-page-eid: a page nested under an ordinary block is contained in no page, a page under a page in that page, a block in its page. A move up onto a collapsed block targets the block, not its hidden last child.
…dated-at

A block moved next to a property value becomes a value of that property; next to an ordinary block an insert keeps a block's property origin and a paste drops it; moving two values of a property keeps both under the block. Collapsing a block (save-block! with :collapse-expand-blocks) does not bump its updated-at.
save-block with a new #NewTag (the ref map the editor's parser makes) gives the tag an ident and makes it extend Root.
@yuxi-liu-wired
yuxi-liu-wired force-pushed the test/outliner-core-edges branch from d3f9872 to fd4d391 Compare November 19, 2026 12:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant