-
Notifications
You must be signed in to change notification settings - Fork 17
Bring BaseViewProvider and ParentedBaseViewProvider event handling wiring and testing up to standards
#2263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring BaseViewProvider and ParentedBaseViewProvider event handling wiring and testing up to standards
#2263
Conversation
…entedBaseViewProvider from perspective of FlinkStatementsViewProvider.
BaseViewProvider and ParentedBaseViewProvider event handling wiring up to standardsBaseViewProvider and ParentedBaseViewProvider event handling wiring and testing up to standards
This comment has been minimized.
This comment has been minimized.
…BaseViewProvider-event-handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR standardizes event handling wiring and testing for BaseViewProvider and ParentedBaseViewProvider classes to follow established patterns. The main purpose is to ensure that only explicit named methods are used as event handlers, improving code maintainability and testability.
Key changes:
- Made
ParentedBaseViewProvider.parentResourceChangedEmitterrequired instead of optional to simplify event wiring logic - Refactored event handler registration to use explicit method binding with
.bind(this)instead of inline arrow functions - Updated test suites to verify complete event listener behavior across the inheritance hierarchy
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/viewProviders/base.ts |
Made parentResourceChangedEmitter required, refactored event handlers to use explicit method binding, renamed handleCCloudConnectionChange to ccloudConnectedHandler |
src/viewProviders/base.test.ts |
Updated tests to use new handler method name and removed outdated search emitter tests |
src/viewProviders/flinkStatements.test.ts |
Updated test descriptions and coverage to include all event handlers from inheritance hierarchy |
src/viewProviders/newResources.test.ts |
Updated test descriptions to clarify event listener testing scope |
Comments suppressed due to low confidence (1)
src/viewProviders/base.test.ts:351
- The test description still references the old method name
handleCCloudConnectionChange()but the method was renamed toccloudConnectedHandler. Update the test description to match the new method name.
it("handleCCloudConnectionChange() should call reset() when the `ccloudConnected` event fires and a CCloud resource is focused", () => {
noeldevelops
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the clarifying code comments!
Summary of Changes
ParentedBaseViewProvider.parentResourceChangedEmitterrequired to be assigned in any concrete subclass. Simplifies itssetEventListeners()implementation. The whole point ofParentedBaseViewProvideris that it has a "parent" resource, and our design pattern is that changing that parent resource is indirectly done through an event emitter. Both of the existing subclasses (FlinkStatementsViewProvider,FlinkArtifactsViewProvider) and upcoming FlinkUDFViewProvider will conform, so make things a little simpler. If a new subclass were created that violated this rule,setEventListeners()will fail at extension startup with trying to reference.event()off ofundefined.BaseViewProviderandParentedBaseViewProvideras is our new standard. InBaseViewProvider's case, the wiring is made a little more complicated due to needing to do so conditionally based on if the concrete subclass has the search change event assigned.setEventListers()behavior acrossBaseViewProviderandParentedBaseViewProviderfrom perspective ofFlinkStatementsViewProvider, which passes the has-search-term-changed-event-emitter condition condition inBaseViewController.setEventListers()behavior acrossBaseViewProviderandParentedBaseViewProviderfrom perspectives ofNewResourceViewController, which goes into the else block of the has-search-term-changed-event-emitter condition condition inBaseViewController(at this time. Search will be implemented Soon).Any additional details or context that should be provided?
Pull request checklist
Please check if your PR fulfills the following (if applicable):
Tests
Other
.vsixfile?