Skip to content
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
12 changes: 6 additions & 6 deletions src/material/datepicker/testing/date-range-input-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class MatEndDateHarness extends MatDatepickerInputHarnessBase {
export class MatDateRangeInputHarness extends DatepickerTriggerHarnessBase {
static hostSelector = '.mat-date-range-input';

private readonly floatingLabelSelector = '.mdc-floating-label';
private readonly _floatingLabelSelector = '.mdc-floating-label';

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatDateRangeInputHarness`
Expand Down Expand Up @@ -94,22 +94,22 @@ export class MatDateRangeInputHarness extends DatepickerTriggerHarnessBase {
/** Gets the floating label text for the range input, if it exists. */
async getLabel(): Promise<string | null> {
// Copied from MatFormFieldControlHarnessBase since this class cannot extend two classes
const documentRootLocator = await this.documentRootLocatorFactory();
const documentRootLocator = this.documentRootLocatorFactory();
const labelId = await (await this.host()).getAttribute('aria-labelledby');
const hostId = await (await this.host()).getAttribute('id');

if (labelId) {
// First option, try to fetch the label using the `aria-labelledby`
// attribute.
const labelEl = await await documentRootLocator.locatorForOptional(
`${this.floatingLabelSelector}[id="${labelId}"]`,
const labelEl = await documentRootLocator.locatorForOptional(
`${this._floatingLabelSelector}[id="${labelId}"]`,
)();
return labelEl ? labelEl.text() : null;
} else if (hostId) {
// Fallback option, try to match the id of the input with the `for`
// attribute of the label.
const labelEl = await await documentRootLocator.locatorForOptional(
`${this.floatingLabelSelector}[for="${hostId}"]`,
const labelEl = await documentRootLocator.locatorForOptional(
`${this._floatingLabelSelector}[for="${hostId}"]`,
)();
return labelEl ? labelEl.text() : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ export abstract class MatFormFieldControlHarness extends ComponentHarness {}
* Shared behavior for `MatFormFieldControlHarness` implementations
*/
export abstract class MatFormFieldControlHarnessBase extends MatFormFieldControlHarness {
private readonly floatingLabelSelector = '.mdc-floating-label';
private readonly _floatingLabelSelector = '.mdc-floating-label';

/** Gets the text content of the floating label, if it exists. */
public async getLabel(): Promise<string | null> {
const documentRootLocator = await this.documentRootLocatorFactory();
async getLabel(): Promise<string | null> {
const documentRootLocator = this.documentRootLocatorFactory();
const labelId = await (await this.host()).getAttribute('aria-labelledby');
const hostId = await (await this.host()).getAttribute('id');

if (labelId) {
// First option, try to fetch the label using the `aria-labelledby`
// attribute.
const labelEl = await await documentRootLocator.locatorForOptional(
`${this.floatingLabelSelector}[id="${labelId}"]`,
const labelEl = await documentRootLocator.locatorForOptional(
`${this._floatingLabelSelector}[id="${labelId}"]`,
)();
return labelEl ? labelEl.text() : null;
} else if (hostId) {
// Fallback option, try to match the id of the input with the `for`
// attribute of the label.
const labelEl = await await documentRootLocator.locatorForOptional(
`${this.floatingLabelSelector}[for="${hostId}"]`,
const labelEl = await documentRootLocator.locatorForOptional(
`${this._floatingLabelSelector}[for="${hostId}"]`,
)();
return labelEl ? labelEl.text() : null;
}
Expand Down
1 change: 0 additions & 1 deletion src/material/select/testing/select-harness-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {BaseHarnessFilters} from '@angular/cdk/testing';
import {MatFormFieldControlHarnessFilters} from '@angular/material/form-field/testing/control';

/** A set of criteria that can be used to filter a list of `MatSelectHarness` instances. */
Expand Down
Loading