Move the export crop math into a module and test it directly
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Read public/sections.mjs for the module pattern, then inspect public/demo.mjs:227-230 and test/export-crop.test.js. Move the crop calculation into public/export-geometry.mjs and have the test import it directly; retain the vertical and wide cases and add matching-ratio and zero-size cases. Done means the test has no readFile or new Function, npm test and npm run check pass, and a Chrome showcase export looks unchanged.
Written by the indexing model from the issue text.
Description
test/export-crop.test.js doesn't import the code it tests. It reads public/demo.mjs as text, finds drawExportFrame by searching for strings (lines 8-12), and rebuilds the crop lines with new Function(...) (lines 15-22). A harmless refactor breaks the test: renaming scaleToCover, moving context.save(), or reformatting the drawImage call (line 33 splits its arguments on commas).
Fix direction: follow the pattern of public/sections.mjs. Create public/export-geometry.mjs with a pure function:
export function coverCrop(sourceWidth, sourceHeight, box) // -> { sourceX, sourceY, sourceW, sourceH }
Then use it in drawExportFrame (public/demo.mjs:227-230). Rewrite test/export-crop.test.js to import coverCrop and keep the existing vertical and wide cases. Add a case where the source already matches the box ratio (no crop) and one with a zero-size box.
Don't change the visual output.
Done when the test has no readFile/new Function, npm test and npm run check pass, and a Chrome export of a showcase reference looks the same as before.
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from blixvip/NullMotion
-
accessibility help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
blixvip/NullMotion#47 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
blixvip/NullMotion#43 ·
-
accessibility good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
blixvip/NullMotion#42 ·
-
accessibility good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
blixvip/NullMotion#41 ·
-
accessibility good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
blixvip/NullMotion#40 ·
All issues in blixvip/NullMotion
Similar issues
-
enhancement language
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
pngwn/twinkleplop#178 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jasonacox/Powerwall-Dashboard#897 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
nikic/PHP-Parser#1187 ·
-
compiler
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
HerringtonDarkholme/hd-lang#1699 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100