Skip to content

test: hold unit-test HTTP in the testing backend - #5899

Merged
norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:fix/test-http-backend
Sep 9, 2026
Merged

test: hold unit-test HTTP in the testing backend#5899
norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:fix/test-http-backend

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

Every make check gate run has been printing around two hundred happy-dom stack traces of the form DOMException [AbortError]: The operation was aborted at the head of the vitest output, with no file attributed. A sequential verbose run attributes them to 56 spec files, and hooking happy-dom's Fetch.sendRequest shows what they are: real requests, one per test — GET /assets/company-config.json from the branding service and friends — aborted when the window is torn down after each file.

The cause is the test platform. The workspace setup initialises the TestBed platform once for all eight projects, and its module provides only zoneless change detection. Core's own setup does pair provideHttpClient() with provideHttpClientTesting(), but it never runs, because the platform already exists. Angular hands every injector a root HttpClient on the fetch backend even when nothing provides one, so a spec that never mentions HttpClient still reaches the network.

Closing the class rather than the symptom:

  • The workspace platform module now provides provideHttpClient() and provideHttpClientTesting(), so requests are held in the testing backend unless a spec overrides it.
  • The specs that provided their own real client pair it with the testing backend, as CF_BASE_TEST_PROVIDERS now does — 79 with a bare provideHttpClient(), four importing HttpClientModule, and six that mixed a deprecated HttpClientTestingModule import with a real provideHttpClient() provider in the same TestBed, where the real backend won. One of those six (running instances) was still sending an app-stats request and was the last AbortError in the log.
  • The narrowed make test frontend PROJECT=... SCOPE=... run still passed --dangerouslyIgnoreUnhandledErrors, which fix: make the gate warning-free and stop ignoring unhandled test errors #5890 removed from the full run; it is gone here too, with its stale comment.

Two greps now come back empty and are the standing check: a spec with a real client and no testing backend, and a spec that mixes a deprecated HTTP module with a real provider.

Holding the requests exposed a spec that had been passing on a failed one. current-user-permissions-and-cfchecker.service.spec.ts drives the CF permission checkers, which read the connected endpoint list from EndpointsDataService. That service fetches /pp/v1/info; under the real backend the fetch failed, the endpoint list came back empty, and the "all endpoints" checks reduced over nothing — which reduceChecks answers true by default. The feature-flag assertions were never reached. The spec now answers /pp/v1/info and each endpoint's /pp/v1/cf/feature_flags/{cnsi} from the same fixtures the store module is built from, so the checks run over the two CF endpoints and their real flags. With real data the private-domain-creation check on the second endpoint is true, not false — that fixture enables the flag there — and a new case covers a flag that is disabled on its endpoint (diego_docker), so enabled, disabled and absent are each asserted.

make check gate green: 3745 passed, 2 skipped, zero AbortError lines.

Every gate run printed around two hundred happy-dom
`DOMException [AbortError]` traces with no file attributed. Hooking
happy-dom's fetch shows real requests, one per test, aborted when the
window is torn down: the branding service's company-config.json and
friends.

The cause is the test platform. The workspace setup initialises the
TestBed platform for all eight projects with a module that provides only
zoneless change detection; core's own setup does pair the http providers
but never runs, because the platform already exists. Angular hands every
injector a root HttpClient on the fetch backend even when nothing
provides one, so a spec that never mentions HttpClient still reaches the
network.

The platform module now provides the client and the testing backend, so
requests are held unless a spec overrides them. The specs that provided
their own real client pair it with the testing backend, as
CF_BASE_TEST_PROVIDERS now does; six that mixed the deprecated modules
with a real provider are converted, one of which (running instances) was
still sending an app-stats request. The narrowed `make test frontend`
run no longer passes the ignore-unhandled-errors flag that cloudfoundry#5890 removed
from the full run.

Holding the requests exposed a spec that had been passing on a failed
one: the CF permission checks read the endpoint list from
EndpointsDataService, whose /pp/v1/info fetch failed under the real
backend, so the "all endpoints" checks reduced over an empty list and
returned true by default. That spec now answers /pp/v1/info and each
endpoint's feature flags from the same fixtures the store module is
built from. With real data the private-domain-creation check on the
second endpoint is true, not false, since the fixture enables the flag
there; a new case covers a flag that is disabled on its endpoint.

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz
norman-abramovitz merged commit 9ac6962 into cloudfoundry:develop Sep 9, 2026
24 checks passed
@nabramovitz
nabramovitz deleted the fix/test-http-backend branch September 9, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants