mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-21 16:52:01 -07:00
Review post-image-rendering: cover isImageUrl guard, stamp manifests
Merged the refactorer handoff (e77e174). The architecture holds: the image
helpers isImageUrl/imageAltText are pure post-links functions, failed-images
is a pure state transition, and PostImage/PostContent stay presentational
with no IO. Added a unit test for isImageUrl non-string input to kill the
last surviving language mutant; mutation and acceptance manifests are
tool-written.
By architect.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# acceptance-mutation-manifest-begin
|
||||
# {"version":1,"tested_at":"2026-09-16T14:30:45.236912355Z","feature_name":"Post Image Rendering","feature_path":"/home/trout/work/psf-memo/.worktrees/architect/psf-memo-client/specs/post-image-rendering.feature","background_hash":"0d66780cb1b8e277f0ada40a8ffe336dec7a8eaf658f19d2ea344815fb9bf26c","implementation_hash":"unknown","scenarios":[{"index":0,"name":"Post Image Rendering - 1 an image URL renders an inline image inside a link","scenario_hash":"7b43dc07b8d3d0c06df1c7afa5d1497a1e555364ae0c27eb3539deff1284b005","mutation_count":16,"result":{"Total":16,"Killed":16,"Survived":0,"Errors":0},"tested_at":"2026-09-16T14:30:45.236912355Z"},{"index":2,"name":"Post Image Rendering - 3 an image that fails to load falls back to a plain link","scenario_hash":"6fde4a40ced467661bde1c978957b34d93f9ec6162c4276d6ee942d7747af7ba","mutation_count":4,"result":{"Total":4,"Killed":4,"Survived":0,"Errors":0},"tested_at":"2026-09-16T14:30:45.236912355Z"}]}
|
||||
# acceptance-mutation-manifest-end
|
||||
|
||||
# Scenarios: Post Image Rendering - 1, Post Image Rendering - 2, Post Image Rendering - 3
|
||||
#
|
||||
# When a post contains a URL whose path ends in a common image file extension
|
||||
|
||||
@@ -122,5 +122,5 @@ function PostContent ({ text = '', initialFailedImages }) {
|
||||
module.exports = PostContent
|
||||
|
||||
// mutate4javascript-manifest-begin
|
||||
// {"version":1,"tested_at":"2026-09-16T02:29:59.905Z","module_hash":"bbc07a4d5e0d9bdf95e1d9014603fbe4ad38611469d51e006b082d32b5bd03c6","functions":[{"id":"func/PostContent","name":"PostContent","line":16,"end_line":63,"hash":"d2202910528f0974b6eaa1892d770e1a46a11e02b5b953c1a8490be59f349895"}]}
|
||||
// {"version":1,"tested_at":"2026-09-16T14:26:42.561Z","module_hash":"1d42bd3e5405ed39e16d308688f75b48430484dcd5096bae9de0e702fd058568","functions":[{"id":"func/PostImage","name":"PostImage","line":22,"end_line":51,"hash":"a7bd61e03c785b7ed6ae1ef0ea15e3d025448f5772b60234f08acd4fd4160a2d"},{"id":"func/PostContent","name":"PostContent","line":53,"end_line":120,"hash":"9af7f0009bd6d71655a47b09a3676f558acdf14a2ceb672765370a82aaf0a150"}]}
|
||||
// mutate4javascript-manifest-end
|
||||
|
||||
@@ -105,5 +105,5 @@ function imageAltText (url) {
|
||||
module.exports = { parsePostLinks, isImageUrl, imageAltText }
|
||||
|
||||
// mutate4javascript-manifest-begin
|
||||
// {"version":1,"tested_at":"2026-09-16T02:28:07.979Z","module_hash":"9d4045719f423239c99405aadb91cd21944e7d2deaa670b15eb53aee5ee66639","functions":[{"id":"func/isBareDomainBoundary","name":"isBareDomainBoundary","line":21,"end_line":26,"hash":"6cbcecc22428ecc54a2598d4401a350b3d07a849b651e5c76198b9defb927aef"},{"id":"func/pushText","name":"pushText","line":29,"end_line":31,"hash":"abda2060349c814451b88fe350ca235069afdc769eaa3ffa90e9d214673c71b9"},{"id":"func/parsePostLinks","name":"parsePostLinks","line":40,"end_line":75,"hash":"7a51da000274bf77614f288f9db2ba8490069202919a00cda9c3c474d7bf48d8"}]}
|
||||
// {"version":1,"tested_at":"2026-09-16T14:28:22.610Z","module_hash":"2909c5416f838cb7977227928ddc30b9b2055af4c047f21fe9dadfdec2ca8fb6","functions":[{"id":"func/isBareDomainBoundary","name":"isBareDomainBoundary","line":19,"end_line":24,"hash":"6cbcecc22428ecc54a2598d4401a350b3d07a849b651e5c76198b9defb927aef"},{"id":"func/pushText","name":"pushText","line":27,"end_line":29,"hash":"abda2060349c814451b88fe350ca235069afdc769eaa3ffa90e9d214673c71b9"},{"id":"func/parsePostLinks","name":"parsePostLinks","line":38,"end_line":73,"hash":"7a51da000274bf77614f288f9db2ba8490069202919a00cda9c3c474d7bf48d8"},{"id":"func/isImageUrl","name":"isImageUrl","line":82,"end_line":89,"hash":"60c63ca1cc2dd0d69ff2900b168205abaea460671b9f2a9290e991f9e0dacd22"},{"id":"func/imageAltText","name":"imageAltText","line":95,"end_line":103,"hash":"99868cbf14ff8508e9f9fbdfbd2f7583809e50da0561fdd48757a4e748c81bf3"}]}
|
||||
// mutate4javascript-manifest-end
|
||||
|
||||
@@ -157,6 +157,13 @@ test('isImageUrl rejects URLs that are not images', () => {
|
||||
assert.equal(isImageUrl('not a url'), false)
|
||||
})
|
||||
|
||||
test('isImageUrl rejects non-string input', () => {
|
||||
assert.equal(isImageUrl(null), false)
|
||||
assert.equal(isImageUrl(undefined), false)
|
||||
assert.equal(isImageUrl(12345), false)
|
||||
assert.equal(isImageUrl({}), false)
|
||||
})
|
||||
|
||||
test('imageAltText returns the URL filename', () => {
|
||||
assert.equal(imageAltText('https://i.imgur.com/swCI56T.jpeg'), 'swCI56T.jpeg')
|
||||
assert.equal(imageAltText('https://cdn.example.com/pics/Sunset.PNG'), 'Sunset.PNG')
|
||||
|
||||
Reference in New Issue
Block a user