Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pricing Calculator

[![Tests](https://github.com/sterlingspares/calc/actions/workflows/tests.yml/badge.svg)](https://github.com/sterlingspares/calc/actions/workflows/tests.yml) ![Tests](https://img.shields.io/badge/tests-1380%20passing-brightgreen?style=flat-square) ![Coverage](https://img.shields.io/badge/coverage-80%25-green?style=flat-square) ![Lighthouse Performance](https://img.shields.io/badge/Lighthouse%20Perf-98-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Accessibility](https://img.shields.io/badge/Lighthouse%20A11y-100-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Best Practices](https://img.shields.io/badge/Best%20Practices-100-brightgreen?style=flat-square&logo=lighthouse) ![a11y](https://img.shields.io/badge/WCAG%202.1-AA-brightgreen?style=flat-square) ![PWA](https://img.shields.io/badge/PWA-offline--ready-brightgreen?style=flat-square&logo=pwa) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
[![Tests](https://github.com/sterlingspares/calc/actions/workflows/tests.yml/badge.svg)](https://github.com/sterlingspares/calc/actions/workflows/tests.yml) ![Tests](https://img.shields.io/badge/tests-1406%20passing-brightgreen?style=flat-square) ![Coverage](https://img.shields.io/badge/coverage-80%25-green?style=flat-square) ![Lighthouse Performance](https://img.shields.io/badge/Lighthouse%20Perf-97-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Accessibility](https://img.shields.io/badge/Lighthouse%20A11y-100-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Best Practices](https://img.shields.io/badge/Best%20Practices-100-brightgreen?style=flat-square&logo=lighthouse) ![a11y](https://img.shields.io/badge/WCAG%202.1-AA-brightgreen?style=flat-square) ![PWA](https://img.shields.io/badge/PWA-offline--ready-brightgreen?style=flat-square&logo=pwa) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)

**Live app:** [calc.sterlingspares.com](https://calc.sterlingspares.com)

Expand Down Expand Up @@ -138,14 +138,15 @@ Opening `index.html` from disk works too — the app runs, but the browser block
index.html markup only
assets/styles.css all styling
assets/app.js core behaviour
assets/app-extra.js what-if, compare, quote, onboarding — loaded on demand
assets/app-extra.js what-if, compare, quote, CSV export — on demand
assets/fonts.css self-hosted @font-face rules
assets/fonts/ three woff2 files
sw.js service worker
manifest.json PWA manifest
_headers response headers for the host
tests/ test suite (dev-only)
docs/ screenshots for this README
robots.txt · sitemap.xml indexing
```

---
Expand Down Expand Up @@ -528,6 +529,14 @@ a phone — rather than one long scroll:
Arrow keys, Home and End move between tabs, and a tab whose sections are all
switched off hides rather than leading nowhere.

### First run

A six-step tour opens on a first visit, written for someone who arrived without
reading any of this. It starts with the problem rather than the features, offers
to **fill the example in** so the screen is working rather than empty, warns that
GP % and Margin % are not the same figure, and says plainly that the tax rate and
the currency are yours to set. Restart it any time from Settings → Help.

| Setting | Description |
|---|---|
| **Dark mode** | Full dark colour scheme |
Expand All @@ -538,7 +547,7 @@ switched off hides rather than leading nowhere.
| **Features** | Switch off anything you do not use |
| **Saved presets** | Open the preset manager |
| **Exchange rates** | Update now, and set a manual rate |
| **App tour** | Restart the onboarding walkthrough |
| **App tour** | Restart the six-step tour |
| **Keyboard shortcuts** | View all shortcuts |
| **Reset everything** | Clear every saved key and start as if the app were new |

Expand Down Expand Up @@ -734,23 +743,32 @@ Every number here is reproducible from the repo — none is hand-written.

| Metric | Value | Reproduce with |
|---|---|---|
| Tests | 1380 passing, 7 suites | `npm test` |
| Statement coverage | **82.6%** (app.js 86.3%, app-extra.js 68.5%) | `npm run coverage` |
| Lighthouse Performance | **98** | `npm i -D lighthouse && npm run lighthouse` |
| Tests | 1406 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** | ” |
| Lighthouse Best Practices | **100** | ” |
| Lighthouse SEO | 60 | ” |
| Lighthouse SEO | **100** | ” |

Lighthouse runs against a local server that gzips and sets the same cache headers
as `_headers`, on emulated mobile with throttling — so the scores reflect a
realistic deployment rather than an unconfigured static host. Measured: FCP 1.5s,
LCP 2.1s, CLS 0. Total Blocking Time is noisy on a shared machine — 0ms on three
runs of four, 30ms on the other.
LCP 2.5s, TBT 0–10ms, CLS 0. Take a single Total Blocking Time reading with salt
— it is noisy on a shared machine, and one run in five here reported 740ms
against a median of 0.

The main-thread cost is Style & Layout at ~325ms, not scripting (70ms eval, 32ms
parse) — a 1,043-node document against 809 CSS rules, thirteen of which use
`:has()`. That is what showing a keyboard-only focus ring on wrapper elements
costs, and it buys more than it costs.

Two audits score zero by choice. `unminified-javascript` (~39KB) is the
no-build-step trade: what is in the repo is what the browser runs.
`unused-javascript` (~88KB) is mostly the deferred bundle, warmed during idle so
the quote builder and what-if open instantly — paid for after load, not before.

**On the SEO score:** it is capped entirely by
`<meta name="robots" content="noindex, nofollow">`. `is-crawlable` is the only
failing audit, and it fails by design — this is an internal tool that should not
be indexed. Removing the meta tag would score 100 and is not wanted.
The app is indexable, with a `robots.txt`, a sitemap, and share-card metadata
that says what the tool does rather than who built it.

Coverage is measured by mapping V8 coverage back to each bundle. The app runs
inside jsdom as an inline script, so c8 and nyc attribute everything to the
Expand All @@ -762,7 +780,7 @@ commands after significant changes.

## Tests

1380 assertions across seven suites. They load the real `index.html`,
1406 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.**

Expand All @@ -773,7 +791,7 @@ npm test

| Suite | Assertions | Covers |
|---|---|---|
| `features` | 953 | GST, incentives, quantity, landed costs, rounding, undo/redo, quote maths, history |
| `features` | 979 | GST, incentives, quantity, landed costs, rounding, undo/redo, 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 |
Expand Down
Loading
Loading