Closed
Description
Note(@jelbourn): Copied from an internal bug report
HarnessPredicate.getSelector returns the wrong result in certain cases. E.g., MatButtonHarness and other CDK harnesses are defined as matching one of several possible selectors:
static hostSelector = [
'[mat-button]',
'[mat-raised-button]',
'[mat-flat-button]',
'[mat-icon-button]',
'[mat-stroked-button]',
'[mat-fab]',
'[mat-mini-fab]',
].join(',');
I would expect getHarness(MatButtonHarness.with({ancestor: '.foo'}))
to always find a MatButton that has a '.foo' ancestor. However, the current implementation of https://source.corp.google.com/search?q=HarnessPredicate.getSelector returns:
.foo [mat-button],[mat-raised-button],[mat-flat-button],[mat-icon-button],[mat-stroked-button],[mat-fab],[mat-mini-fab]
which only applies the ancestor constraint to the first possibility.