-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material/tree): add getTreeStructure for tree harness #20568
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
83383b5
to
ecc6d38
Compare
Currently just using spaces to denote levels. Looking into other ascii representation. While more complicated ascii strings may be easier to read but may be hard for users to produce the correct string to assert on. |
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.
LGTM, marking as blocked until pre-req PR goes in
@@ -28,4 +28,17 @@ export class MatTreeHarness extends ComponentHarness { | |||
async getNodes(filter: TreeNodeHarnessFilters = {}): Promise<MatTreeNodeHarness[]> { | |||
return this.locatorForAll(MatTreeNodeHarness.with(filter))(); | |||
} | |||
|
|||
async getTreeStructure(): Promise<string> { |
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.
Is there any motivation for adding this function? Is it to simplify test assertions for a tree and it's state? I'm wondering if it would be better type-wise and assertion-wise to just return a nested array or object instead.
94bd52f
to
408ad7f
Compare
Changed to object representation of tree structure as asserting against a string can be finicky |
408ad7f
to
acb8466
Compare
0a1967b
to
5386107
Compare
*/ | ||
async getTreeStructure(): Promise<TreeNode> { | ||
const nodes = await this.getNodes(); | ||
const nodeInformation = await Promise.all(nodes.map(node => { |
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.
now that parallel
is available from @angular/cdk/testing
please use that over Promise.all
5386107
to
c2bb057
Compare
c2bb057
to
4684d5a
Compare
4684d5a
to
cdf3345
Compare
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.
LGTM, please update the API golds and commit message then apply merge ready
label
cdf3345
to
c1279bd
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Add a "pretty print" method for the tree harness.
The method is only available at the tree/root level because it is not possible to get children of flat nodes as they are siblings in the DOM.