Skip to content

Unit test for the cli and github action#133

Merged
5PK merged 1 commit into
mainfrom
dlo/cli-tests
May 20, 2026
Merged

Unit test for the cli and github action#133
5PK merged 1 commit into
mainfrom
dlo/cli-tests

Conversation

@DerekAgility
Copy link
Copy Markdown
Contributor

@DerekAgility DerekAgility commented May 19, 2026

A base set of unit tests for the current state of the CLI

Interestingly, found a few typescript errors while it was building these test cases

Bugs found and fixed during test writing

File Bug Fix
src/lib/getters/filesystem/get-galleries.ts readJsonFile returns null for malformed JSON; null.mediaGroupingID in the dedup filter threw TypeError Added if (gallery) guard before galleries.push(gallery)
src/lib/incremental/timestamp-tracker.ts path.join(process.cwd(), rootPath, ...) produced wrong path when rootPath was absolute, leaking files into the project root Changed to path.resolve(rootPath, ...)
src/core/state.ts resetState() reset operationType and dryRun but not autoPublish Added state.autoPublish = '' to resetState()
src/lib/publishers/*.ts (4 files) if (!targetGuid) guard on a string[] — empty array is truthy, so guard never fired; targetGuid[0] silently became undefined Changed to if (!targetGuid?.length)
src/lib/ui/console/logging-modes.ts validateLoggingState used !state.sourceGuid and !state.locale — empty arrays are truthy so validation never caught missing GUIDs/locales Changed to !state.sourceGuid?.length and !state.locale?.length
src/core/publish.ts PublishService constructor used !state.targetGuid — same empty-array truthy issue Changed to !state.targetGuid?.length
src/lib/workflows/refresh-mappings.ts path.join(process.cwd(), state.rootPath, ...) leaked log files into <project>/var/folders/... when rootPath was absolute Changed to path.resolve(state.rootPath, ...)
src/core/pull.ts, src/core/push.ts, src/core/state.ts (×2) Same path.join(process.cwd(), state.rootPath, ...) pattern in handleResetFlag and two state path helpers Changed all four to path.resolve(state.rootPath, ...)

@DerekAgility DerekAgility force-pushed the dlo/cli-tests branch 2 times, most recently from 46017f6 to a8c9921 Compare May 19, 2026 19:06
@DerekAgility DerekAgility changed the title Unit test for core files and github action Unit test for the cli and github action May 19, 2026
@DerekAgility DerekAgility requested review from 5PK and jules-exel May 19, 2026 19:10
@5PK 5PK merged commit fa99825 into main May 20, 2026
1 check passed
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.

2 participants