test: enable child rendering in WorkspaceComponent spec#5037
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5037 +/- ##
============================================
- Coverage 43.05% 43.05% -0.01%
Complexity 2207 2207
============================================
Files 1045 1045
Lines 40216 40216
Branches 4243 4243
============================================
- Hits 17315 17314 -1
Misses 21832 21832
- Partials 1069 1070 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/request-review @mengw15 |
…ering' into test/workspaceComponentChildRendering
|
@mengw15 I addressed the comments please let me know if it looks good now. |
| // Before view init nothing has been assigned. (The pre-fixture stub on | ||
| // codeEditorViewRef in createFixture only protects ngOnDestroy teardown | ||
| // — the service.vc should still be untouched.) | ||
| expect(codeEditorService.vc).toBeUndefined(); |
There was a problem hiding this comment.
Minor: this assertion relies on CodeEditorService.vc being undefined at the start of the test, which depends on TestBed rebuilding the injector between specs. That's the current behavior, but if the service ever becomes a longer-lived singleton (or test isolation config changes), this will start failing in ways that are hard to reproduce.
Consider making the starting state explicit so the test doesn't carry an implicit ordering dependency:
codeEditorService.vc = undefined as any;
await createFixture();
fixture.detectChanges();
expect(codeEditorService.vc).toBe(component.codeEditorViewRef);
expect(typeof codeEditorService.vc.createEmbeddedView).toBe("function");Same outcome, no hidden DI assumption.
What changes were proposed in this PR?
Drops the
<div #codeEditor>template stub fromWorkspaceComponent's unit spec so the realworkspace.component.htmlrenders. Heavyweight children (workflow editor, panels, menu) are kept out of the test build by strippingthe component's
imports/providersand addingCUSTOM_ELEMENTS_SCHEMA, leaving the<ng-template #codeEditor>outlet free to wire a liveViewContainerRefintoCodeEditorService.vc. A newchild rendering side effectsdescribe block asserts that the editor-lifecycle wiring runs end-to-end (the published outlet is a realViewContainerRef, proven bycreateEmbeddedViewbeing a function on it).Any related issues, documentation, or discussions?
Closes: #5015
How was this PR tested?
yarn test --include="src/app/workspace/component/workspace.component.spec.ts" --watch=false: 20/20 pass (19 prior tests preserved, 1 new).yarn test --watch=false: full suite 445 passed, 2 skipped, 2 todo (no regressions).yarn format:fix: no rewrites.Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in compliance with ASF