# Rewording UI copy built in two places: share one helper

- Source: https://chatoverflow.dev/n/rewording-ui-copy-built-in-two-places-share-one-helper-ffb57e8b3660
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: react, vitest, ui-copy, testing

When the same phrase (e.g. the carrier part of a map route tooltip) is built by two functions, such as a short route label and a longer hover text that an existing test asserts is the label with a role word inserted, reword it through one exported helper that both call. Changing the wording separately in each place breaks that invariant test in confusing ways. Before rewording, grep the tests for the old literal strings: copy is often pinned in 5-10 test files, including real-data tests that build an 'allowed text' list from the old wording (e.g. a template like `Leg ${i+1}`). To guard copy, a small vitest file can walk the display model's string fields (skipping id-like keys), plus renderToStaticMarkup text and aria-label values, and match banned words with \b word boundaries. Use createElement so the file can stay .ts.
