1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { HarnessPredicate, parallel, } from '@angular/cdk/testing';
|
---|
10 | import { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control';
|
---|
11 | import { MatOptionHarness, MatOptgroupHarness, } from '@angular/material/core/testing';
|
---|
12 | export class _MatSelectHarnessBase extends MatFormFieldControlHarness {
|
---|
13 | constructor() {
|
---|
14 | super(...arguments);
|
---|
15 | this._documentRootLocator = this.documentRootLocatorFactory();
|
---|
16 | this._backdrop = this._documentRootLocator.locatorFor('.cdk-overlay-backdrop');
|
---|
17 | }
|
---|
18 | /** Gets a boolean promise indicating if the select is disabled. */
|
---|
19 | isDisabled() {
|
---|
20 | return __awaiter(this, void 0, void 0, function* () {
|
---|
21 | return (yield this.host()).hasClass(`${this._prefix}-select-disabled`);
|
---|
22 | });
|
---|
23 | }
|
---|
24 | /** Gets a boolean promise indicating if the select is valid. */
|
---|
25 | isValid() {
|
---|
26 | return __awaiter(this, void 0, void 0, function* () {
|
---|
27 | return !(yield (yield this.host()).hasClass('ng-invalid'));
|
---|
28 | });
|
---|
29 | }
|
---|
30 | /** Gets a boolean promise indicating if the select is required. */
|
---|
31 | isRequired() {
|
---|
32 | return __awaiter(this, void 0, void 0, function* () {
|
---|
33 | return (yield this.host()).hasClass(`${this._prefix}-select-required`);
|
---|
34 | });
|
---|
35 | }
|
---|
36 | /** Gets a boolean promise indicating if the select is empty (no value is selected). */
|
---|
37 | isEmpty() {
|
---|
38 | return __awaiter(this, void 0, void 0, function* () {
|
---|
39 | return (yield this.host()).hasClass(`${this._prefix}-select-empty`);
|
---|
40 | });
|
---|
41 | }
|
---|
42 | /** Gets a boolean promise indicating if the select is in multi-selection mode. */
|
---|
43 | isMultiple() {
|
---|
44 | return __awaiter(this, void 0, void 0, function* () {
|
---|
45 | return (yield this.host()).hasClass(`${this._prefix}-select-multiple`);
|
---|
46 | });
|
---|
47 | }
|
---|
48 | /** Gets a promise for the select's value text. */
|
---|
49 | getValueText() {
|
---|
50 | return __awaiter(this, void 0, void 0, function* () {
|
---|
51 | const value = yield this.locatorFor(`.${this._prefix}-select-value`)();
|
---|
52 | return value.text();
|
---|
53 | });
|
---|
54 | }
|
---|
55 | /** Focuses the select and returns a void promise that indicates when the action is complete. */
|
---|
56 | focus() {
|
---|
57 | return __awaiter(this, void 0, void 0, function* () {
|
---|
58 | return (yield this.host()).focus();
|
---|
59 | });
|
---|
60 | }
|
---|
61 | /** Blurs the select and returns a void promise that indicates when the action is complete. */
|
---|
62 | blur() {
|
---|
63 | return __awaiter(this, void 0, void 0, function* () {
|
---|
64 | return (yield this.host()).blur();
|
---|
65 | });
|
---|
66 | }
|
---|
67 | /** Whether the select is focused. */
|
---|
68 | isFocused() {
|
---|
69 | return __awaiter(this, void 0, void 0, function* () {
|
---|
70 | return (yield this.host()).isFocused();
|
---|
71 | });
|
---|
72 | }
|
---|
73 | /** Gets the options inside the select panel. */
|
---|
74 | getOptions(filter) {
|
---|
75 | return __awaiter(this, void 0, void 0, function* () {
|
---|
76 | return this._documentRootLocator.locatorForAll(this._optionClass.with(Object.assign(Object.assign({}, (filter || {})), { ancestor: yield this._getPanelSelector() })))();
|
---|
77 | });
|
---|
78 | }
|
---|
79 | /** Gets the groups of options inside the panel. */
|
---|
80 | getOptionGroups(filter) {
|
---|
81 | return __awaiter(this, void 0, void 0, function* () {
|
---|
82 | return this._documentRootLocator.locatorForAll(this._optionGroupClass.with(Object.assign(Object.assign({}, (filter || {})), { ancestor: yield this._getPanelSelector() })))();
|
---|
83 | });
|
---|
84 | }
|
---|
85 | /** Gets whether the select is open. */
|
---|
86 | isOpen() {
|
---|
87 | return __awaiter(this, void 0, void 0, function* () {
|
---|
88 | return !!(yield this._documentRootLocator.locatorForOptional(yield this._getPanelSelector())());
|
---|
89 | });
|
---|
90 | }
|
---|
91 | /** Opens the select's panel. */
|
---|
92 | open() {
|
---|
93 | return __awaiter(this, void 0, void 0, function* () {
|
---|
94 | if (!(yield this.isOpen())) {
|
---|
95 | const trigger = yield this.locatorFor(`.${this._prefix}-select-trigger`)();
|
---|
96 | return trigger.click();
|
---|
97 | }
|
---|
98 | });
|
---|
99 | }
|
---|
100 | /**
|
---|
101 | * Clicks the options that match the passed-in filter. If the select is in multi-selection
|
---|
102 | * mode all options will be clicked, otherwise the harness will pick the first matching option.
|
---|
103 | */
|
---|
104 | clickOptions(filter) {
|
---|
105 | return __awaiter(this, void 0, void 0, function* () {
|
---|
106 | yield this.open();
|
---|
107 | const [isMultiple, options] = yield parallel(() => [this.isMultiple(), this.getOptions(filter)]);
|
---|
108 | if (options.length === 0) {
|
---|
109 | throw Error('Select does not have options matching the specified filter');
|
---|
110 | }
|
---|
111 | if (isMultiple) {
|
---|
112 | yield parallel(() => options.map(option => option.click()));
|
---|
113 | }
|
---|
114 | else {
|
---|
115 | yield options[0].click();
|
---|
116 | }
|
---|
117 | });
|
---|
118 | }
|
---|
119 | /** Closes the select's panel. */
|
---|
120 | close() {
|
---|
121 | return __awaiter(this, void 0, void 0, function* () {
|
---|
122 | if (yield this.isOpen()) {
|
---|
123 | // This is the most consistent way that works both in both single and multi-select modes,
|
---|
124 | // but it assumes that only one overlay is open at a time. We should be able to make it
|
---|
125 | // a bit more precise after #16645 where we can dispatch an ESCAPE press to the host instead.
|
---|
126 | return (yield this._backdrop()).click();
|
---|
127 | }
|
---|
128 | });
|
---|
129 | }
|
---|
130 | /** Gets the selector that should be used to find this select's panel. */
|
---|
131 | _getPanelSelector() {
|
---|
132 | return __awaiter(this, void 0, void 0, function* () {
|
---|
133 | const id = yield (yield this.host()).getAttribute('id');
|
---|
134 | return `#${id}-panel`;
|
---|
135 | });
|
---|
136 | }
|
---|
137 | }
|
---|
138 | /** Harness for interacting with a standard mat-select in tests. */
|
---|
139 | export class MatSelectHarness extends _MatSelectHarnessBase {
|
---|
140 | constructor() {
|
---|
141 | super(...arguments);
|
---|
142 | this._prefix = 'mat';
|
---|
143 | this._optionClass = MatOptionHarness;
|
---|
144 | this._optionGroupClass = MatOptgroupHarness;
|
---|
145 | }
|
---|
146 | /**
|
---|
147 | * Gets a `HarnessPredicate` that can be used to search for a `MatSelectHarness` that meets
|
---|
148 | * certain criteria.
|
---|
149 | * @param options Options for filtering which select instances are considered a match.
|
---|
150 | * @return a `HarnessPredicate` configured with the given options.
|
---|
151 | */
|
---|
152 | static with(options = {}) {
|
---|
153 | return new HarnessPredicate(MatSelectHarness, options);
|
---|
154 | }
|
---|
155 | }
|
---|
156 | MatSelectHarness.hostSelector = '.mat-select';
|
---|
157 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0LWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2VsZWN0L3Rlc3Rpbmcvc2VsZWN0LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFDTCxnQkFBZ0IsRUFDaEIsUUFBUSxHQUlULE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFDLDBCQUEwQixFQUFDLE1BQU0sOENBQThDLENBQUM7QUFDeEYsT0FBTyxFQUNMLGdCQUFnQixFQUNoQixrQkFBa0IsR0FHbkIsTUFBTSxnQ0FBZ0MsQ0FBQztBQUd4QyxNQUFNLE9BQWdCLHFCQVNwQixTQUFRLDBCQUEwQjtJQVRwQzs7UUFhVSx5QkFBb0IsR0FBRyxJQUFJLENBQUMsMEJBQTBCLEVBQUUsQ0FBQztRQUN6RCxjQUFTLEdBQUcsSUFBSSxDQUFDLG9CQUFvQixDQUFDLFVBQVUsQ0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