@angular/material 21.0.0-next.9 → 21.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/tokens/_classes.scss +1 -1
- package/core/tokens/m2/_md-sys-color.scss +17 -17
- package/fesm2022/_animation-chunk.mjs +10 -16
- package/fesm2022/_animation-chunk.mjs.map +1 -1
- package/fesm2022/_date-formats-chunk.mjs +68 -164
- package/fesm2022/_date-formats-chunk.mjs.map +1 -1
- package/fesm2022/_date-range-input-harness-chunk.mjs +284 -463
- package/fesm2022/_date-range-input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_error-options-chunk.mjs +56 -19
- package/fesm2022/_error-options-chunk.mjs.map +1 -1
- package/fesm2022/_error-state-chunk.mjs +24 -31
- package/fesm2022/_error-state-chunk.mjs.map +1 -1
- package/fesm2022/_form-field-chunk.mjs +1224 -1017
- package/fesm2022/_form-field-chunk.mjs.map +1 -1
- package/fesm2022/_icon-button-chunk.mjs +243 -187
- package/fesm2022/_icon-button-chunk.mjs.map +1 -1
- package/fesm2022/_icon-registry-chunk.mjs +350 -575
- package/fesm2022/_icon-registry-chunk.mjs.map +1 -1
- package/fesm2022/_input-harness-chunk.mjs +56 -107
- package/fesm2022/_input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_input-value-accessor-chunk.mjs +0 -6
- package/fesm2022/_input-value-accessor-chunk.mjs.map +1 -1
- package/fesm2022/_internal-form-field-chunk.mjs +59 -19
- package/fesm2022/_internal-form-field-chunk.mjs.map +1 -1
- package/fesm2022/_line-chunk.mjs +83 -43
- package/fesm2022/_line-chunk.mjs.map +1 -1
- package/fesm2022/_option-chunk.mjs +348 -311
- package/fesm2022/_option-chunk.mjs.map +1 -1
- package/fesm2022/_option-harness-chunk.mjs +23 -39
- package/fesm2022/_option-harness-chunk.mjs.map +1 -1
- package/fesm2022/_option-module-chunk.mjs +36 -10
- package/fesm2022/_option-module-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-chunk.mjs +79 -44
- package/fesm2022/_pseudo-checkbox-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs +36 -10
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs.map +1 -1
- package/fesm2022/_public-api-chunk.mjs +71 -134
- package/fesm2022/_public-api-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-chunk.mjs +504 -600
- package/fesm2022/_ripple-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-loader-chunk.mjs +120 -138
- package/fesm2022/_ripple-loader-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-module-chunk.mjs +36 -10
- package/fesm2022/_ripple-module-chunk.mjs.map +1 -1
- package/fesm2022/_structural-styles-chunk.mjs +37 -10
- package/fesm2022/_structural-styles-chunk.mjs.map +1 -1
- package/fesm2022/_tooltip-chunk.mjs +810 -888
- package/fesm2022/_tooltip-chunk.mjs.map +1 -1
- package/fesm2022/autocomplete-testing.mjs +62 -86
- package/fesm2022/autocomplete-testing.mjs.map +1 -1
- package/fesm2022/autocomplete.mjs +965 -1126
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge-testing.mjs +38 -54
- package/fesm2022/badge-testing.mjs.map +1 -1
- package/fesm2022/badge.mjs +321 -272
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet-testing.mjs +10 -24
- package/fesm2022/bottom-sheet-testing.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs +349 -344
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button-testing.mjs +60 -94
- package/fesm2022/button-testing.mjs.map +1 -1
- package/fesm2022/button-toggle-testing.mjs +76 -125
- package/fesm2022/button-toggle-testing.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs +752 -662
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs +263 -158
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card-testing.mjs +19 -33
- package/fesm2022/card-testing.mjs.map +1 -1
- package/fesm2022/card.mjs +576 -272
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox-testing.mjs +71 -123
- package/fesm2022/checkbox-testing.mjs.map +1 -1
- package/fesm2022/checkbox.mjs +515 -477
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips-testing.mjs +201 -344
- package/fesm2022/chips-testing.mjs.map +1 -1
- package/fesm2022/chips.mjs +2552 -2289
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/core-testing.mjs +14 -28
- package/fesm2022/core-testing.mjs.map +1 -1
- package/fesm2022/core.mjs +357 -328
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/datepicker-testing.mjs +15 -25
- package/fesm2022/datepicker-testing.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +4826 -4563
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog-testing.mjs +93 -129
- package/fesm2022/dialog-testing.mjs.map +1 -1
- package/fesm2022/dialog.mjs +810 -829
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider-testing.mjs +10 -11
- package/fesm2022/divider-testing.mjs.map +1 -1
- package/fesm2022/divider.mjs +119 -43
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/expansion-testing.mjs +74 -130
- package/fesm2022/expansion-testing.mjs.map +1 -1
- package/fesm2022/expansion.mjs +703 -515
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field-testing-control.mjs +16 -33
- package/fesm2022/form-field-testing-control.mjs.map +1 -1
- package/fesm2022/form-field-testing.mjs +118 -179
- package/fesm2022/form-field-testing.mjs.map +1 -1
- package/fesm2022/form-field.mjs +36 -10
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list-testing.mjs +65 -113
- package/fesm2022/grid-list-testing.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +559 -494
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon-testing.mjs +148 -127
- package/fesm2022/icon-testing.mjs.map +1 -1
- package/fesm2022/icon.mjs +325 -351
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/input-testing.mjs +59 -99
- package/fesm2022/input-testing.mjs.map +1 -1
- package/fesm2022/input.mjs +457 -520
- package/fesm2022/input.mjs.map +1 -1
- package/fesm2022/list-testing.mjs +251 -434
- package/fesm2022/list-testing.mjs.map +1 -1
- package/fesm2022/list.mjs +1522 -1204
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/material.mjs +0 -5
- package/fesm2022/material.mjs.map +1 -1
- package/fesm2022/menu-testing.mjs +159 -228
- package/fesm2022/menu-testing.mjs.map +1 -1
- package/fesm2022/menu.mjs +1338 -1343
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/paginator-testing.mjs +55 -79
- package/fesm2022/paginator-testing.mjs.map +1 -1
- package/fesm2022/paginator.mjs +381 -309
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar-testing.mjs +12 -21
- package/fesm2022/progress-bar-testing.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs +224 -169
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner-testing.mjs +13 -23
- package/fesm2022/progress-spinner-testing.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +235 -160
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/radio-testing.mjs +133 -208
- package/fesm2022/radio-testing.mjs.map +1 -1
- package/fesm2022/radio.mjs +712 -679
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/select-testing.mjs +83 -117
- package/fesm2022/select-testing.mjs.map +1 -1
- package/fesm2022/select.mjs +1116 -1246
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav-testing.mjs +54 -120
- package/fesm2022/sidenav-testing.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +1078 -995
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle-testing.mjs +57 -92
- package/fesm2022/slide-toggle-testing.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +369 -279
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider-testing.mjs +90 -138
- package/fesm2022/slider-testing.mjs.map +1 -1
- package/fesm2022/slider.mjs +1651 -1716
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar-testing.mjs +40 -87
- package/fesm2022/snack-bar-testing.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs +763 -714
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort-testing.mjs +45 -66
- package/fesm2022/sort-testing.mjs.map +1 -1
- package/fesm2022/sort.mjs +419 -344
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper-testing.mjs +78 -154
- package/fesm2022/stepper-testing.mjs.map +1 -1
- package/fesm2022/stepper.mjs +790 -498
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/table-testing.mjs +120 -213
- package/fesm2022/table-testing.mjs.map +1 -1
- package/fesm2022/table.mjs +1026 -684
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs-testing.mjs +125 -197
- package/fesm2022/tabs-testing.mjs.map +1 -1
- package/fesm2022/tabs.mjs +2351 -2028
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/timepicker-testing.mjs +113 -172
- package/fesm2022/timepicker-testing.mjs.map +1 -1
- package/fesm2022/timepicker.mjs +1019 -826
- package/fesm2022/timepicker.mjs.map +1 -1
- package/fesm2022/toolbar-testing.mjs +16 -27
- package/fesm2022/toolbar-testing.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +163 -78
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip-testing.mjs +41 -52
- package/fesm2022/tooltip-testing.mjs.map +1 -1
- package/fesm2022/tooltip.mjs +36 -10
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree-testing.mjs +86 -162
- package/fesm2022/tree-testing.mjs.map +1 -1
- package/fesm2022/tree.mjs +638 -466
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/schematics/ng-add/index.js +1 -1
- package/types/expansion.d.ts +4 -2
- package/types/menu-testing.d.ts +2 -0
- package/types/select.d.ts +1 -1
- package/types/timepicker.d.ts +1 -0
|
@@ -1,500 +1,321 @@
|
|
|
1
1
|
import { HarnessPredicate, ComponentHarness, parallel, TestKey } from '@angular/cdk/testing';
|
|
2
2
|
import { MatFormFieldControlHarnessBase } from '@angular/material/form-field/testing/control';
|
|
3
3
|
|
|
4
|
-
/** Sets up the filter predicates for a datepicker input harness. */
|
|
5
4
|
function getInputPredicate(type, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.addOption('label', options.label, (harness, label) => {
|
|
14
|
-
return HarnessPredicate.stringMatches(harness.getLabel(), label);
|
|
15
|
-
});
|
|
5
|
+
return new HarnessPredicate(type, options).addOption('value', options.value, (harness, value) => {
|
|
6
|
+
return HarnessPredicate.stringMatches(harness.getValue(), value);
|
|
7
|
+
}).addOption('placeholder', options.placeholder, (harness, placeholder) => {
|
|
8
|
+
return HarnessPredicate.stringMatches(harness.getPlaceholder(), placeholder);
|
|
9
|
+
}).addOption('label', options.label, (harness, label) => {
|
|
10
|
+
return HarnessPredicate.stringMatches(harness.getLabel(), label);
|
|
11
|
+
});
|
|
16
12
|
}
|
|
17
|
-
/** Base class for datepicker input harnesses. */
|
|
18
13
|
class MatDatepickerInputHarnessBase extends MatFormFieldControlHarnessBase {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
async focus() {
|
|
56
|
-
return (await this.host()).focus();
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Blurs the input and returns a promise that indicates when the
|
|
60
|
-
* action is complete.
|
|
61
|
-
*/
|
|
62
|
-
async blur() {
|
|
63
|
-
return (await this.host()).blur();
|
|
64
|
-
}
|
|
65
|
-
/** Whether the input is focused. */
|
|
66
|
-
async isFocused() {
|
|
67
|
-
return (await this.host()).isFocused();
|
|
68
|
-
}
|
|
69
|
-
/** Gets the formatted minimum date for the input's value. */
|
|
70
|
-
async getMin() {
|
|
71
|
-
return (await this.host()).getAttribute('min');
|
|
72
|
-
}
|
|
73
|
-
/** Gets the formatted maximum date for the input's value. */
|
|
74
|
-
async getMax() {
|
|
75
|
-
return (await this.host()).getAttribute('max');
|
|
76
|
-
}
|
|
14
|
+
async isDisabled() {
|
|
15
|
+
return (await this.host()).getProperty('disabled');
|
|
16
|
+
}
|
|
17
|
+
async isRequired() {
|
|
18
|
+
return (await this.host()).getProperty('required');
|
|
19
|
+
}
|
|
20
|
+
async getValue() {
|
|
21
|
+
return await (await this.host()).getProperty('value');
|
|
22
|
+
}
|
|
23
|
+
async setValue(newValue) {
|
|
24
|
+
const inputEl = await this.host();
|
|
25
|
+
await inputEl.clear();
|
|
26
|
+
if (newValue) {
|
|
27
|
+
await inputEl.sendKeys(newValue);
|
|
28
|
+
}
|
|
29
|
+
await inputEl.dispatchEvent('change');
|
|
30
|
+
}
|
|
31
|
+
async getPlaceholder() {
|
|
32
|
+
return await (await this.host()).getProperty('placeholder');
|
|
33
|
+
}
|
|
34
|
+
async focus() {
|
|
35
|
+
return (await this.host()).focus();
|
|
36
|
+
}
|
|
37
|
+
async blur() {
|
|
38
|
+
return (await this.host()).blur();
|
|
39
|
+
}
|
|
40
|
+
async isFocused() {
|
|
41
|
+
return (await this.host()).isFocused();
|
|
42
|
+
}
|
|
43
|
+
async getMin() {
|
|
44
|
+
return (await this.host()).getAttribute('min');
|
|
45
|
+
}
|
|
46
|
+
async getMax() {
|
|
47
|
+
return (await this.host()).getAttribute('max');
|
|
48
|
+
}
|
|
77
49
|
}
|
|
78
50
|
|
|
79
|
-
/** Harness for interacting with a standard Material calendar cell in tests. */
|
|
80
51
|
class MatCalendarCellHarness extends ComponentHarness {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return this._hasState('range-start');
|
|
167
|
-
}
|
|
168
|
-
/** Whether the cell is the end of the main range. */
|
|
169
|
-
async isRangeEnd() {
|
|
170
|
-
return this._hasState('range-end');
|
|
171
|
-
}
|
|
172
|
-
/** Whether the cell is part of the main range. */
|
|
173
|
-
async isInRange() {
|
|
174
|
-
return this._hasState('in-range');
|
|
175
|
-
}
|
|
176
|
-
/** Whether the cell is the start of the comparison range. */
|
|
177
|
-
async isComparisonRangeStart() {
|
|
178
|
-
return this._hasState('comparison-start');
|
|
179
|
-
}
|
|
180
|
-
/** Whether the cell is the end of the comparison range. */
|
|
181
|
-
async isComparisonRangeEnd() {
|
|
182
|
-
return this._hasState('comparison-end');
|
|
183
|
-
}
|
|
184
|
-
/** Whether the cell is inside of the comparison range. */
|
|
185
|
-
async isInComparisonRange() {
|
|
186
|
-
return this._hasState('in-comparison-range');
|
|
187
|
-
}
|
|
188
|
-
/** Whether the cell is the start of the preview range. */
|
|
189
|
-
async isPreviewRangeStart() {
|
|
190
|
-
return this._hasState('preview-start');
|
|
191
|
-
}
|
|
192
|
-
/** Whether the cell is the end of the preview range. */
|
|
193
|
-
async isPreviewRangeEnd() {
|
|
194
|
-
return this._hasState('preview-end');
|
|
195
|
-
}
|
|
196
|
-
/** Whether the cell is inside of the preview range. */
|
|
197
|
-
async isInPreviewRange() {
|
|
198
|
-
return this._hasState('in-preview');
|
|
199
|
-
}
|
|
200
|
-
/** Returns whether the cell has a particular CSS class-based state. */
|
|
201
|
-
async _hasState(name) {
|
|
202
|
-
return (await this.host()).hasClass(`mat-calendar-body-${name}`);
|
|
203
|
-
}
|
|
52
|
+
static hostSelector = '.mat-calendar-body-cell';
|
|
53
|
+
_content = this.locatorFor('.mat-calendar-body-cell-content');
|
|
54
|
+
static with(options = {}) {
|
|
55
|
+
return new HarnessPredicate(MatCalendarCellHarness, options).addOption('text', options.text, (harness, text) => {
|
|
56
|
+
return HarnessPredicate.stringMatches(harness.getText(), text);
|
|
57
|
+
}).addOption('selected', options.selected, async (harness, selected) => {
|
|
58
|
+
return (await harness.isSelected()) === selected;
|
|
59
|
+
}).addOption('active', options.active, async (harness, active) => {
|
|
60
|
+
return (await harness.isActive()) === active;
|
|
61
|
+
}).addOption('disabled', options.disabled, async (harness, disabled) => {
|
|
62
|
+
return (await harness.isDisabled()) === disabled;
|
|
63
|
+
}).addOption('today', options.today, async (harness, today) => {
|
|
64
|
+
return (await harness.isToday()) === today;
|
|
65
|
+
}).addOption('inRange', options.inRange, async (harness, inRange) => {
|
|
66
|
+
return (await harness.isInRange()) === inRange;
|
|
67
|
+
}).addOption('inComparisonRange', options.inComparisonRange, async (harness, inComparisonRange) => {
|
|
68
|
+
return (await harness.isInComparisonRange()) === inComparisonRange;
|
|
69
|
+
}).addOption('inPreviewRange', options.inPreviewRange, async (harness, inPreviewRange) => {
|
|
70
|
+
return (await harness.isInPreviewRange()) === inPreviewRange;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async getText() {
|
|
74
|
+
return (await this._content()).text();
|
|
75
|
+
}
|
|
76
|
+
async getAriaLabel() {
|
|
77
|
+
return (await this.host()).getAttribute('aria-label');
|
|
78
|
+
}
|
|
79
|
+
async isSelected() {
|
|
80
|
+
const host = await this.host();
|
|
81
|
+
return (await host.getAttribute('aria-pressed')) === 'true';
|
|
82
|
+
}
|
|
83
|
+
async isDisabled() {
|
|
84
|
+
return this._hasState('disabled');
|
|
85
|
+
}
|
|
86
|
+
async isActive() {
|
|
87
|
+
return this._hasState('active');
|
|
88
|
+
}
|
|
89
|
+
async isToday() {
|
|
90
|
+
return (await this._content()).hasClass('mat-calendar-body-today');
|
|
91
|
+
}
|
|
92
|
+
async select() {
|
|
93
|
+
return (await this.host()).click();
|
|
94
|
+
}
|
|
95
|
+
async hover() {
|
|
96
|
+
return (await this.host()).hover();
|
|
97
|
+
}
|
|
98
|
+
async mouseAway() {
|
|
99
|
+
return (await this.host()).mouseAway();
|
|
100
|
+
}
|
|
101
|
+
async focus() {
|
|
102
|
+
return (await this.host()).focus();
|
|
103
|
+
}
|
|
104
|
+
async blur() {
|
|
105
|
+
return (await this.host()).blur();
|
|
106
|
+
}
|
|
107
|
+
async isRangeStart() {
|
|
108
|
+
return this._hasState('range-start');
|
|
109
|
+
}
|
|
110
|
+
async isRangeEnd() {
|
|
111
|
+
return this._hasState('range-end');
|
|
112
|
+
}
|
|
113
|
+
async isInRange() {
|
|
114
|
+
return this._hasState('in-range');
|
|
115
|
+
}
|
|
116
|
+
async isComparisonRangeStart() {
|
|
117
|
+
return this._hasState('comparison-start');
|
|
118
|
+
}
|
|
119
|
+
async isComparisonRangeEnd() {
|
|
120
|
+
return this._hasState('comparison-end');
|
|
121
|
+
}
|
|
122
|
+
async isInComparisonRange() {
|
|
123
|
+
return this._hasState('in-comparison-range');
|
|
124
|
+
}
|
|
125
|
+
async isPreviewRangeStart() {
|
|
126
|
+
return this._hasState('preview-start');
|
|
127
|
+
}
|
|
128
|
+
async isPreviewRangeEnd() {
|
|
129
|
+
return this._hasState('preview-end');
|
|
130
|
+
}
|
|
131
|
+
async isInPreviewRange() {
|
|
132
|
+
return this._hasState('in-preview');
|
|
133
|
+
}
|
|
134
|
+
async _hasState(name) {
|
|
135
|
+
return (await this.host()).hasClass(`mat-calendar-body-${name}`);
|
|
136
|
+
}
|
|
204
137
|
}
|
|
205
138
|
|
|
206
|
-
/** Possible views of a `MatCalendarHarness`. */
|
|
207
139
|
var CalendarView;
|
|
208
140
|
(function (CalendarView) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
141
|
+
CalendarView[CalendarView["MONTH"] = 0] = "MONTH";
|
|
142
|
+
CalendarView[CalendarView["YEAR"] = 1] = "YEAR";
|
|
143
|
+
CalendarView[CalendarView["MULTI_YEAR"] = 2] = "MULTI_YEAR";
|
|
212
144
|
})(CalendarView || (CalendarView = {}));
|
|
213
|
-
/** Harness for interacting with a standard Material calendar in tests. */
|
|
214
145
|
class MatCalendarHarness extends ComponentHarness {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
/** Goes to the next page of the current view (e.g. next month when inside the month view). */
|
|
253
|
-
async next() {
|
|
254
|
-
return (await this.locatorFor('.mat-calendar-next-button')()).click();
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Goes to the previous page of the current view
|
|
258
|
-
* (e.g. previous month when inside the month view).
|
|
259
|
-
*/
|
|
260
|
-
async previous() {
|
|
261
|
-
return (await this.locatorFor('.mat-calendar-previous-button')()).click();
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Selects a cell in the current calendar view.
|
|
265
|
-
* @param filter An optional filter to apply to the cells. The first cell matching the filter
|
|
266
|
-
* will be selected.
|
|
267
|
-
*/
|
|
268
|
-
async selectCell(filter = {}) {
|
|
269
|
-
const cells = await this.getCells(filter);
|
|
270
|
-
if (!cells.length) {
|
|
271
|
-
throw Error(`Cannot find calendar cell matching filter ${JSON.stringify(filter)}`);
|
|
272
|
-
}
|
|
273
|
-
await cells[0].select();
|
|
274
|
-
}
|
|
146
|
+
static hostSelector = '.mat-calendar';
|
|
147
|
+
_periodButton = this.locatorFor('.mat-calendar-period-button');
|
|
148
|
+
static with(options = {}) {
|
|
149
|
+
return new HarnessPredicate(MatCalendarHarness, options);
|
|
150
|
+
}
|
|
151
|
+
async getCells(filter = {}) {
|
|
152
|
+
return this.locatorForAll(MatCalendarCellHarness.with(filter))();
|
|
153
|
+
}
|
|
154
|
+
async getCurrentView() {
|
|
155
|
+
if (await this.locatorForOptional('mat-multi-year-view')()) {
|
|
156
|
+
return CalendarView.MULTI_YEAR;
|
|
157
|
+
}
|
|
158
|
+
if (await this.locatorForOptional('mat-year-view')()) {
|
|
159
|
+
return CalendarView.YEAR;
|
|
160
|
+
}
|
|
161
|
+
return CalendarView.MONTH;
|
|
162
|
+
}
|
|
163
|
+
async getCurrentViewLabel() {
|
|
164
|
+
return (await this._periodButton()).text();
|
|
165
|
+
}
|
|
166
|
+
async changeView() {
|
|
167
|
+
return (await this._periodButton()).click();
|
|
168
|
+
}
|
|
169
|
+
async next() {
|
|
170
|
+
return (await this.locatorFor('.mat-calendar-next-button')()).click();
|
|
171
|
+
}
|
|
172
|
+
async previous() {
|
|
173
|
+
return (await this.locatorFor('.mat-calendar-previous-button')()).click();
|
|
174
|
+
}
|
|
175
|
+
async selectCell(filter = {}) {
|
|
176
|
+
const cells = await this.getCells(filter);
|
|
177
|
+
if (!cells.length) {
|
|
178
|
+
throw Error(`Cannot find calendar cell matching filter ${JSON.stringify(filter)}`);
|
|
179
|
+
}
|
|
180
|
+
await cells[0].select();
|
|
181
|
+
}
|
|
275
182
|
}
|
|
276
183
|
|
|
277
|
-
/** Base class for harnesses that can trigger a calendar. */
|
|
278
184
|
class DatepickerTriggerHarnessBase extends ComponentHarness {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Gets the `MatCalendarHarness` that is associated with the trigger.
|
|
300
|
-
* @param filter Optionally filters which calendar is included.
|
|
301
|
-
*/
|
|
302
|
-
async getCalendar(filter = {}) {
|
|
303
|
-
return getCalendar(filter, this.host(), this.documentRootLocatorFactory());
|
|
304
|
-
}
|
|
185
|
+
async openCalendar() {
|
|
186
|
+
const [isDisabled, hasCalendar] = await parallel(() => [this.isDisabled(), this.hasCalendar()]);
|
|
187
|
+
if (!isDisabled && hasCalendar) {
|
|
188
|
+
return this._openCalendar();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async closeCalendar() {
|
|
192
|
+
if (await this.isCalendarOpen()) {
|
|
193
|
+
await closeCalendar(getCalendarId(this.host()), this.documentRootLocatorFactory());
|
|
194
|
+
await this.forceStabilize();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async hasCalendar() {
|
|
198
|
+
return (await getCalendarId(this.host())) != null;
|
|
199
|
+
}
|
|
200
|
+
async getCalendar(filter = {}) {
|
|
201
|
+
return getCalendar(filter, this.host(), this.documentRootLocatorFactory());
|
|
202
|
+
}
|
|
305
203
|
}
|
|
306
|
-
/** Gets the ID of the calendar that a particular test element can trigger. */
|
|
307
204
|
async function getCalendarId(host) {
|
|
308
|
-
|
|
205
|
+
return (await host).getAttribute('data-mat-calendar');
|
|
309
206
|
}
|
|
310
|
-
/** Closes the calendar with a specific ID. */
|
|
311
207
|
async function closeCalendar(calendarId, documentLocator) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// escape key has multiple functions inside a range picker (either cancel the current range
|
|
315
|
-
// or close the calendar). Since we don't have access to set the ID on the backdrop in all
|
|
316
|
-
// cases, we set a unique class instead which is the same as the calendar's ID and suffixed
|
|
317
|
-
// with `-backdrop`.
|
|
318
|
-
const backdropSelector = `.${await calendarId}-backdrop`;
|
|
319
|
-
return (await documentLocator.locatorFor(backdropSelector)()).click();
|
|
208
|
+
const backdropSelector = `.${await calendarId}-backdrop`;
|
|
209
|
+
return (await documentLocator.locatorFor(backdropSelector)()).click();
|
|
320
210
|
}
|
|
321
|
-
/** Gets the test harness for a calendar associated with a particular host. */
|
|
322
211
|
async function getCalendar(filter, host, documentLocator) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
212
|
+
const calendarId = await getCalendarId(host);
|
|
213
|
+
if (!calendarId) {
|
|
214
|
+
throw Error(`Element is not associated with a calendar`);
|
|
215
|
+
}
|
|
216
|
+
return documentLocator.locatorFor(MatCalendarHarness.with({
|
|
217
|
+
...filter,
|
|
218
|
+
selector: `#${calendarId}`
|
|
219
|
+
}))();
|
|
331
220
|
}
|
|
332
221
|
|
|
333
|
-
/** Harness for interacting with a standard Material datepicker inputs in tests. */
|
|
334
222
|
class MatDatepickerInputHarness extends MatDatepickerInputHarnessBase {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
// This is necessary so that we wait for the closing animation to finish in touch UI mode.
|
|
365
|
-
await this.forceStabilize();
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
/** Whether a calendar is associated with the input. */
|
|
369
|
-
async hasCalendar() {
|
|
370
|
-
return (await getCalendarId(this.host())) != null;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Gets the `MatCalendarHarness` that is associated with the trigger.
|
|
374
|
-
* @param filter Optionally filters which calendar is included.
|
|
375
|
-
*/
|
|
376
|
-
async getCalendar(filter = {}) {
|
|
377
|
-
return getCalendar(filter, this.host(), this.documentRootLocatorFactory());
|
|
378
|
-
}
|
|
223
|
+
static hostSelector = '.mat-datepicker-input';
|
|
224
|
+
static with(options = {}) {
|
|
225
|
+
return getInputPredicate(MatDatepickerInputHarness, options);
|
|
226
|
+
}
|
|
227
|
+
async isCalendarOpen() {
|
|
228
|
+
const host = await this.host();
|
|
229
|
+
return (await host.getAttribute('aria-owns')) != null;
|
|
230
|
+
}
|
|
231
|
+
async openCalendar() {
|
|
232
|
+
const [isDisabled, hasCalendar] = await parallel(() => [this.isDisabled(), this.hasCalendar()]);
|
|
233
|
+
if (!isDisabled && hasCalendar) {
|
|
234
|
+
const host = await this.host();
|
|
235
|
+
return host.sendKeys({
|
|
236
|
+
alt: true
|
|
237
|
+
}, TestKey.DOWN_ARROW);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async closeCalendar() {
|
|
241
|
+
if (await this.isCalendarOpen()) {
|
|
242
|
+
await closeCalendar(getCalendarId(this.host()), this.documentRootLocatorFactory());
|
|
243
|
+
await this.forceStabilize();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async hasCalendar() {
|
|
247
|
+
return (await getCalendarId(this.host())) != null;
|
|
248
|
+
}
|
|
249
|
+
async getCalendar(filter = {}) {
|
|
250
|
+
return getCalendar(filter, this.host(), this.documentRootLocatorFactory());
|
|
251
|
+
}
|
|
379
252
|
}
|
|
380
253
|
|
|
381
|
-
/** Harness for interacting with a standard Material date range start input in tests. */
|
|
382
254
|
class MatStartDateHarness extends MatDatepickerInputHarnessBase {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
* @param options Options for filtering which input instances are considered a match.
|
|
388
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
389
|
-
*/
|
|
390
|
-
static with(options = {}) {
|
|
391
|
-
return getInputPredicate(MatStartDateHarness, options);
|
|
392
|
-
}
|
|
255
|
+
static hostSelector = '.mat-start-date';
|
|
256
|
+
static with(options = {}) {
|
|
257
|
+
return getInputPredicate(MatStartDateHarness, options);
|
|
258
|
+
}
|
|
393
259
|
}
|
|
394
|
-
/** Harness for interacting with a standard Material date range end input in tests. */
|
|
395
260
|
class MatEndDateHarness extends MatDatepickerInputHarnessBase {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* @param options Options for filtering which input instances are considered a match.
|
|
401
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
402
|
-
*/
|
|
403
|
-
static with(options = {}) {
|
|
404
|
-
return getInputPredicate(MatEndDateHarness, options);
|
|
405
|
-
}
|
|
261
|
+
static hostSelector = '.mat-end-date';
|
|
262
|
+
static with(options = {}) {
|
|
263
|
+
return getInputPredicate(MatEndDateHarness, options);
|
|
264
|
+
}
|
|
406
265
|
}
|
|
407
|
-
/** Harness for interacting with a standard Material date range input in tests. */
|
|
408
266
|
class MatDateRangeInputHarness extends DatepickerTriggerHarnessBase {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
else if (hostId) {
|
|
463
|
-
// Finally, search the DOM for a label that points to the host element
|
|
464
|
-
const labelEl = await documentRootLocator.locatorForOptional(`[for="${hostId}"]`)();
|
|
465
|
-
return labelEl ? labelEl.text() : null;
|
|
466
|
-
}
|
|
467
|
-
return null;
|
|
468
|
-
}
|
|
469
|
-
/** Gets the separator text between the values of the two inputs. */
|
|
470
|
-
async getSeparator() {
|
|
471
|
-
return (await this.locatorFor('.mat-date-range-input-separator')()).text();
|
|
472
|
-
}
|
|
473
|
-
/** Gets whether the range input is disabled. */
|
|
474
|
-
async isDisabled() {
|
|
475
|
-
// We consider the input as disabled if both of the sub-inputs are disabled.
|
|
476
|
-
const [startDisabled, endDisabled] = await parallel(() => [
|
|
477
|
-
this.getStartInput().then(input => input.isDisabled()),
|
|
478
|
-
this.getEndInput().then(input => input.isDisabled()),
|
|
479
|
-
]);
|
|
480
|
-
return startDisabled && endDisabled;
|
|
481
|
-
}
|
|
482
|
-
/** Gets whether the range input is required. */
|
|
483
|
-
async isRequired() {
|
|
484
|
-
return (await this.host()).hasClass('mat-date-range-input-required');
|
|
485
|
-
}
|
|
486
|
-
/** Opens the calendar associated with the input. */
|
|
487
|
-
async isCalendarOpen() {
|
|
488
|
-
// `aria-owns` is set on both inputs only if there's an
|
|
489
|
-
// open range picker so we can use it as an indicator.
|
|
490
|
-
const startHost = await (await this.getStartInput()).host();
|
|
491
|
-
return (await startHost.getAttribute('aria-owns')) != null;
|
|
492
|
-
}
|
|
493
|
-
async _openCalendar() {
|
|
494
|
-
// Alt + down arrow is the combination for opening the calendar with the keyboard.
|
|
495
|
-
const startHost = await (await this.getStartInput()).host();
|
|
496
|
-
return startHost.sendKeys({ alt: true }, TestKey.DOWN_ARROW);
|
|
497
|
-
}
|
|
267
|
+
static hostSelector = '.mat-date-range-input';
|
|
268
|
+
static with(options = {}) {
|
|
269
|
+
return new HarnessPredicate(MatDateRangeInputHarness, options).addOption('value', options.value, (harness, value) => HarnessPredicate.stringMatches(harness.getValue(), value)).addOption('label', options.label, (harness, label) => {
|
|
270
|
+
return HarnessPredicate.stringMatches(harness.getLabel(), label);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async getValue() {
|
|
274
|
+
const [start, end, separator] = await parallel(() => [this.getStartInput().then(input => input.getValue()), this.getEndInput().then(input => input.getValue()), this.getSeparator()]);
|
|
275
|
+
return start + `${end ? ` ${separator} ${end}` : ''}`;
|
|
276
|
+
}
|
|
277
|
+
async getStartInput() {
|
|
278
|
+
return this.locatorFor(MatStartDateHarness)();
|
|
279
|
+
}
|
|
280
|
+
async getEndInput() {
|
|
281
|
+
return this.locatorFor(MatEndDateHarness)();
|
|
282
|
+
}
|
|
283
|
+
async getLabel() {
|
|
284
|
+
const documentRootLocator = this.documentRootLocatorFactory();
|
|
285
|
+
const labelId = await (await this.host()).getAttribute('aria-labelledby');
|
|
286
|
+
const labelText = await (await this.host()).getAttribute('aria-label');
|
|
287
|
+
const hostId = await (await this.host()).getAttribute('id');
|
|
288
|
+
if (labelId) {
|
|
289
|
+
const labelEl = await documentRootLocator.locatorForOptional(`[id="${labelId}"]`)();
|
|
290
|
+
return labelEl ? labelEl.text() : null;
|
|
291
|
+
} else if (labelText) {
|
|
292
|
+
return labelText;
|
|
293
|
+
} else if (hostId) {
|
|
294
|
+
const labelEl = await documentRootLocator.locatorForOptional(`[for="${hostId}"]`)();
|
|
295
|
+
return labelEl ? labelEl.text() : null;
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
async getSeparator() {
|
|
300
|
+
return (await this.locatorFor('.mat-date-range-input-separator')()).text();
|
|
301
|
+
}
|
|
302
|
+
async isDisabled() {
|
|
303
|
+
const [startDisabled, endDisabled] = await parallel(() => [this.getStartInput().then(input => input.isDisabled()), this.getEndInput().then(input => input.isDisabled())]);
|
|
304
|
+
return startDisabled && endDisabled;
|
|
305
|
+
}
|
|
306
|
+
async isRequired() {
|
|
307
|
+
return (await this.host()).hasClass('mat-date-range-input-required');
|
|
308
|
+
}
|
|
309
|
+
async isCalendarOpen() {
|
|
310
|
+
const startHost = await (await this.getStartInput()).host();
|
|
311
|
+
return (await startHost.getAttribute('aria-owns')) != null;
|
|
312
|
+
}
|
|
313
|
+
async _openCalendar() {
|
|
314
|
+
const startHost = await (await this.getStartInput()).host();
|
|
315
|
+
return startHost.sendKeys({
|
|
316
|
+
alt: true
|
|
317
|
+
}, TestKey.DOWN_ARROW);
|
|
318
|
+
}
|
|
498
319
|
}
|
|
499
320
|
|
|
500
321
|
export { CalendarView, DatepickerTriggerHarnessBase, MatCalendarCellHarness, MatCalendarHarness, MatDateRangeInputHarness, MatDatepickerInputHarness, MatEndDateHarness, MatStartDateHarness };
|