Skip to content

Commit

Permalink
fix CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Aug 16, 2022
1 parent 76cc2f8 commit 8bbf672
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 39 deletions.
18 changes: 6 additions & 12 deletions src/material/legacy-snack-bar/testing/snack-bar-harness.ts
Expand Up @@ -5,21 +5,18 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ComponentHarnessConstructor, HarnessPredicate} from '@angular/cdk/testing';
import {
MatSnackBarHarness as SnackBarHarnessBase,
SnackBarHarnessFilters,
} from '@angular/material/snack-bar/testing';
import {HarnessPredicate} from '@angular/cdk/testing';
import {_MatSnackBarHarnessBase, SnackBarHarnessFilters} from '@angular/material/snack-bar/testing';

/** Harness for interacting with a standard mat-snack-bar in tests. */
export class MatLegacySnackBarHarness extends SnackBarHarnessBase {
export class MatLegacySnackBarHarness extends _MatSnackBarHarnessBase {
// Developers can provide a custom component or template for the snackbar. The canonical snack-bar
// parent is the "MatSnackBarContainer". We use `:not([mat-exit])` to exclude snack bars that
// are in the process of being dismissed, because the element only gets removed after the
// animation is finished and since it runs outside of Angular, we don't have a way of being
// notified when it's done.
/** The selector for the host element of a `MatSnackBar` instance. */
static override hostSelector = '.mat-snack-bar-container';
static hostSelector = '.mat-snack-bar-container';
protected override _messageSelector = '.mat-simple-snackbar > span';
protected override _actionButtonSelector = '.mat-simple-snackbar-action > button';

Expand All @@ -28,11 +25,8 @@ export class MatLegacySnackBarHarness extends SnackBarHarnessBase {
* @param options Options for filtering which snack bar instances are considered a match.
* @return a `HarnessPredicate` configured with the given options.
*/
static override with<T extends MatLegacySnackBarHarness>(
this: ComponentHarnessConstructor<T>,
options: SnackBarHarnessFilters = {},
): HarnessPredicate<T> {
return new HarnessPredicate(this, options);
static with(options: SnackBarHarnessFilters = {}): HarnessPredicate<MatLegacySnackBarHarness> {
return new HarnessPredicate(MatLegacySnackBarHarness, options);
}

protected override async _assertContentAnnotated() {
Expand Down
50 changes: 31 additions & 19 deletions src/material/snack-bar/testing/snack-bar-harness.ts
Expand Up @@ -10,25 +10,11 @@ import {ContentContainerComponentHarness, HarnessPredicate, parallel} from '@ang
import {AriaLivePoliteness} from '@angular/cdk/a11y';
import {SnackBarHarnessFilters} from './snack-bar-harness-filters';

/** Harness for interacting with an MDC-based mat-snack-bar in tests. */
export class MatSnackBarHarness extends ContentContainerComponentHarness<string> {
// Developers can provide a custom component or template for the
// snackbar. The canonical snack-bar parent is the "MatSnackBarContainer".
/** The selector for the host element of a `MatSnackBar` instance. */
static hostSelector = '.mat-mdc-snack-bar-container:not([mat-exit])';
protected _messageSelector = '.mdc-snackbar__label';
protected _actionButtonSelector = '.mat-mdc-snack-bar-action';
private _snackBarLiveRegion = this.locatorFor('[aria-live]');
export abstract class _MatSnackBarHarnessBase extends ContentContainerComponentHarness<string> {
protected abstract _messageSelector: string;
protected abstract _actionButtonSelector: string;

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatSnackBarHarness` that meets
* certain criteria.
* @param options Options for filtering which snack bar instances are considered a match.
* @return a `HarnessPredicate` configured with the given options.
*/
static with(options: SnackBarHarnessFilters = {}): HarnessPredicate<MatSnackBarHarness> {
return new HarnessPredicate(MatSnackBarHarness, options);
}
private _snackBarLiveRegion = this.locatorFor('[aria-live]');

/**
* Gets the role of the snack-bar. The role of a snack-bar is determined based
Expand Down Expand Up @@ -104,7 +90,7 @@ export class MatSnackBarHarness extends ContentContainerComponentHarness<string>
* Asserts that the current snack-bar has annotated content. Promise reject
* if content is not annotated.
*/
protected async _assertContentAnnotated(): Promise<void> {}
protected abstract _assertContentAnnotated(): Promise<void>;

/**
* Asserts that the current snack-bar has an action defined. Otherwise the
Expand All @@ -122,3 +108,29 @@ export class MatSnackBarHarness extends ContentContainerComponentHarness<string>
return this.locatorForOptional(this._actionButtonSelector)();
}
}

/** Harness for interacting with an MDC-based mat-snack-bar in tests. */
export class MatSnackBarHarness extends _MatSnackBarHarnessBase {
// Developers can provide a custom component or template for the
// snackbar. The canonical snack-bar parent is the "MatSnackBarContainer".
/** The selector for the host element of a `MatSnackBar` instance. */
static hostSelector = '.mat-mdc-snack-bar-container:not([mat-exit])';
protected override _messageSelector = '.mdc-snackbar__label';
protected override _actionButtonSelector = '.mat-mdc-snack-bar-action';

/**
* Gets a `HarnessPredicate` that can be used to search for a `MatSnackBarHarness` that meets
* certain criteria.
* @param options Options for filtering which snack bar instances are considered a match.
* @return a `HarnessPredicate` configured with the given options.
*/
static with(options: SnackBarHarnessFilters = {}): HarnessPredicate<MatSnackBarHarness> {
return new HarnessPredicate(MatSnackBarHarness, options);
}

/**
* Asserts that the current snack-bar has annotated content. Promise reject
* if content is not annotated.
*/
protected override async _assertContentAnnotated() {}
}
7 changes: 3 additions & 4 deletions tools/public_api_guard/material/legacy-snack-bar-testing.md
Expand Up @@ -4,23 +4,22 @@
```ts

import { ComponentHarnessConstructor } from '@angular/cdk/testing';
import { HarnessPredicate } from '@angular/cdk/testing';
import { SnackBarHarnessFilters as LegacySnackBarHarnessFilters } from '@angular/material/snack-bar/testing';
import { MatSnackBarHarness } from '@angular/material/snack-bar/testing';
import { _MatSnackBarHarnessBase } from '@angular/material/snack-bar/testing';

export { LegacySnackBarHarnessFilters }

// @public
export class MatLegacySnackBarHarness extends MatSnackBarHarness {
export class MatLegacySnackBarHarness extends _MatSnackBarHarnessBase {
// (undocumented)
protected _actionButtonSelector: string;
// (undocumented)
protected _assertContentAnnotated(): Promise<void>;
static hostSelector: string;
// (undocumented)
protected _messageSelector: string;
static with<T extends MatLegacySnackBarHarness>(this: ComponentHarnessConstructor<T>, options?: LegacySnackBarHarnessFilters): HarnessPredicate<T>;
static with(options?: LegacySnackBarHarnessFilters): HarnessPredicate<MatLegacySnackBarHarness>;
}

// (No @packageDocumentation comment for this package)
Expand Down
17 changes: 13 additions & 4 deletions tools/public_api_guard/material/snack-bar-testing.md
Expand Up @@ -10,10 +10,21 @@ import { ContentContainerComponentHarness } from '@angular/cdk/testing';
import { HarnessPredicate } from '@angular/cdk/testing';

// @public
export class MatSnackBarHarness extends ContentContainerComponentHarness<string> {
export class MatSnackBarHarness extends _MatSnackBarHarnessBase {
// (undocumented)
protected _actionButtonSelector: string;
protected _assertContentAnnotated(): Promise<void>;
static hostSelector: string;
// (undocumented)
protected _messageSelector: string;
static with(options?: SnackBarHarnessFilters): HarnessPredicate<MatSnackBarHarness>;
}

// @public (undocumented)
export abstract class _MatSnackBarHarnessBase extends ContentContainerComponentHarness<string> {
// (undocumented)
protected abstract _actionButtonSelector: string;
protected abstract _assertContentAnnotated(): Promise<void>;
protected _assertHasAction(): Promise<void>;
dismissWithAction(): Promise<void>;
getActionDescription(): Promise<string>;
Expand All @@ -22,11 +33,9 @@ export class MatSnackBarHarness extends ContentContainerComponentHarness<string>
// @deprecated
getRole(): Promise<'alert' | 'status' | null>;
hasAction(): Promise<boolean>;
static hostSelector: string;
isDismissed(): Promise<boolean>;
// (undocumented)
protected _messageSelector: string;
static with(options?: SnackBarHarnessFilters): HarnessPredicate<MatSnackBarHarness>;
protected abstract _messageSelector: string;
}

// @public
Expand Down

0 comments on commit 8bbf672

Please sign in to comment.