source: trip-planner-front/node_modules/@angular/cdk/esm2015/testing/harness-environment.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 35.1 KB
Line 
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 */
8import { __awaiter } from "tslib";
9import { parallel } from './change-detection';
10import { ComponentHarness, HarnessPredicate, } from './component-harness';
11/**
12 * Base harness environment class that can be extended to allow `ComponentHarness`es to be used in
13 * different test environments (e.g. testbed, protractor, etc.). This class implements the
14 * functionality of both a `HarnessLoader` and `LocatorFactory`. This class is generic on the raw
15 * element type, `E`, used by the particular test environment.
16 */
17export class HarnessEnvironment {
18 constructor(rawRootElement) {
19 this.rawRootElement = rawRootElement;
20 this.rootElement = this.createTestElement(rawRootElement);
21 }
22 // Implemented as part of the `LocatorFactory` interface.
23 documentRootLocatorFactory() {
24 return this.createEnvironment(this.getDocumentRoot());
25 }
26 // Implemented as part of the `LocatorFactory` interface.
27 locatorFor(...queries) {
28 return () => _assertResultFound(this._getAllHarnessesAndTestElements(queries), _getDescriptionForLocatorForQueries(queries));
29 }
30 // Implemented as part of the `LocatorFactory` interface.
31 locatorForOptional(...queries) {
32 return () => __awaiter(this, void 0, void 0, function* () { return (yield this._getAllHarnessesAndTestElements(queries))[0] || null; });
33 }
34 // Implemented as part of the `LocatorFactory` interface.
35 locatorForAll(...queries) {
36 return () => this._getAllHarnessesAndTestElements(queries);
37 }
38 // Implemented as part of the `LocatorFactory` interface.
39 rootHarnessLoader() {
40 return __awaiter(this, void 0, void 0, function* () {
41 return this;
42 });
43 }
44 // Implemented as part of the `LocatorFactory` interface.
45 harnessLoaderFor(selector) {
46 return __awaiter(this, void 0, void 0, function* () {
47 return this.createEnvironment(yield _assertResultFound(this.getAllRawElements(selector), [_getDescriptionForHarnessLoaderQuery(selector)]));
48 });
49 }
50 // Implemented as part of the `LocatorFactory` interface.
51 harnessLoaderForOptional(selector) {
52 return __awaiter(this, void 0, void 0, function* () {
53 const elements = yield this.getAllRawElements(selector);
54 return elements[0] ? this.createEnvironment(elements[0]) : null;
55 });
56 }
57 // Implemented as part of the `LocatorFactory` interface.
58 harnessLoaderForAll(selector) {
59 return __awaiter(this, void 0, void 0, function* () {
60 const elements = yield this.getAllRawElements(selector);
61 return elements.map(element => this.createEnvironment(element));
62 });
63 }
64 // Implemented as part of the `HarnessLoader` interface.
65 getHarness(query) {
66 return this.locatorFor(query)();
67 }
68 // Implemented as part of the `HarnessLoader` interface.
69 getAllHarnesses(query) {
70 return this.locatorForAll(query)();
71 }
72 // Implemented as part of the `HarnessLoader` interface.
73 getChildLoader(selector) {
74 return __awaiter(this, void 0, void 0, function* () {
75 return this.createEnvironment(yield _assertResultFound(this.getAllRawElements(selector), [_getDescriptionForHarnessLoaderQuery(selector)]));
76 });
77 }
78 // Implemented as part of the `HarnessLoader` interface.
79 getAllChildLoaders(selector) {
80 return __awaiter(this, void 0, void 0, function* () {
81 return (yield this.getAllRawElements(selector)).map(e => this.createEnvironment(e));
82 });
83 }
84 /** Creates a `ComponentHarness` for the given harness type with the given raw host element. */
85 createComponentHarness(harnessType, element) {
86 return new harnessType(this.createEnvironment(element));
87 }
88 /**
89 * Matches the given raw elements with the given list of element and harness queries to produce a
90 * list of matched harnesses and test elements.
91 */
92 _getAllHarnessesAndTestElements(queries) {
93 return __awaiter(this, void 0, void 0, function* () {
94 const { allQueries, harnessQueries, elementQueries, harnessTypes } = _parseQueries(queries);
95 // Combine all of the queries into one large comma-delimited selector and use it to get all raw
96 // elements matching any of the individual queries.
97 const rawElements = yield this.getAllRawElements([...elementQueries, ...harnessQueries.map(predicate => predicate.getSelector())].join(','));
98 // If every query is searching for the same harness subclass, we know every result corresponds
99 // to an instance of that subclass. Likewise, if every query is for a `TestElement`, we know
100 // every result corresponds to a `TestElement`. Otherwise we need to verify which result was
101 // found by which selector so it can be matched to the appropriate instance.
102 const skipSelectorCheck = (elementQueries.length === 0 && harnessTypes.size === 1) ||
103 harnessQueries.length === 0;
104 const perElementMatches = yield parallel(() => rawElements.map((rawElement) => __awaiter(this, void 0, void 0, function* () {
105 const testElement = this.createTestElement(rawElement);
106 const allResultsForElement = yield parallel(
107 // For each query, get `null` if it doesn't match, or a `TestElement` or
108 // `ComponentHarness` as appropriate if it does match. This gives us everything that
109 // matches the current raw element, but it may contain duplicate entries (e.g.
110 // multiple `TestElement` or multiple `ComponentHarness` of the same type).
111 () => allQueries.map(query => this._getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck)));
112 return _removeDuplicateQueryResults(allResultsForElement);
113 })));
114 return [].concat(...perElementMatches);
115 });
116 }
117 /**
118 * Check whether the given query matches the given element, if it does return the matched
119 * `TestElement` or `ComponentHarness`, if it does not, return null. In cases where the caller
120 * knows for sure that the query matches the element's selector, `skipSelectorCheck` can be used
121 * to skip verification and optimize performance.
122 */
123 _getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck = false) {
124 return __awaiter(this, void 0, void 0, function* () {
125 if (typeof query === 'string') {
126 return ((skipSelectorCheck || (yield testElement.matchesSelector(query))) ? testElement : null);
127 }
128 if (skipSelectorCheck || (yield testElement.matchesSelector(query.getSelector()))) {
129 const harness = this.createComponentHarness(query.harnessType, rawElement);
130 return (yield query.evaluate(harness)) ? harness : null;
131 }
132 return null;
133 });
134 }
135}
136/**
137 * Parses a list of queries in the format accepted by the `locatorFor*` methods into an easier to
138 * work with format.
139 */
140function _parseQueries(queries) {
141 const allQueries = [];
142 const harnessQueries = [];
143 const elementQueries = [];
144 const harnessTypes = new Set();
145 for (const query of queries) {
146 if (typeof query === 'string') {
147 allQueries.push(query);
148 elementQueries.push(query);
149 }
150 else {
151 const predicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
152 allQueries.push(predicate);
153 harnessQueries.push(predicate);
154 harnessTypes.add(predicate.harnessType);
155 }
156 }
157 return { allQueries, harnessQueries, elementQueries, harnessTypes };
158}
159/**
160 * Removes duplicate query results for a particular element. (e.g. multiple `TestElement`
161 * instances or multiple instances of the same `ComponentHarness` class.
162 */
163function _removeDuplicateQueryResults(results) {
164 return __awaiter(this, void 0, void 0, function* () {
165 let testElementMatched = false;
166 let matchedHarnessTypes = new Set();
167 const dedupedMatches = [];
168 for (const result of results) {
169 if (!result) {
170 continue;
171 }
172 if (result instanceof ComponentHarness) {
173 if (!matchedHarnessTypes.has(result.constructor)) {
174 matchedHarnessTypes.add(result.constructor);
175 dedupedMatches.push(result);
176 }
177 }
178 else if (!testElementMatched) {
179 testElementMatched = true;
180 dedupedMatches.push(result);
181 }
182 }
183 return dedupedMatches;
184 });
185}
186/** Verifies that there is at least one result in an array. */
187function _assertResultFound(results, queryDescriptions) {
188 return __awaiter(this, void 0, void 0, function* () {
189 const result = (yield results)[0];
190 if (result == undefined) {
191 throw Error(`Failed to find element matching one of the following queries:\n` +
192 queryDescriptions.map(desc => `(${desc})`).join(',\n'));
193 }
194 return result;
195 });
196}
197/** Gets a list of description strings from a list of queries. */
198function _getDescriptionForLocatorForQueries(queries) {
199 return queries.map(query => typeof query === 'string' ?
200 _getDescriptionForTestElementQuery(query) : _getDescriptionForComponentHarnessQuery(query));
201}
202/** Gets a description string for a `ComponentHarness` query. */
203function _getDescriptionForComponentHarnessQuery(query) {
204 const harnessPredicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
205 const { name, hostSelector } = harnessPredicate.harnessType;
206 const description = `${name} with host element matching selector: "${hostSelector}"`;
207 const constraints = harnessPredicate.getDescription();
208 return description + (constraints ?
209 ` satisfying the constraints: ${harnessPredicate.getDescription()}` : '');
210}
211/** Gets a description string for a `TestElement` query. */
212function _getDescriptionForTestElementQuery(selector) {
213 return `TestElement for element matching selector: "${selector}"`;
214}
215/** Gets a description string for a `HarnessLoader` query. */
216function _getDescriptionForHarnessLoaderQuery(selector) {
217 return `HarnessLoader for element matching selector: "${selector}"`;
218}
219//# sour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