Skip to content

Commit 3dfc855

Browse files
erkamyamanalxhub
authored andcommitted
test(devtools): run the orphaned supported-apis spec
`supported-apis.spec.ts` was added in #60585, in a commit that also edited the `ts_test_library` three lines below the `srcs` it was left out of. No revision of that BUILD file has ever listed it, so it has not run since March 2025. The target goes from 12 specs to 14. Wiring it up alone would not have worked. Every `*IsSupported` helper calls `ngDebugClient()`, which throws when `window.ng` is undefined, and the old `expect(supported).toBeTruthy()` set no `ng` at all. It now stubs `ng` and checks the flag set and that each flag tracks its own debug API. `ng-debug-api.spec.ts` adds an `[ng-version]` root and did not remove it, which `getAppRoots()` then picks up in the other file under jasmine's random ordering, so it now clears the DOM in its own `afterEach`. `glob` matches the sibling `directive-forest/component-tree` target and keeps the next spec in this directory from being dropped the same way.
1 parent 3481b15 commit 3dfc855

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

devtools/projects/ng-devtools-backend/src/lib/shared/ng-debug-api/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ng_project(
1919

2020
ts_test_library(
2121
name = "ng-debug-api_test_lib",
22-
srcs = ["ng-debug-api.spec.ts"],
22+
srcs = glob(["*.spec.ts"]),
2323
deps = [
2424
":ng-debug-api",
2525
"//:node_modules/@angular/core",

devtools/projects/ng-devtools-backend/src/lib/shared/ng-debug-api/ng-debug-api.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const fakeNgGlobal = (framework: Framework): Partial<Ng> => {
6161
describe('ng-debug-api', () => {
6262
afterEach(() => {
6363
delete (globalThis as any).ng;
64+
document.body.replaceChildren();
6465
});
6566

6667
describe('ngDebugDependencyInjectionApiIsSupported', () => {

devtools/projects/ng-devtools-backend/src/lib/shared/ng-debug-api/supported-apis.spec.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,38 @@
99
import {getSupportedApis} from './supported-apis';
1010

1111
describe('supported-apis', () => {
12+
afterEach(() => {
13+
delete (globalThis as any).ng;
14+
});
15+
1216
describe('getSupportedApis', () => {
13-
it('should return supported APIs', () => {
17+
it('should return every flag as false when no debug API is available', () => {
18+
(globalThis as any).ng = {};
19+
20+
const supported = getSupportedApis();
21+
22+
expect(Object.keys(supported).sort()).toEqual([
23+
'dependencyInjection',
24+
'profiler',
25+
'routes',
26+
'signalPropertiesInspection',
27+
'signals',
28+
'transferState',
29+
]);
30+
expect(Object.values(supported).every((value) => value === false)).toBeTrue();
31+
});
32+
33+
it('should only report signals when the signal graph API is available', () => {
34+
(globalThis as any).ng = {ɵgetSignalGraph: () => {}};
35+
1436
const supported = getSupportedApis();
1537

16-
expect(supported).toBeTruthy();
38+
expect(supported.signals).toBeTrue();
39+
expect(supported.dependencyInjection).toBeFalse();
40+
expect(supported.profiler).toBeFalse();
41+
expect(supported.routes).toBeFalse();
42+
expect(supported.signalPropertiesInspection).toBeFalse();
43+
expect(supported.transferState).toBeFalse();
1744
});
1845
});
1946
});

0 commit comments

Comments
 (0)