rest.test.jsrest.js), verifying the correctness of the base URL constant, query parameter serialization, and service URL assembly. Uses Jest's global it/describe/expect API. This test file ensures that URL routing changes (such as the REST endpoint prefix migration from /rest to /rs) do not silently break the URL construction logic that dozens of API-calling components depend on.The file tests three exported functions from rest.js:
baseURL — a single assertion that the constant equals the expected string. This acts as a canary: if the base URL ever changes unexpectedly, this test catches it.
createQueryParams — a described block with four cases: empty params (returns empty string), a single key-value pair, multiple key-value pairs joined with &, and params containing special characters that must be URI-encoded (e.g., German umlauts in Schwarzwälder Kirschtorte).
getServiceURL — a described block with three cases: undefined params (just appends path to base), empty params (same), and params present (full URL with query string). Tests the assembly of the complete REST endpoint URL from a service path and optional parameters.
This test file played a critical role during the API prefix migration. When the base URL changed from /rest to /rs, the test expectations served as the specification: all assertions were updated first to reflect the new expected values, then the implementation in rest.js was changed until tests passed. Later, the Vite migration moved the proxy handling to the build tool level, which made the baseURL testable as an empty string rather than /rs.
| Commit | What changed |
|---|---|
bf988bc6d | Changed the baseURL expected value from '/rs' to '' (empty string). This accompanied the react-scripts→Vite migration: the Vite dev server handles proxy forwarding of /rs and /rest paths to the backend, so the React app's base URL constant no longer needs the prefix since the proxy layer handles it transparently. |
f744162e7 | Updated all test expectations from '/rest' to '/rs' throughout the file — four occurrences in getServiceURL test cases and one in baseURL. This reflected the backend REST endpoint consolidation where the old /rest prefix was replaced with /rs for consistency with the Wicket page mounting scheme. |
7ea575588 | Created the test file with the initial test suite using '/rest' as the base service prefix. Established the pattern of testing empty params, single params, multi params, and URI-encoded special characters. The playful test data (cakes, flavor, Schwarzwälder Kirschtorte) originates here. |