Skip to content

fix(material/list/testing): avoid element selectors that could conflict with the MDC version #20528

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/material/list/testing/action-list-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export class MatActionListHarness extends MatListHarnessBase<
/** Harness for interacting with an action list item. */
export class MatActionListItemHarness extends MatListItemHarnessBase {
/** The selector for the host element of a `MatListItem` instance. */
static hostSelector = ['mat-list-item', 'a[mat-list-item]', 'button[mat-list-item]']
.map(selector => `${MatActionListHarness.hostSelector} ${selector}`)
.join(',');
static hostSelector = `${MatActionListHarness.hostSelector} .mat-list-item`;

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatActionListItemHarness` that
Expand Down
6 changes: 2 additions & 4 deletions src/material/list/testing/list-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {getListItemPredicate, MatListItemHarnessBase} from './list-item-harness-
export class MatListHarness extends
MatListHarnessBase<typeof MatListItemHarness, MatListItemHarness, ListItemHarnessFilters> {
/** The selector for the host element of a `MatList` instance. */
static hostSelector = '.mat-list:not(mat-action-list):not(mat-nav-list):not(mat-selection-list)';
static hostSelector = '.mat-list:not(mat-action-list)';

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatListHarness` that meets certain
Expand All @@ -33,9 +33,7 @@ export class MatListHarness extends
/** Harness for interacting with a list item. */
export class MatListItemHarness extends MatListItemHarnessBase {
/** The selector for the host element of a `MatListItem` instance. */
static hostSelector = ['mat-list-item', 'a[mat-list-item]', 'button[mat-list-item]']
.map(selector => `${MatListHarness.hostSelector} ${selector}`)
.join(',');
static hostSelector = `${MatListHarness.hostSelector} .mat-list-item`;

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatListItemHarness` that meets
Expand Down
6 changes: 3 additions & 3 deletions src/material/list/testing/list-item-harness-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export class MatSubheaderHarness extends ComponentHarness {
* @docs-private
*/
export class MatListItemHarnessBase extends ComponentHarness {
private _lines = this.locatorForAll('[mat-line], [matLine]');
private _avatar = this.locatorForOptional('[mat-list-avatar], [matListAvatar]');
private _icon = this.locatorForOptional('[mat-list-icon], [matListIcon]');
private _lines = this.locatorForAll('.mat-line');
private _avatar = this.locatorForOptional('.mat-list-avatar');
private _icon = this.locatorForOptional('.mat-list-icon');

/** Gets the full text content of the list item (including text from any font icons). */
async getText(): Promise<string> {
Expand Down
4 changes: 1 addition & 3 deletions src/material/list/testing/nav-list-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export class MatNavListHarness extends MatListHarnessBase<
/** Harness for interacting with a nav list item. */
export class MatNavListItemHarness extends MatListItemHarnessBase {
/** The selector for the host element of a `MatListItem` instance. */
static hostSelector = ['mat-list-item', 'a[mat-list-item]', 'button[mat-list-item]']
.map(selector => `${MatNavListHarness.hostSelector} ${selector}`)
.join(',');
static hostSelector = `${MatNavListHarness.hostSelector} .mat-list-item`;

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatNavListItemHarness` that
Expand Down