Skip to content

feat(cdk/tree): add tests for the new cdk/tree APIs #24500

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

Conversation

BobobUnicorn
Copy link
Collaborator

@BobobUnicorn BobobUnicorn commented Mar 1, 2022

Followed by #25729.

@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch 2 times, most recently from 660fd06 to 20086c9 Compare March 1, 2022 23:08
@BobobUnicorn BobobUnicorn changed the base branch from master to cdk-tree-revamp March 1, 2022 23:10
@andrewseguin andrewseguin self-assigned this Apr 21, 2022
@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch from 20086c9 to 5316c3c Compare April 28, 2022 15:08
@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch 2 times, most recently from db63ba5 to b027a6a Compare May 17, 2022 19:58
@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch from b027a6a to 7f79601 Compare September 29, 2022 19:57
@BobobUnicorn BobobUnicorn marked this pull request as ready for review September 29, 2022 20:15
@BobobUnicorn
Copy link
Collaborator Author

@andrewseguin this is a straight migration of the existing tests just using the non-deprecated APIs

@@ -450,7 +450,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
} else if (this._expansionModel) {
const expansionModel = this._expansionModel;
this._getAllDescendants()
.pipe(take(1), takeUntil(this._onDestroy))
.pipe(takeUntil(this._onDestroy))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a strange change - wouldn't this only want to take one look at the descendants? Would this emit multiple times over the course of the component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_getAllDecendants emits multiple times, but does only call getDescendants once per node

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here (above this._getAllDescendants()) that explains what's happening here?

My mental model here is that _getAllDescendants is an observable because descendants may change over time, but the expandAll and collapseAll operations happen at a single point in time. My expectation would be that you would still want take(1) here with _getAllDescendants not emitting until it has accumulated all nodes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a text blurb above the _getAllDescendants function instead, does that clarify things?

@@ -450,7 +450,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
} else if (this._expansionModel) {
const expansionModel = this._expansionModel;
this._getAllDescendants()
.pipe(take(1), takeUntil(this._onDestroy))
.pipe(takeUntil(this._onDestroy))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here (above this._getAllDescendants()) that explains what's happening here?

My mental model here is that _getAllDescendants is an observable because descendants may change over time, but the expandAll and collapseAll operations happen at a single point in time. My expectation would be that you would still want take(1) here with _getAllDescendants not emitting until it has accumulated all nodes.

@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch from 0ec5a71 to 29e3bb8 Compare February 16, 2023 18:48
@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch from 29e3bb8 to 0ff7739 Compare February 17, 2023 21:52
@andrewseguin andrewseguin force-pushed the cdk-tree-revamp branch 2 times, most recently from 565eb38 to fbe321d Compare April 4, 2023 21:45
@BobobUnicorn BobobUnicorn force-pushed the cdk-tree-redesign-expansion-tests branch from 26182bf to 148aa0d Compare April 5, 2023 18:26
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Apr 5, 2023
@andrewseguin
Copy link
Contributor

Run yarn bazel run //tools/public_api_guard:cdk/tree.md_api.accept to update the goldens

@andrewseguin andrewseguin merged commit b9a9e62 into angular:cdk-tree-revamp Apr 6, 2023
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
detected: feature PR contains a feature commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants