refactor: split order title i18n keys into no-amount / with-amount variants#859
refactor: split order title i18n keys into no-amount / with-amount variants#859grunch wants to merge 1 commit into
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c664a0d to
532622e
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/bot/ordersActions.spec.ts (1)
59-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTest coverage gap: two of the eight title branches are untested.
Across both describe blocks,
showusername_buying_sats_with_amount(username + buy + fixed) andshowusername_selling_sats(username + sell + market/range) are never exercised. Consider adding one test case per block for symmetry with the existing username-based assertions.✅ Suggested additional test cases
it('shows the username and the sats amount when the user shows their name', () => { const title = getOrderTitleMessage(i18nCtx, { user: publicUser, type: 'sell', amount: 100, fiatCode: 'USD', priceFromAPI: false, }); expect(title).to.equal('`@alice` is selling 100 sats'); }); + + it('shows the username and the sats amount when buying', () => { + const title = getOrderTitleMessage(i18nCtx, { + user: publicUser, + type: 'buy', + amount: 100, + fiatCode: 'USD', + priceFromAPI: false, + }); + + expect(title).to.equal('`@alice` is buying 100 sats'); + }); });it('shows the username but omits the amount when the user shows their name', () => { const title = getOrderTitleMessage(i18nCtx, { user: publicUser, type: 'buy', amount: 0, fiatCode: 'USD', priceFromAPI: true, }); + + expect(title).to.equal('`@alice` is buying sats'); + }); + + it('shows the username but omits the amount when selling', () => { + const title = getOrderTitleMessage(i18nCtx, { + user: publicUser, + type: 'sell', + amount: 0, + fiatCode: 'USD', + priceFromAPI: true, + }); + + expect(title).to.equal('`@alice` is selling sats'); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/bot/ordersActions.spec.ts` around lines 59 - 93, Add the missing title coverage in getOrderTitleMessage by creating one username-based test for the fixed-price buy branch and one for the market/range sell branch, alongside the existing anonymousUser/publicUser cases in tests/bot/ordersActions.spec.ts. Use the same describe blocks and verify the exact formatted title for publicUser so the showusername_buying_sats_with_amount and showusername_selling_sats paths are exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/bot/ordersActions.spec.ts`:
- Around line 59-93: Add the missing title coverage in getOrderTitleMessage by
creating one username-based test for the fixed-price buy branch and one for the
market/range sell branch, alongside the existing anonymousUser/publicUser cases
in tests/bot/ordersActions.spec.ts. Use the same describe blocks and verify the
exact formatted title for publicUser so the showusername_buying_sats_with_amount
and showusername_selling_sats paths are exercised.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: abe8075e-ab07-4f90-83cb-a6dfc29fb2e1
📒 Files selected for processing (12)
bot/ordersActions.tslocales/de.yamllocales/en.yamllocales/es.yamllocales/fa.yamllocales/fr.yamllocales/it.yamllocales/ko.yamllocales/pt.yamllocales/ru.yamllocales/uk.yamltests/bot/ordersActions.spec.ts
Closes #854
Problem
After #852 the order title keys interpolate
${amount}with no space in the template ('Selling ${amount}sats') because the separating space lives inside the interpolated variable as a trailing-space hack. That's invisible to translators: adding the "missing" space in the YAML produces a double space, and languages where the amount can't sit adjacent to the noun can't reorder safely.Changes
Locales (all 10): each title key is split into two explicit variants, with the space visible in the template:
Same for
buying_satsand bothshowusername_*keys. The no-amount variants restore the pre-#770 wording verbatim (e.g. French recovers "achète des sats", which the single-key version had to drop). The with-amount variants keep each locale's current wording, just with an explicit space — native-speaker review welcome.getOrderTitleMessage: selects the key variant instead of building an empty-or-trailing-space string; takes an options object (OrderTitleArguments) instead of 6 positional params; the comment now matches the actual guard (priceFromAPI, notamount === 0).Spec:
tests/bot/ordersActions.spec.tsupdated to the new signature with identical expected strings — the regression test from #852 passing unchanged is the proof that rendered output is preserved.Notes
Test plan
npm run lintclean, fullnpx tscbuild cleanSummary by CodeRabbit
New Features
Bug Fixes
10 satsinstead of10sats.