da8cdc19 - Fix hardcoded services.dfx.swiss link in test mock - #1408
da8cdc19 - Fix hardcoded services.dfx.swiss link in test mock#1408Danswar wants to merge 1 commit into
Conversation
Fix the stale default `base` URL in a Jest mock of the `url` utility, used by open-crypto-pay tests. The user-facing frontend is app.dfx.swiss, not services.dfx.swiss.
|
EN: DE: |
TaprootFreakAI
left a comment
There was a problem hiding this comment.
EN:
Approve — one-line mock default fix; the red CodeQL check is a GitHub upload outage, not this diff.
DE:
Approve — Ein-Zeilen-Fix im Test-Mock; der rote CodeQL-Check ist ein GitHub-Upload-Ausfall, nicht dieser Diff.
TaprootFreakAI
left a comment
There was a problem hiding this comment.
EN:
Withdrawing the earlier approve — this PR still has a red or cancelled check.
DE:
Früheres Approve zurückgezogen — dieser PR hat noch einen roten oder abgebrochenen Check.
EN:
Part of DFXswiss/api#5021: replace hardcoded
services.dfx.swisslinks withapp.dfx.swissacross the frontend repos. A full-repo search of this repo found exactly one hardcoded occurrence; it is fixed here.DE:
Teil von DFXswiss/api#5021: hartcodierte
services.dfx.swiss-Links durchapp.dfx.swissersetzen. Eine vollständige Repo-Suche ergab genau einen Treffer; er ist hiermit behoben.Details
Search
Searched the full repository (all text files, excluding
node_modules/dist/build/.next) forservices.dfx.swiss,services-dev., anddev.services.(and case-insensitive variants). Exactly one hit:src/__tests__/open-crypto-pay.test.ts:18— a Jest mock of theurlutility used a stale defaultbasevalue of'https://services.dfx.swiss'.No other occurrences exist in this repo. All other matches for the substring
servicesare thedfx-servicesproduct/component name (the widget custom element, Docker image tags, thex-clientheader value) — not this domain, and out of scope for this issue.Fix
Changed the default value to
'https://app.dfx.swiss'.app.dfx.swiss(not thedev.variant) is correct here: this mock has no environment awareness (it exists "to avoid env dependency", per the comment above it), matching how other unit tests in this repo reference the prod placeholder domain;dev.app.dfx.swissonly appears in this repo's E2E specs and dev build scripts, where an actual environment target is meant.This default is exercised at runtime —
OpenCryptoPayUtils.getOcpUrlByUniqueIdbuilds the inner API URL with an explicitbase, but the outer LNURL-wrapping step (Lnurl.prependLnurl→url({ path: 'pl', params })) calls the same mockedurlwithout abase, so the changed default does land in the returned string on every test run. None of the assertions in the file's 5 tests pin that specific host value, so the change doesn't alter what the tests check — but the default is not dead code, and no test breaks either way.Coverage:
src/__tests__/open-crypto-pay.test.tsis a test file, not part of the code under test, so Jest doesn't produce statement/branch coverage for it — running--collectCoverageFromscoped to this file confirms Jest emits no coverage entries for it at all. There's no per-file number to report for a file this rule doesn't apply to.Out of scope
Per the issue,
Config.frontend.services/ theSERVICES_URLenv var (API-side) is a deploy/config concern, not duplicated here.DFXswiss/appdoes not exist as a repo, so it is not covered by this PR or by DFXswiss/packages (searched separately — no hardcoded occurrences found there, no PR needed).Local verification
CI=true npm test -- --watchAll=false --testPathPattern=open-crypto-pay— 5/5 passednpm run lint— cleannpm run build:dev— succeedednpm run widget:dev— succeedednpm run format:md:check— clean