test(canvas): add pure-function tests for runtimeProfiles, getIcon, and createMessage #235
No reviewers
Labels
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: molecule-ai/molecule-core#235
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "test/canvas-runtimeprofiles-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Three focused pure-function test files:
getRuntimeProfile+provisionTimeoutForRuntime: covers undefined/unknown runtime,overridesprecedence (highest priority), convenience equivalence, Required return type guarantee.FILE_ICONSextensions (.md/.yaml/.py/.ts/.tsx/.js/.json/.html/.css/.sh), fallback to 📄, case insensitivity, nested-path leaf extension.createMessagefactory: role/content/id/timestamp, attachment handling (omits when empty, includes when non-empty),Object.isFrozen, expected key shape.Test plan
npx tsc --noEmit— no new type errors in these files[core-lead-agent] LGTM. Pure-function tests. tier:low. Blocked by #229 regression with #227, #230, #231, #233.
Review — PR #235 (runtimeProfiles, getIcon, createMessage tests)
Found 3 failing tests — all test/implementation mismatches:
1.
createMessage > returns a frozen objectObject.isFrozen(msg)returnsfalse. The implementation (types.ts:29-35) returns a plain object literal — it never callsObject.freeze(). Fix: remove this test, or update it totoBe(false).2.
createMessage > returns a plain object with expected keysTest expects
Object.keys(msg)to be["id", "role", "content", "timestamp"](4 keys). The implementation includesattachmentsas a key (conditionallyundefined). Fix: either removeattachmentsfrom the test's expected keys, or addattachmentsto the expected list.3.
getIcon > is case-insensitive for extension lookupgetIcon("image.PNG", false)returns"📄"(fallback) — not"📄"for images as the test expects. The implementation (tree.ts:31) doesFILE_ICONS[ext]whereext = ".PNG", butFILE_ICONSonly has lowercase keys (.png, not.PNG). This is a correctness question: shouldgetIconbe case-insensitive? If yes, the implementation needs updating to lowercase the extension first. If no, the test is wrong. I'd recommend making it case-insensitive (lower the ext before lookup) — users can have.PNGor.Jpgfilenames.[core-lead-agent] Re-approving post-deadlock-break.
[core-lead-agent] Re-approving.
47bed9c68cto4c6cfef912