Skip to content

Commit 1ef503e

Browse files
dgp1130atscott
authored andcommitted
test(http): disable XSRF and mock location in HttpClient tests to avoid Domino failures and state leakage
The `HttpClient` tests in `client_spec.ts` were failing intermittently in Node/Domino environment because `MockPlatformLocation` defaults to `http://_empty_/`. This valid URL satisfied the URL parser in `xsrfInterceptorFn`, causing it to proceed to cookie extraction which throws `NotYetImplemented` in Domino. To fix this: 1. Disabled XSRF protection in `client_spec.ts` using `withNoXsrfProtection()`, as these tests are not for XSRF. 2. Provided `ɵprovideFakePlatformNavigation` to remove state leakage effects and ensure consistency.
1 parent d95e856 commit 1ef503e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/common/http/test/client_spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import {HttpClient} from '../src/client';
1010
import {HttpErrorResponse, HttpEventType, HttpResponse, HttpStatusCode} from '../src/response';
1111
import {HttpTestingController, provideHttpClientTesting} from '../testing';
12-
import {provideHttpClient} from '../src/provider';
12+
import {provideHttpClient, withNoXsrfProtection} from '../src/provider';
13+
import {ɵprovideFakePlatformNavigation} from '@angular/common/testing';
1314
import {TestBed} from '@angular/core/testing';
1415
import {toArray} from 'rxjs/operators';
1516

@@ -18,7 +19,11 @@ describe('HttpClient', () => {
1819
let backend: HttpTestingController;
1920
beforeEach(() => {
2021
TestBed.configureTestingModule({
21-
providers: [provideHttpClient(), provideHttpClientTesting()],
22+
providers: [
23+
provideHttpClient(withNoXsrfProtection()),
24+
provideHttpClientTesting(),
25+
ɵprovideFakePlatformNavigation(),
26+
],
2227
});
2328
client = TestBed.inject(HttpClient);
2429
backend = TestBed.inject(HttpTestingController);

0 commit comments

Comments
 (0)