Angular: Remove usage of ComponentFactoryResolver#34535
Conversation
|
View your CI Pipeline Execution ↗ for commit b058e01
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit b058e01 ☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughRemoval of Angular components and Storybook stories from the "component-with-complex-selectors" directory that relied on Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts (1)
50-212:⚠️ Potential issue | 🟠 MajorRe-enable positive-path
getComponentInputsOutputstests instead of block-commenting them.This removes most behavioral coverage for
getComponentInputsOutputsand leaves only the empty-path assertion. Please keep these tests active and decouple them from factory-based assertions (assert explicit expectedinputs/outputsonly).Suggested direction
- /* Commented out until we figure out how to handle the removal of ComponentFactoryResolver in Angular 22 - ... - */ + it('should return I/O', () => { + // keep component setup + const { inputs, outputs } = getComponentInputsOutputs(FooComponent); + expect({ inputs, outputs }).toEqual({ + inputs: [ + { propName: 'inputInComponentMetadata', templateName: 'inputInComponentMetadata' }, + { propName: 'input', templateName: 'input' }, + { propName: 'inputWithBindingPropertyName', templateName: 'inputPropertyName' }, + ], + outputs: [ + { propName: 'outputInComponentMetadata', templateName: 'outputInComponentMetadata' }, + { propName: 'output', templateName: 'output' }, + { propName: 'outputWithBindingPropertyName', templateName: 'outputPropertyName' }, + ], + }); + }); + // Apply the same pattern to the other currently-commented cases in this block.Based on learnings, “Export functions that need direct tests and test real behavior, not just syntax patterns.”
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts` around lines 50 - 212, The tests for getComponentInputsOutputs were commented out, removing behavioral coverage; re-enable the positive-path tests but remove reliance on resolveComponentFactory (decouple from Angular factory internals) by asserting explicit expected inputs/outputs returned from getComponentInputsOutputs for the various component classes in the file (NgComponentAnalyzer.test.ts); keep tests that define FooComponent/BarComponent variants and call getComponentInputsOutputs(FooComponent) and assert the exact inputs/outputs objects (including alias/templateName cases, multiple decorators, and inheritance) rather than comparing to fooComponentFactory inputs/outputs, so tests exercise getComponentInputsOutputs directly.
🧹 Nitpick comments (1)
code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts (1)
378-387: Delete the commented-outresolveComponentFactoryhelper to avoid dead-code drift.If this helper is intentionally deferred, track it in an issue/PR note rather than leaving a commented implementation in the test file.
Cleanup diff
-/* -function resolveComponentFactory<T extends Type<any>>(component: T) { - TestBed.configureTestingModule({ - declarations: [component], - }).overrideModule(BrowserDynamicTestingModule, {}); - const componentFactoryResolver = TestBed.inject(ComponentFactoryResolver); - - return componentFactoryResolver.resolveComponentFactory(component); -} -*/🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts` around lines 378 - 387, Remove the commented-out helper resolveComponentFactory and its block to eliminate dead-code drift; locate the commented function named resolveComponentFactory (which references TestBed, BrowserDynamicTestingModule, and ComponentFactoryResolver) in NgComponentAnalyzer.test.ts and delete the entire commented implementation, or if it's intentionally deferred add a note pointing to an issue/PR instead of leaving the commented code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts`:
- Around line 50-212: The tests for getComponentInputsOutputs were commented
out, removing behavioral coverage; re-enable the positive-path tests but remove
reliance on resolveComponentFactory (decouple from Angular factory internals) by
asserting explicit expected inputs/outputs returned from
getComponentInputsOutputs for the various component classes in the file
(NgComponentAnalyzer.test.ts); keep tests that define FooComponent/BarComponent
variants and call getComponentInputsOutputs(FooComponent) and assert the exact
inputs/outputs objects (including alias/templateName cases, multiple decorators,
and inheritance) rather than comparing to fooComponentFactory inputs/outputs, so
tests exercise getComponentInputsOutputs directly.
---
Nitpick comments:
In
`@code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts`:
- Around line 378-387: Remove the commented-out helper resolveComponentFactory
and its block to eliminate dead-code drift; locate the commented function named
resolveComponentFactory (which references TestBed, BrowserDynamicTestingModule,
and ComponentFactoryResolver) in NgComponentAnalyzer.test.ts and delete the
entire commented implementation, or if it's intentionally deferred add a note
pointing to an issue/PR instead of leaving the commented code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d2ec3195-928d-4588-a669-ac05e1270e5a
📒 Files selected for processing (8)
code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selector.component.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/class-selector.component.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.tscode/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts
💤 Files with no reviewable changes (7)
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/class-selector.component.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts
- code/frameworks/angular/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts
What I did
The release of Angular 22.0.0-next.7 removed the exports of
ComponentFactoryResolverandComponentFactory. We relied on these in a few unit tests and stories, that I've now removed. We should try to add them in later in a way that doesn't depend on the removed APIs.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
See the Angular prerelease sandboxes not failing.
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
Tests
Chores