saberzero1_quartz-syncer/test
Emile Bangma 0732c4d10f
Link inclusion fixes (#115)
* fix: prevent greedy regex matching across wikilink boundaries and preserve anchors

TRANSCLUDED_FILE_REGEX used (.*?) which matched across ]] boundaries when
multiple transcluded files appeared on the same line. Replace with character
classes [^\]|]* to constrain matches. Also fix anchor/fragment handling in
extractBlobLinks and convertFileLinks so #page=3 and #right are preserved
through the compile pipeline instead of being silently dropped.

* test: add Layer 1 regex contract tests and Layer 2 compiler step unit tests

Establish a two-layer testing foundation for the regex-to-remark-obsidian
migration. Layer 1 (44 tests) validates every regex pattern's match/capture
behavior as behavioral contracts. Layer 2 (29 tests) exercises compiler steps
in isolation with mocked Obsidian APIs. Expand __mocks__/obsidian.ts from a
stub to a full mock supporting Vault, MetadataCache, getLinkpath, etc.

* chore: scaffold Layer 3 E2E test infrastructure with wdio-obsidian-service

Add wdio.conf.mts, test vault fixtures, E2E test spec, and flake.nix for
NixOS nix-ld support. Configure Jest to exclude test/e2e/ and add test:unit
and test:e2e npm scripts. The E2E tests require installing wdio-obsidian-service
and its dependencies before they can run.

* fix(e2e): use destructured executeObsidian API and tolerate sandboxed vault names

Fix mocha import crash by using WDIO-provided globals. Use { app } destructuring
for executeObsidian callbacks per wdio-obsidian-service API. Use toContain for
vault name assertion since the service appends a random sandbox suffix.

* ci: add E2E test job with wdio-obsidian-service to GitHub Actions

Run E2E tests on ubuntu-latest after build, using xvfb and herbstluftwm
for virtual display. Cache downloaded Obsidian versions between runs.

* test: expand utils and regex contract coverage and add FrontmatterCompiler tests

Add Layer 2 FrontmatterCompiler unit tests (33 cases) covering compile output,
permalink/alias handling, pass-through fields, tags, CSS classes, social image
fields, and timestamp behavior. Expand Layer 1 regex contract tests with capture
assertions, edge cases, and CRLF/URL behaviors. Extend utils tests for
generateUrlPath, generateBlobHash, sanitizePermalink, and escapeRegExp.

* test: add createTranscludedText unit tests for transclusion behavior

Add a focused transclusion test suite that mocks PublishFile instances and
metadata cache resolution. Covers depth limits, applyEmbeds=false, block refs,
header transclusion, recursive embeds, excalidraw skip, vault path filtering,
and block-math line handling.

* fix: align lint/typecheck for E2E files and remove explicit any in tests

Introduce a dedicated tsconfig.eslint.json so lint can include E2E and wdio
files while typecheck excludes them. Remove explicit-any casts in unit tests
by using safer unknown casts and typed internal helpers. Update justfile full
recipe to run unit+e2e, and adjust mock signatures to satisfy lint.

* docs: add three-layer testing strategy to migration plan

Document the Layer 1 (regex contracts), Layer 2 (compiler unit tests),
and Layer 3 (E2E via wdio-obsidian-service) parity gates. Update Phase 1
and Phase 2 verification checklists to reference the test layers. Add
environment notes for NixOS, CI, and the tsconfig.eslint.json split.

* feat: complete Phase 2-3 migration to AST-based transforms and minimize compiler

Phase 2: Replace string-replace transforms with remark-obsidian AST pipeline
- Consolidate comment stripping, link resolution, vault path stripping into astTransform
- Remove removeObsidianComments, convertLinksToFullPath, applyVaultPath methods
- Add unified/remark-parse/remark-stringify/remark-obsidian dependencies

Phase 3: Delegate transforms to Quartz v5 build pipeline
- Remove createTranscludedText, createSvgEmbeds, and publish cache system
- Simplify constructor (5 params instead of 6)
- Reduce pipeline from 8 steps to 4: convertFrontMatter, convertIntegrations, linkTargeting, astTransform

Bug fixes:
- Fix embed blending: use text-based replacement instead of stale CachedMetadata offsets
- Fix callout bracket escaping: post-process to unescape blockquote callout syntax
- Fix table wikilink pipes: post-process to escape pipe in wikilinks on table rows

Compiler reduced from ~900 to ~500 lines. 155 tests pass.

* docs: add v1.11.0 changelog entry

* refactor: remove dead settings and simplify Excalidraw to pass-through

Remove applyEmbeds and pathRewriteRules (dead after Phase 2-3 migration)
from settings interface, defaults, UI toggle, and test mocks.

Simplify Excalidraw integration from SVG conversion (245 lines) to
pass-through (31 lines) matching BasesIntegration pattern. Quartz v5
will handle rendering. Add excalidraw shouldPublish check in Publisher.

Remove dead rewriteRule field and getRewriteRules/PathRewriteRule
imports from Publisher.

* feat: split connection status into read and write access checks

Use listServerRefs with forPush:true to query git-receive-pack endpoint,
testing write (push) access separately from read (fetch) access.

Settings header now shows two indicators: (read: ok) (write: ok).
A public repo without token correctly shows read ok but write failed.

* docs: update v1.11.0 changelog with settings cleanup and connection split

* fix: address Copilot review feedback

- Replace truncated PNG fixture with valid 1x1 PNG
- Rename misleading E2E test names to match actual assertions
- Fix status element detachment: recreate elements in initializeGitHeader
  instead of constructor, so they survive display() -> empty() cycles

* fix: handle escaped pipes in embed matching and prevent double-escape

- convertFileLinks now falls back to escaped-pipe variant of embed.original
  when astTransform has escaped | to \| in table-row wikilinks
- Table pipe escaping regex uses negative lookbehind to skip already-escaped pipes
- Remove misleading stripVaultPath docstring

* fix: scope pipe escaping fallback to wikilink context only

Replace generic | → \| replacement with wikilink-scoped regex to avoid
CodeQL incomplete-sanitization alert (js/incomplete-sanitization).
The replacement now only escapes pipes between [[ and ]], matching the
exact transformation astTransform applies on table rows.

* fix: remove stale convertFileLinks docstring referencing position-based replacement

* fix: filter canvas extractBlobLinks to asset extensions only

Canvas file nodes previously included all linked files (including .md
notes). Now filters through ASSET_EXTENSIONS so only images, fonts, and
other binary assets are collected for syncing.
2026-03-24 01:26:59 +01:00
..
e2e Link inclusion fixes (#115) 2026-03-24 01:26:59 +01:00
vaults/compile-test Link inclusion fixes (#115) 2026-03-24 01:26:59 +01:00