diff --git a/README.md b/README.md
index ffb8498..d4c505a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Pricing Calculator
-[](https://github.com/sterlingspares/calc/actions/workflows/tests.yml)         
+[](https://github.com/sterlingspares/calc/actions/workflows/tests.yml)         
**Live app:** [calc.sterlingspares.com](https://calc.sterlingspares.com)
@@ -145,7 +145,7 @@ sw.js service worker
manifest.json PWA manifest
_headers response headers for the host
tests/ test suite (dev-only)
-docs/ screenshots for this README (npm run screenshots)
+docs/ README screenshots — all four are generated (npm run screenshots)
robots.txt · sitemap.xml indexing
```
@@ -455,6 +455,8 @@ Three things that are useful beside a calculation but are not part of one live
under **Tools** in the header — the quote builder and the two converters. On a
phone they are in the hamburger menu instead. Press `T` to open it.
+
+
### GP % / markup % converter
Two ways of quoting the same profit, over different denominators — which is why
@@ -470,8 +472,9 @@ money. **Tools → GP ⇄ Markup** takes either and returns the other:
`markup = GP ÷ (100 − GP)` and `GP = markup ÷ (100 + markup)`. It shows the
result as money as well — *buy at ₹100.00, sell at ₹125.00* — because a
percentage on its own is easy to nod along to. **Use this calculation** seeds it
-from whatever is on screen, and the two ends with no finite answer (100% GP,
-−100% markup) say so rather than blanking.
+from whatever is on screen; with nothing to pull in it stays put and says what
+is missing, rather than disappearing. The two ends with no finite answer (100%
+GP, −100% markup) say so rather than blanking.
### Currency converter
@@ -480,6 +483,8 @@ currencies, at the same rates the rest of the app uses. Type into either side
and the other follows; **⇄** reverses the pair, carrying the converted amount
back as the new input.
+
+
It is deliberately separate from the **Show** setting in Settings → Pricing.
That one restates the whole calculation in another currency; this is a scratch
pad, and leaves the calculation alone. Every rate is quoted per rupee, so a
@@ -794,7 +799,7 @@ Every number here is reproducible from the repo — none is hand-written.
| Metric | Value | Reproduce with |
|---|---|---|
-| Tests | 1543 passing, 7 suites | `npm test` |
+| Tests | 1549 passing, 7 suites | `npm test` |
| Statement coverage | **82.7%** (app.js 86.3%, app-extra.js 72.3%) | `npm run coverage` |
| Lighthouse Performance | **97** | `npm i -D lighthouse && npm run lighthouse` |
| Lighthouse Accessibility | **100** | ” |
@@ -831,7 +836,7 @@ commands after significant changes.
## Tests
-1543 assertions across seven suites. They load the real `index.html`,
+1549 assertions across seven suites. They load the real `index.html`,
`assets/styles.css` and both script bundles, and drive the actual application
functions — no application code is mocked. **Node 22 or newer.**
@@ -842,7 +847,7 @@ npm test
| Suite | Assertions | Covers |
|---|---|---|
-| `features` | 1087 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history |
+| `features` | 1093 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history |
| `errors` | 33 | every failure path logs; a clean run stays silent; storage and payload recovery |
| `mobile` | 78 | modal layering, touch targets, sticky result bar, responsive quote layouts |
| `fab` | 50 | floating action button behaviour and z-index ordering |
diff --git a/assets/app.js b/assets/app.js
index 56dd68b..b05eabd 100644
--- a/assets/app.js
+++ b/assets/app.js
@@ -1406,8 +1406,24 @@ function openConvert(){
o.classList.add('open');
document.body.style.overflow='hidden';
pushOverlay(o);
- var use=el('cv-use');
- if(use)use.style.display=(LAST_CP&&LAST_SP)?'':'none';
+ /* "Use this calculation" used to disappear when there was nothing to pull in.
+ From the outside that reads as a broken feature rather than an unavailable
+ one — the README describes a button that simply is not there. It stays put
+ and says why, the same way the exchange-rate override does. */
+ var use=el('cv-use'),have=!!(LAST_CP&&LAST_SP);
+ if(use){
+ use.style.display='';
+ use.disabled=!have;
+ use.title=have?'':'Enter MRP, cost and selling price on the calculator first';
+ }
+ var gpEl=el('cv-gp'),mkEl=el('cv-mk'),out=el('cv-out');
+ if(out&&gpEl&&mkEl&&gpEl.value===''&&mkEl.value===''){
+ out.textContent=have
+ ? 'Type a percentage into either box — or pull in the calculation on screen.'
+ : 'Type a percentage into either box. Once MRP, cost and selling price are '+
+ 'filled in on the calculator, you can pull that calculation straight in.';
+ out.className='cv-out';
+ }
setTimeout(function(){ var f=el('cv-gp'); if(f){f.focus();if(f.select)f.select()} },30);
}
/** Close it. */
diff --git a/docs/screenshot-currency.png b/docs/screenshot-currency.png
new file mode 100644
index 0000000..3f13060
Binary files /dev/null and b/docs/screenshot-currency.png differ
diff --git a/docs/screenshot-tools.png b/docs/screenshot-tools.png
new file mode 100644
index 0000000..760ea41
Binary files /dev/null and b/docs/screenshot-tools.png differ
diff --git a/tests/README.md b/tests/README.md
index d2ccdb6..b883b2f 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,6 +1,6 @@
# Tests
-1543 assertions across seven suites. They load the real `index.html`,
+1549 assertions across seven suites. They load the real `index.html`,
`assets/styles.css` and `assets/app.js` into
[jsdom](https://github.com/jsdom/jsdom) and drive the actual application
functions — no application code is mocked.
@@ -34,7 +34,7 @@ The runner exits non-zero if anything fails, so CI catches it.
| File | Assertions | Covers |
|---|---|---|
-| `features.test.js` | 1087 | GST (presets, custom, decimal), incentive edit mode, add/delete/rename, %/₹ modes, quantity and order totals, rounding, undo/redo of typed values and every control, quote maths, history search/filter/tags, share-state round trips |
+| `features.test.js` | 1093 | GST (presets, custom, decimal), incentive edit mode, add/delete/rename, %/₹ modes, quantity and order totals, rounding, undo/redo of typed values and every control, quote maths, history search/filter/tags, share-state round trips |
| `errors.test.js` | 33 | every failure path logs; a clean run logs nothing; storage-quota and corrupt-payload recovery; global handlers |
| `mobile.test.js` | 78 | modal layering vs the bottom nav, touch-target sizes, viewport zoom policy, type scale, sticky result bar states, quote table vs card layouts |
| `fab.test.js` | 50 | FAB visibility rules, open/close and dismissal, ARIA state, deferred dispatch, error containment, z-index ordering |
@@ -157,7 +157,7 @@ test disagrees with the app, check the formula before changing the code.
npm run screenshots
```
-The two images the README embeds are generated, not captured by hand. They had
+The four images the README embeds are generated, not captured by hand. They had
drifted twice — once when labels were renamed, once when a header button was
added — and nothing tied them to the app. `screenshots.js` drives the real page
through the same worked example the README's own table walks through, so the
diff --git a/tests/features.test.js b/tests/features.test.js
index 3568e8b..8c0b520 100644
--- a/tests/features.test.js
+++ b/tests/features.test.js
@@ -2797,10 +2797,36 @@ ok("and the markup matches the app's Markup %",
cvMk.value + ' vs ' + d.getElementById('s-mg').textContent);
w.closeConvert();
ok('closing hands the focus trap back', w._openOverlay === null);
+// With nothing to pull in, the button used to disappear. From the outside that
+// reads as a broken feature rather than an unavailable one — the README
+// describes a button that simply is not there.
w.resetAll();
+d.getElementById('cv-gp').value = ''; d.getElementById('cv-mk').value = '';
w.openConvert();
-ok('with nothing calculated the offer is hidden',
- d.getElementById('cv-use').style.display === 'none');
+ok('with nothing calculated the offer stays put',
+ d.getElementById('cv-use').style.display !== 'none',
+ d.getElementById('cv-use').style.display);
+ok('but cannot be pressed', d.getElementById('cv-use').disabled === true);
+ok('and says what is missing',
+ /MRP, cost and selling price/.test(d.getElementById('cv-use').title),
+ d.getElementById('cv-use').title);
+ok('with the same reason on screen, not only in a tooltip',
+ /MRP, cost and selling price/.test(d.getElementById('cv-out').textContent),
+ d.getElementById('cv-out').textContent);
+w.closeConvert();
+
+// And it comes back the moment there is something to offer
+freshCalc(1000, 40, 25);
+d.getElementById('cv-gp').value = ''; d.getElementById('cv-mk').value = '';
+w.openConvert();
+ok('a calculation re-enables it', d.getElementById('cv-use').disabled === false);
+ok('and the empty state invites either route',
+ /pull in the calculation/.test(d.getElementById('cv-out').textContent),
+ d.getElementById('cv-out').textContent);
+// Through the delegated handler, the way a click reaches it
+w.ACT.convertUseCurrent();
+ok('pressing it still seeds both boxes', cvGp.value === '20' && cvMk.value === '25',
+ cvGp.value + ' / ' + cvMk.value);
w.closeConvert();
ok('it is reachable from the Tools menu',
diff --git a/tests/screenshots.js b/tests/screenshots.js
index 6b0e407..079696c 100644
--- a/tests/screenshots.js
+++ b/tests/screenshots.js
@@ -101,6 +101,53 @@ const SHOTS = [
{ file: 'screenshot-mobile.png', width: 390, height: 900, fullPage: false },
];
+/**
+ * Two pictures for the Tools section: the menu open, and the currency converter.
+ * Separately, not composed — the converter is a modal with a blurred backdrop,
+ * so a menu shown behind it photographs as a smear.
+ */
+async function toolsShots(browser, origin) {
+ const page = await browser.newPage({
+ viewport: { width: 1100, height: 560 }, deviceScaleFactor: 2,
+ });
+ await page.addInitScript(() => { try { localStorage.setItem('ob-done', '1') } catch (e) {} });
+ await page.goto(origin + '/', { waitUntil: 'load' });
+ await page.waitForFunction(() => typeof window.calc === 'function');
+ await page.emulateMedia({ reducedMotion: 'reduce' });
+ await page.evaluate(workedExample);
+ await page.waitForTimeout(600);
+ await page.evaluate(tidyUp);
+
+ await page.evaluate(() => window.openTools());
+ await page.waitForTimeout(300);
+ await page.screenshot({ path: path.join(OUT, 'screenshot-tools.png'),
+ clip: { x: 340, y: 0, width: 760, height: 300 } });
+ console.log(' wrote docs/screenshot-tools.png');
+ await page.evaluate(() => window.closeTools());
+
+ // Fixed rates, so the picture does not change with the day's market
+ await page.evaluate(() => {
+ window.FX.rates = { INR: 1, USD: 0.012, EUR: 0.011, GBP: 0.0094 };
+ window.FX.fetched = window.nowMs();
+ });
+ await page.waitForFunction(() => typeof window._renderCcyConvImpl === 'function',
+ null, { timeout: 8000 });
+ await page.evaluate(() => {
+ window.openCcyConv();
+ document.getElementById('cc-from-amt').value = '250';
+ window.renderCcyConv('from');
+ });
+ // openCcyConv focuses and selects the first field on a 30ms timer, so the
+ // blur has to come after that or the figure photographs highlighted.
+ await page.waitForTimeout(400);
+ await page.evaluate(() => document.getElementById('cc-from-amt').blur());
+ await page.waitForTimeout(200);
+ await page.locator('#overlay-ccyconv .modal').screenshot({
+ path: path.join(OUT, 'screenshot-currency.png') });
+ console.log(' wrote docs/screenshot-currency.png');
+ await page.close();
+}
+
(async () => {
let chromium;
try { ({ chromium } = require('playwright')); }
@@ -130,6 +177,8 @@ const SHOTS = [
await page.close();
}
+ await toolsShots(browser, origin);
+
await browser.close();
await new Promise(r => server.close(r));
})();