@fluentui-react-native/tester 0.129.6 → 0.129.8

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.
Files changed (95) hide show
  1. package/CHANGELOG.json +280 -1
  2. package/CHANGELOG.md +57 -2
  3. package/lib/E2E/src/FocusZone/consts.d.ts +3 -2
  4. package/lib/E2E/src/FocusZone/consts.d.ts.map +1 -1
  5. package/lib/E2E/src/FocusZone/consts.js.map +1 -1
  6. package/lib/E2E/src/FocusZone/pages/FocusZonePageObject.d.ts +28 -0
  7. package/lib/E2E/src/FocusZone/pages/FocusZonePageObject.d.ts.map +1 -0
  8. package/lib/E2E/src/FocusZone/pages/FocusZonePageObject.js +189 -0
  9. package/lib/E2E/src/FocusZone/pages/FocusZonePageObject.js.map +1 -0
  10. package/lib/E2E/src/TabsV1/consts.d.ts +7 -2
  11. package/lib/E2E/src/TabsV1/consts.d.ts.map +1 -1
  12. package/lib/E2E/src/TabsV1/consts.js +7 -2
  13. package/lib/E2E/src/TabsV1/consts.js.map +1 -1
  14. package/lib/E2E/src/common/BasePage.d.ts +67 -0
  15. package/lib/E2E/src/common/BasePage.d.ts.map +1 -0
  16. package/lib/E2E/src/common/BasePage.js +654 -0
  17. package/lib/E2E/src/common/BasePage.js.map +1 -0
  18. package/lib/E2E/src/common/consts.d.ts.map +1 -1
  19. package/lib/E2E/src/common/consts.js.map +1 -1
  20. package/lib/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.d.ts.map +1 -1
  21. package/lib/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.js +2 -1
  22. package/lib/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.js.map +1 -1
  23. package/lib/fluent-tester/src/TestComponents/Button/ButtonTest.d.ts.map +1 -1
  24. package/lib/fluent-tester/src/TestComponents/Button/ButtonTest.js +4 -2
  25. package/lib/fluent-tester/src/TestComponents/Button/ButtonTest.js.map +1 -1
  26. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.d.ts +1 -2
  27. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.d.ts.map +1 -1
  28. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.js +1 -22
  29. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.js.map +1 -1
  30. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.d.ts +2 -0
  31. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.d.ts.map +1 -0
  32. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.js +2 -0
  33. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.js.map +1 -0
  34. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.d.ts +3 -0
  35. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.d.ts.map +1 -0
  36. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.js +23 -0
  37. package/lib/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.js.map +1 -0
  38. package/lib/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.d.ts +1 -1
  39. package/lib/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.d.ts.map +1 -1
  40. package/lib/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.js +5 -5
  41. package/lib/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.js.map +1 -1
  42. package/lib/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.d.ts.map +1 -1
  43. package/lib/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.js +7 -7
  44. package/lib/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.js.map +1 -1
  45. package/lib-commonjs/E2E/src/FocusZone/consts.d.ts +3 -2
  46. package/lib-commonjs/E2E/src/FocusZone/consts.d.ts.map +1 -1
  47. package/lib-commonjs/E2E/src/FocusZone/consts.js.map +1 -1
  48. package/lib-commonjs/E2E/src/FocusZone/pages/FocusZonePageObject.d.ts +28 -0
  49. package/lib-commonjs/E2E/src/FocusZone/pages/FocusZonePageObject.d.ts.map +1 -0
  50. package/lib-commonjs/E2E/src/FocusZone/pages/FocusZonePageObject.js +191 -0
  51. package/lib-commonjs/E2E/src/FocusZone/pages/FocusZonePageObject.js.map +1 -0
  52. package/lib-commonjs/E2E/src/TabsV1/consts.d.ts +7 -2
  53. package/lib-commonjs/E2E/src/TabsV1/consts.d.ts.map +1 -1
  54. package/lib-commonjs/E2E/src/TabsV1/consts.js +8 -3
  55. package/lib-commonjs/E2E/src/TabsV1/consts.js.map +1 -1
  56. package/lib-commonjs/E2E/src/common/BasePage.d.ts +67 -0
  57. package/lib-commonjs/E2E/src/common/BasePage.d.ts.map +1 -0
  58. package/lib-commonjs/E2E/src/common/BasePage.js +658 -0
  59. package/lib-commonjs/E2E/src/common/BasePage.js.map +1 -0
  60. package/lib-commonjs/E2E/src/common/consts.d.ts.map +1 -1
  61. package/lib-commonjs/E2E/src/common/consts.js.map +1 -1
  62. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.d.ts.map +1 -1
  63. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.js +2 -1
  64. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonSizeTestSection.js.map +1 -1
  65. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonTest.d.ts.map +1 -1
  66. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonTest.js +4 -2
  67. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonTest.js.map +1 -1
  68. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.d.ts +1 -2
  69. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.d.ts.map +1 -1
  70. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.js +2 -24
  71. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.android.js.map +1 -1
  72. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.d.ts +2 -0
  73. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.d.ts.map +1 -0
  74. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.js +6 -0
  75. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.ios.js.map +1 -0
  76. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.d.ts +3 -0
  77. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.d.ts.map +1 -0
  78. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.js +28 -0
  79. package/lib-commonjs/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.mobile.js.map +1 -0
  80. package/lib-commonjs/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.d.ts +1 -1
  81. package/lib-commonjs/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.d.ts.map +1 -1
  82. package/lib-commonjs/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.js +14 -14
  83. package/lib-commonjs/fluent-tester/src/TestComponents/FocusZone/FocusZoneE2ETest.js.map +1 -1
  84. package/lib-commonjs/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.d.ts.map +1 -1
  85. package/lib-commonjs/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.js +6 -6
  86. package/lib-commonjs/fluent-tester/src/TestComponents/TabsV1/TabsV1E2ETest.js.map +1 -1
  87. package/package.json +33 -33
  88. package/src/TestComponents/Button/ButtonSizeTestSection.tsx +3 -1
  89. package/src/TestComponents/Button/ButtonTest.tsx +4 -2
  90. package/src/TestComponents/Button/ButtonVariantTestSection.android.tsx +1 -45
  91. package/src/TestComponents/Button/ButtonVariantTestSection.ios.tsx +1 -0
  92. package/src/TestComponents/Button/ButtonVariantTestSection.mobile.tsx +45 -0
  93. package/src/TestComponents/FocusZone/FocusZoneE2ETest.tsx +15 -14
  94. package/src/TestComponents/TabsV1/TabsV1E2ETest.tsx +14 -9
  95. package/tsconfig.json +2 -1
@@ -0,0 +1,658 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasePage = exports.By = exports.COMPONENT_SCROLL_COORDINATES = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var consts_1 = require("./consts");
6
+ var consts_2 = require("./consts");
7
+ var DUMMY_CHAR = '';
8
+ // The E2ETEST_PLATFORM environment variable should be set in the beforeSession hook in the wdio.conf file for the respective platform
9
+ var PLATFORM = process.env['E2ETEST_PLATFORM'];
10
+ exports.COMPONENT_SCROLL_COORDINATES = { x: -0, y: -100 }; // These are the offsets. Y is negative because we want the touch to move up (and thus it scrolls down)
11
+ var rootView = null;
12
+ /* Win32/UWP-Specific Selector. We use this to get elements on the test page */
13
+ function By(identifier) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ return tslib_1.__generator(this, function (_a) {
16
+ switch (_a.label) {
17
+ case 0:
18
+ if (!(PLATFORM === 'windows')) return [3 /*break*/, 2];
19
+ return [4 /*yield*/, $('~' + identifier)];
20
+ case 1:
21
+ // For some reason, the rootView node is never put into the element tree on the UWP tester. Remove this when fixed.
22
+ return [2 /*return*/, _a.sent()];
23
+ case 2: return [4 /*yield*/, QueryWithChaining(identifier)];
24
+ case 3: return [2 /*return*/, _a.sent()];
25
+ }
26
+ });
27
+ });
28
+ }
29
+ exports.By = By;
30
+ function QueryWithChaining(identifier) {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
32
+ var selector, queryResult;
33
+ return tslib_1.__generator(this, function (_a) {
34
+ switch (_a.label) {
35
+ case 0:
36
+ if (!(rootView === null)) return [3 /*break*/, 2];
37
+ return [4 /*yield*/, $('~' + consts_1.ROOT_VIEW)];
38
+ case 1:
39
+ // Most of the elements we're searching for will be children of this rootView node.
40
+ rootView = _a.sent();
41
+ _a.label = 2;
42
+ case 2:
43
+ selector = '~' + identifier;
44
+ return [4 /*yield*/, rootView.$(selector)];
45
+ case 3:
46
+ queryResult = _a.sent();
47
+ if (!queryResult.error) return [3 /*break*/, 5];
48
+ return [4 /*yield*/, $(selector)];
49
+ case 4:
50
+ // In some cases, such as opened ContextualMenu items, the element nodes are not children of the rootView node, meaning we need to start our search from the top of the tree.
51
+ queryResult = _a.sent();
52
+ _a.label = 5;
53
+ case 5: return [2 /*return*/, queryResult];
54
+ }
55
+ });
56
+ });
57
+ }
58
+ /****************************** IMPORTANT! PLEASE READ! **************************************************
59
+ * Every component's page object extends this. We can assume each test page will interact with at least
60
+ * two UI elements, so we'll add integration for two UI elements in this file (See *Getters* section below).
61
+ * Every additional UI element that a test page wants to interact with should be handled in that respective
62
+ * component's page object.
63
+ *********************************************************************************************************/
64
+ var BasePage = /** @class */ (function () {
65
+ function BasePage() {
66
+ // Default timeout to wait until page is displayed (10s)
67
+ this.waitForUiEvent = 25000;
68
+ if (PLATFORM) {
69
+ this.platform = PLATFORM;
70
+ }
71
+ }
72
+ /******************************************************************/
73
+ /**************** UI Element Interaction Methods ******************/
74
+ /******************************************************************/
75
+ /**
76
+ * Checks to see if an element attribute is strictly equal to an expected value the user passes in.
77
+ * The advantage to this over testing using .isEqual in a spec is that this throws a detailed error if
78
+ * the expected and actual values don't match. This should be called for attribute tests in specs. */
79
+ BasePage.prototype.compareAttribute = function (element, attribute, expectedValue) {
80
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
81
+ var el, actualValue, _a, _b, _c;
82
+ return tslib_1.__generator(this, function (_d) {
83
+ switch (_d.label) {
84
+ case 0: return [4 /*yield*/, element];
85
+ case 1:
86
+ el = _d.sent();
87
+ return [4 /*yield*/, el.getAttribute(attribute)];
88
+ case 2:
89
+ actualValue = _d.sent();
90
+ if (!(expectedValue !== actualValue)) return [3 /*break*/, 4];
91
+ _a = Error.bind;
92
+ _c = (_b = "On ".concat(this._pageName, ", a test component with a testID = '")).concat;
93
+ return [4 /*yield*/, el.getAttribute("AutomationId" /* Attribute.TestID */)];
94
+ case 3: throw new (_a.apply(Error, [void 0, _c.apply(_b, [_d.sent(), "' should have attribute, "]).concat(consts_2.attributeToEnumName[attribute], " (which maps to windows attribute '").concat(attribute, "' property on the element), equal to '").concat(expectedValue, "'. Instead, ").concat(consts_2.attributeToEnumName[attribute], " is equal to '").concat(actualValue, "'.")]))();
95
+ case 4: return [2 /*return*/, true];
96
+ }
97
+ });
98
+ });
99
+ };
100
+ BasePage.prototype.getAccessibilityRole = function () {
101
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
102
+ var _a;
103
+ return tslib_1.__generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ _a = this.getElementAttribute;
107
+ return [4 /*yield*/, this._primaryComponent];
108
+ case 1: return [4 /*yield*/, _a.apply(this, [_b.sent(), "ControlType" /* Attribute.AccessibilityRole */])];
109
+ case 2: return [2 /*return*/, _b.sent()];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ /* Gets the accessibility label of an UI element given the selector */
115
+ BasePage.prototype.getAccessibilityLabel = function (componentSelector) {
116
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
117
+ var _a, _b, _c;
118
+ return tslib_1.__generator(this, function (_d) {
119
+ switch (_d.label) {
120
+ case 0:
121
+ _a = componentSelector;
122
+ switch (_a) {
123
+ case 'Primary': return [3 /*break*/, 1];
124
+ case 'Secondary': return [3 /*break*/, 4];
125
+ }
126
+ return [3 /*break*/, 7];
127
+ case 1:
128
+ _b = this.getElementAttribute;
129
+ return [4 /*yield*/, this._primaryComponent];
130
+ case 2: return [4 /*yield*/, _b.apply(this, [_d.sent(), "Name" /* Attribute.AccessibilityLabel */])];
131
+ case 3: return [2 /*return*/, _d.sent()];
132
+ case 4:
133
+ _c = this.getElementAttribute;
134
+ return [4 /*yield*/, this._secondaryComponent];
135
+ case 5: return [4 /*yield*/, _c.apply(this, [_d.sent(), "Name" /* Attribute.AccessibilityLabel */])];
136
+ case 6: return [2 /*return*/, _d.sent()];
137
+ case 7: return [2 /*return*/];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ /* Returns true if the test page has loaded. To determine if it's loaded, each test page has a specific UI element we attempt to locate.
143
+ * If this UI element is located, we know the page as loaded correctly. The UI element we look for is a Text component that contains
144
+ * the title of the page (this._testPage returns that UI element) */
145
+ BasePage.prototype.isPageLoaded = function () {
146
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
147
+ var onPage, _a;
148
+ return tslib_1.__generator(this, function (_b) {
149
+ switch (_b.label) {
150
+ case 0: return [4 /*yield*/, this._testPage];
151
+ case 1: return [4 /*yield*/, (_b.sent()).isDisplayed()];
152
+ case 2:
153
+ _a = (_b.sent());
154
+ if (_a) return [3 /*break*/, 5];
155
+ return [4 /*yield*/, this._primaryComponent];
156
+ case 3: return [4 /*yield*/, (_b.sent()).isDisplayed()];
157
+ case 4:
158
+ _a = (_b.sent());
159
+ _b.label = 5;
160
+ case 5:
161
+ onPage = _a;
162
+ return [2 /*return*/, onPage];
163
+ }
164
+ });
165
+ });
166
+ };
167
+ /* Returns true if the test page's button is displayed (the button that navigates to each test page) */
168
+ BasePage.prototype.isButtonInView = function () {
169
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
170
+ return tslib_1.__generator(this, function (_a) {
171
+ switch (_a.label) {
172
+ case 0: return [4 /*yield*/, this._pageButton];
173
+ case 1: return [4 /*yield*/, (_a.sent()).isDisplayed()];
174
+ case 2: return [2 /*return*/, _a.sent()];
175
+ }
176
+ });
177
+ });
178
+ };
179
+ BasePage.prototype.clickComponent = function () {
180
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
181
+ return tslib_1.__generator(this, function (_a) {
182
+ switch (_a.label) {
183
+ case 0: return [4 /*yield*/, this._primaryComponent];
184
+ case 1: return [4 /*yield*/, (_a.sent()).click()];
185
+ case 2:
186
+ _a.sent();
187
+ return [2 /*return*/];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ /* The goal of click() and sendKeys() is to be generally used across all pageobjects to reduce code repetition in similar methods. */
193
+ BasePage.prototype.click = function (element) {
194
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
195
+ return tslib_1.__generator(this, function (_a) {
196
+ switch (_a.label) {
197
+ case 0: return [4 /*yield*/, element];
198
+ case 1: return [4 /*yield*/, (_a.sent()).click()];
199
+ case 2:
200
+ _a.sent();
201
+ return [2 /*return*/];
202
+ }
203
+ });
204
+ });
205
+ };
206
+ BasePage.prototype.sendKeys = function (element, keys) {
207
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
208
+ return tslib_1.__generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0: return [4 /*yield*/, element];
211
+ case 1: return [4 /*yield*/, (_a.sent()).addValue(keys)];
212
+ case 2:
213
+ _a.sent();
214
+ return [2 /*return*/];
215
+ }
216
+ });
217
+ });
218
+ };
219
+ BasePage.prototype.getElementAttribute = function (element, attribute) {
220
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
221
+ return tslib_1.__generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0: return [4 /*yield*/, element.getAttribute(attribute)];
224
+ case 1: return [2 /*return*/, _a.sent()];
225
+ }
226
+ });
227
+ });
228
+ };
229
+ /* Scrolls until the desired test page's button is displayed. We use the scroll viewer UI element as the point to start scrolling.
230
+ * We use a negative number as the Y-coordinate because that enables us to scroll downwards */
231
+ BasePage.prototype.mobileScrollToComponentButton = function () {
232
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
233
+ var errorMsg, _a;
234
+ var _this = this;
235
+ return tslib_1.__generator(this, function (_b) {
236
+ switch (_b.label) {
237
+ case 0: return [4 /*yield*/, this._pageButton];
238
+ case 1: return [4 /*yield*/, (_b.sent()).isDisplayed()];
239
+ case 2:
240
+ if (_b.sent()) {
241
+ return [2 /*return*/];
242
+ }
243
+ errorMsg = 'Could not scroll to the ' + this._pageName + "'s Button. Please see Pipeline artifacts for more debugging information.";
244
+ _a = this.platform;
245
+ switch (_a) {
246
+ case 'ios': return [3 /*break*/, 3];
247
+ case 'android': return [3 /*break*/, 5];
248
+ }
249
+ return [3 /*break*/, 5];
250
+ case 3: return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
251
+ return tslib_1.__generator(this, function (_a) {
252
+ switch (_a.label) {
253
+ case 0: return [4 /*yield*/, driver.execute('mobile: scroll', { direction: 'down' })];
254
+ case 1:
255
+ _a.sent();
256
+ return [4 /*yield*/, this._pageButton];
257
+ case 2: return [4 /*yield*/, (_a.sent()).isDisplayed()];
258
+ case 3: return [2 /*return*/, _a.sent()];
259
+ }
260
+ });
261
+ }); }, {
262
+ timeout: this.waitForUiEvent,
263
+ timeoutMsg: errorMsg,
264
+ })];
265
+ case 4:
266
+ _b.sent();
267
+ return [3 /*break*/, 7];
268
+ case 5:
269
+ /* 'mobile: scroll' which is used for iOS, does not support direction option on Android.
270
+ * Instead, we use the UiScrollable class to scroll down to the desired view based on its 'description' (accessibilityLabel).
271
+ * The first selector tells which container to scroll in, and the other selector tells which component to scroll to. */
272
+ return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
273
+ var buttonElementSelector, pageButton;
274
+ return tslib_1.__generator(this, function (_a) {
275
+ switch (_a.label) {
276
+ case 0:
277
+ buttonElementSelector = "new UiScrollable(new UiSelector().description(\"".concat(consts_2.TESTPAGE_BUTTONS_SCROLLVIEWER, "\").scrollable(true)).setMaxSearchSwipes(10).setAsVerticalList().scrollIntoView(new UiSelector().description(\"").concat(this._pageButtonName, "\"))");
278
+ return [4 /*yield*/, $("android=".concat(buttonElementSelector))];
279
+ case 1:
280
+ pageButton = _a.sent();
281
+ return [4 /*yield*/, pageButton.isDisplayed()];
282
+ case 2: return [2 /*return*/, _a.sent()];
283
+ }
284
+ });
285
+ }); }, {
286
+ timeout: this.waitForUiEvent,
287
+ timeoutMsg: errorMsg,
288
+ })];
289
+ case 6:
290
+ /* 'mobile: scroll' which is used for iOS, does not support direction option on Android.
291
+ * Instead, we use the UiScrollable class to scroll down to the desired view based on its 'description' (accessibilityLabel).
292
+ * The first selector tells which container to scroll in, and the other selector tells which component to scroll to. */
293
+ _b.sent();
294
+ return [3 /*break*/, 7];
295
+ case 7: return [2 /*return*/];
296
+ }
297
+ });
298
+ });
299
+ };
300
+ /* Waits for the test page to load. If the test page doesn't load before the timeout, it causes the test to fail. */
301
+ BasePage.prototype.waitForPageDisplayed = function (timeout) {
302
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
303
+ var _this = this;
304
+ return tslib_1.__generator(this, function (_a) {
305
+ switch (_a.label) {
306
+ case 0: return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
307
+ switch (_a.label) {
308
+ case 0: return [4 /*yield*/, this.isPageLoaded()];
309
+ case 1: return [2 /*return*/, _a.sent()];
310
+ }
311
+ }); }); }, {
312
+ timeout: timeout !== null && timeout !== void 0 ? timeout : this.waitForUiEvent,
313
+ timeoutMsg: this._pageName + ' did not render correctly. Please see /errorShots for more information.',
314
+ interval: 1500,
315
+ })];
316
+ case 1:
317
+ _a.sent();
318
+ return [2 /*return*/];
319
+ }
320
+ });
321
+ });
322
+ };
323
+ /* Waits for the test page's button to be displayed. If the button doesn't load before the timeout, it causes the test to fail. */
324
+ BasePage.prototype.waitForButtonDisplayed = function (timeout) {
325
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
326
+ var _this = this;
327
+ return tslib_1.__generator(this, function (_a) {
328
+ switch (_a.label) {
329
+ case 0: return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
330
+ switch (_a.label) {
331
+ case 0: return [4 /*yield*/, this.isButtonInView()];
332
+ case 1: return [2 /*return*/, _a.sent()];
333
+ }
334
+ }); }); }, {
335
+ timeout: timeout !== null && timeout !== void 0 ? timeout : this.waitForUiEvent,
336
+ timeoutMsg: 'Could not find the button to navigate to ' + this._pageName + '. Please see /errorShots for more information.',
337
+ interval: 1500,
338
+ })];
339
+ case 1:
340
+ _a.sent();
341
+ return [2 /*return*/];
342
+ }
343
+ });
344
+ });
345
+ };
346
+ /* @deprecated, only use `scrollToTestElement()` instead */
347
+ BasePage.prototype.waitForPrimaryElementDisplayed = function (timeout) {
348
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
349
+ var _this = this;
350
+ return tslib_1.__generator(this, function (_a) {
351
+ switch (_a.label) {
352
+ case 0:
353
+ console.warn('`waitForPrimaryElementDisplayed` is deprecated. Only use `scrollToTestElement` in your spec to improve performance.');
354
+ return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
355
+ switch (_a.label) {
356
+ case 0: return [4 /*yield*/, this._primaryComponent];
357
+ case 1: return [4 /*yield*/, (_a.sent()).isDisplayed()];
358
+ case 2: return [2 /*return*/, _a.sent()];
359
+ }
360
+ }); }); }, {
361
+ timeout: timeout !== null && timeout !== void 0 ? timeout : this.waitForUiEvent,
362
+ timeoutMsg: 'The UI element for testing did not display correctly. Please see /errorShots of the first failed test for more information.',
363
+ interval: 1500,
364
+ })];
365
+ case 1:
366
+ _a.sent();
367
+ return [2 /*return*/];
368
+ }
369
+ });
370
+ });
371
+ };
372
+ /* Scrolls to the specified or primary UI test element until it is displayed. */
373
+ BasePage.prototype.scrollToTestElement = function (component) {
374
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
375
+ var ComponentToScrollTo, _a, FocusButton, scrollDownKeys;
376
+ var _this = this;
377
+ return tslib_1.__generator(this, function (_b) {
378
+ switch (_b.label) {
379
+ case 0:
380
+ if (!(component !== null && component !== void 0)) return [3 /*break*/, 1];
381
+ _a = component;
382
+ return [3 /*break*/, 3];
383
+ case 1: return [4 /*yield*/, this._primaryComponent];
384
+ case 2:
385
+ _a = (_b.sent());
386
+ _b.label = 3;
387
+ case 3:
388
+ ComponentToScrollTo = _a;
389
+ return [4 /*yield*/, ComponentToScrollTo.isDisplayed()];
390
+ case 4:
391
+ if (_b.sent()) {
392
+ return [2 /*return*/];
393
+ }
394
+ return [4 /*yield*/, By('Focus_Button')];
395
+ case 5:
396
+ FocusButton = _b.sent();
397
+ scrollDownKeys = ["\uE00F" /* Keys.PAGE_DOWN */];
398
+ return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
399
+ return tslib_1.__generator(this, function (_a) {
400
+ switch (_a.label) {
401
+ case 0: return [4 /*yield*/, FocusButton.addValue(scrollDownKeys)];
402
+ case 1:
403
+ _a.sent();
404
+ scrollDownKeys.push("\uE00F" /* Keys.PAGE_DOWN */);
405
+ return [4 /*yield*/, ComponentToScrollTo.isDisplayed()];
406
+ case 2: return [2 /*return*/, _a.sent()];
407
+ }
408
+ });
409
+ }); }, {
410
+ timeout: 30000,
411
+ timeoutMsg: 'Could not scroll to the ' +
412
+ this._pageName +
413
+ "'s main test element. Please see Pipeline artifacts for more debugging information.",
414
+ })];
415
+ case 6:
416
+ _b.sent();
417
+ // We have this extra scroll here to ensure the whole component is visible.
418
+ return [4 /*yield*/, FocusButton.addValue(scrollDownKeys)];
419
+ case 7:
420
+ // We have this extra scroll here to ensure the whole component is visible.
421
+ _b.sent();
422
+ return [2 /*return*/];
423
+ }
424
+ });
425
+ });
426
+ };
427
+ /* Scrolls to the specified or primary UI test element until it is displayed. */
428
+ BasePage.prototype.mobileScrollToTestElement = function (componentIdentifier) {
429
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
430
+ var componentToScrollTo, errorMsg, _a;
431
+ var _this = this;
432
+ return tslib_1.__generator(this, function (_b) {
433
+ switch (_b.label) {
434
+ case 0:
435
+ componentToScrollTo = componentIdentifier !== null && componentIdentifier !== void 0 ? componentIdentifier : this._primaryComponentName;
436
+ return [4 /*yield*/, By(componentToScrollTo)];
437
+ case 1: return [4 /*yield*/, (_b.sent()).isDisplayed()];
438
+ case 2:
439
+ if (_b.sent()) {
440
+ return [2 /*return*/];
441
+ }
442
+ errorMsg = 'Could not scroll to the ' + componentToScrollTo + '. Please see Pipeline artifacts for more debugging information.';
443
+ _a = this.platform;
444
+ switch (_a) {
445
+ case 'ios': return [3 /*break*/, 3];
446
+ case 'android': return [3 /*break*/, 5];
447
+ }
448
+ return [3 /*break*/, 7];
449
+ case 3: return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
450
+ return tslib_1.__generator(this, function (_a) {
451
+ switch (_a.label) {
452
+ case 0: return [4 /*yield*/, driver.execute('mobile: scroll', { direction: 'down' })];
453
+ case 1:
454
+ _a.sent();
455
+ return [4 /*yield*/, By(componentToScrollTo)];
456
+ case 2: return [4 /*yield*/, (_a.sent()).isDisplayed()];
457
+ case 3: return [2 /*return*/, _a.sent()];
458
+ }
459
+ });
460
+ }); }, {
461
+ timeout: this.waitForUiEvent,
462
+ timeoutMsg: errorMsg,
463
+ })];
464
+ case 4:
465
+ _b.sent();
466
+ return [3 /*break*/, 7];
467
+ case 5:
468
+ /* 'mobile: scroll' which is used for iOS, does not support direction option on Android.
469
+ * Instead, we use the UiScrollable class to scroll down to the desired view based on its 'description' (accessibilityLabel).
470
+ * The first selector tells which container to scroll in, and the other selector tells which component to scroll to. */
471
+ return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
472
+ var componentSelector, component;
473
+ return tslib_1.__generator(this, function (_a) {
474
+ switch (_a.label) {
475
+ case 0:
476
+ componentSelector = "new UiScrollable(new UiSelector().description(\"".concat(consts_1.TESTPAGE_CONTENT_SCROLLVIEWER, "\").scrollable(true)).setMaxSearchSwipes(10).scrollIntoView(new UiSelector().description(\"").concat(componentIdentifier, "\"))");
477
+ return [4 /*yield*/, $("android=".concat(componentSelector))];
478
+ case 1:
479
+ component = _a.sent();
480
+ return [4 /*yield*/, component.isDisplayed()];
481
+ case 2: return [2 /*return*/, _a.sent()];
482
+ }
483
+ });
484
+ }); }, {
485
+ timeout: this.waitForUiEvent,
486
+ timeoutMsg: errorMsg,
487
+ })];
488
+ case 6:
489
+ /* 'mobile: scroll' which is used for iOS, does not support direction option on Android.
490
+ * Instead, we use the UiScrollable class to scroll down to the desired view based on its 'description' (accessibilityLabel).
491
+ * The first selector tells which container to scroll in, and the other selector tells which component to scroll to. */
492
+ _b.sent();
493
+ return [3 /*break*/, 7];
494
+ case 7: return [2 /*return*/];
495
+ }
496
+ });
497
+ });
498
+ };
499
+ /* A method that allows the caller to pass in a condition. A wrapper for waitUntil(). Once testing becomes more extensive,
500
+ * this will allow cleaner code within all the Page Objects. */
501
+ BasePage.prototype.waitForCondition = function (condition, errorMsg, timeout, interval) {
502
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
503
+ var _this = this;
504
+ return tslib_1.__generator(this, function (_a) {
505
+ switch (_a.label) {
506
+ case 0: return [4 /*yield*/, browser.waitUntil(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
507
+ switch (_a.label) {
508
+ case 0: return [4 /*yield*/, condition()];
509
+ case 1: return [2 /*return*/, _a.sent()];
510
+ }
511
+ }); }); }, {
512
+ timeout: timeout !== null && timeout !== void 0 ? timeout : this.waitForUiEvent,
513
+ timeoutMsg: errorMsg !== null && errorMsg !== void 0 ? errorMsg : 'Error. Please see /errorShots and logs for more information.',
514
+ interval: interval !== null && interval !== void 0 ? interval : 1000,
515
+ })];
516
+ case 1:
517
+ _a.sent();
518
+ return [2 /*return*/];
519
+ }
520
+ });
521
+ });
522
+ };
523
+ /* FUNCTIONALITY: Determines if an Assert has fired. True if yes; false otherwise
524
+ *
525
+ * WHY/HOW: Unfortunately, some Asserts don't take focus away from the test app. Because of this, the test execution is able
526
+ * to continue without realizing an assert as popped up (unless the assert is a crashing one).
527
+ *
528
+ * In order to detect an assert, this function gets the number of window handles currently open within the test app.
529
+ * Only one instance SHOULD be open at a time (the app itself). If another instance of the app is open, we know an assert dialogue
530
+ * has popped up. With this information, we know to fail the test.
531
+ *
532
+ * Additionally, you might think it's logical to simply place this in the afterEach() hook so it's called after every test (rather than duplicating this call in every test).
533
+ * Unfortunately, afterEach() is designed for setup/teardown - not for determining if a test should fail or not.
534
+ * */
535
+ BasePage.prototype.didAssertPopup = function () {
536
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
537
+ var windowHandles;
538
+ return tslib_1.__generator(this, function (_a) {
539
+ switch (_a.label) {
540
+ case 0:
541
+ if (!(PLATFORM === 'android')) return [3 /*break*/, 2];
542
+ return [4 /*yield*/, this.isPageLoaded()];
543
+ case 1: return [2 /*return*/, !(_a.sent())];
544
+ case 2: return [4 /*yield*/, browser.getWindowHandles()];
545
+ case 3:
546
+ windowHandles = _a.sent();
547
+ return [2 /*return*/, windowHandles.length > 1];
548
+ }
549
+ });
550
+ });
551
+ };
552
+ Object.defineProperty(BasePage.prototype, "_testPage", {
553
+ /*****************************************/
554
+ /**************** Getters ****************/
555
+ /*****************************************/
556
+ /* IMPORTANT:
557
+ * Each PageObject class that extends this class is expected to override these values.
558
+ * This is necessary because each page will have different IDs for their respective UI elements.
559
+ * DUMMY_CHAR is just a placeholder.
560
+ */
561
+ // Returns: UI Element
562
+ // The Text component on each test page containing the title of that page. We can use this to determine if a test page has loaded correctly.
563
+ get: function () {
564
+ return By(this._pageName);
565
+ },
566
+ enumerable: false,
567
+ configurable: true
568
+ });
569
+ Object.defineProperty(BasePage.prototype, "_primaryComponent", {
570
+ // Returns: UI Element
571
+ // The primary UI element used for testing on the given test page.
572
+ get: function () {
573
+ return By(this._primaryComponentName);
574
+ },
575
+ enumerable: false,
576
+ configurable: true
577
+ });
578
+ Object.defineProperty(BasePage.prototype, "_secondaryComponent", {
579
+ // Returns: UI Element
580
+ // The secondary UI element used for testing on the given test page. Often times, we'll want to set a
581
+ // prop on one component, and not set it on another to verify certain behaviors. This is why we have this secondary component.
582
+ get: function () {
583
+ return By(this._secondaryComponentName);
584
+ },
585
+ enumerable: false,
586
+ configurable: true
587
+ });
588
+ Object.defineProperty(BasePage.prototype, "_pageButton", {
589
+ // Returns: UI Element
590
+ // The button that navigates you to the component's test page.
591
+ get: function () {
592
+ return By(this._pageButtonName);
593
+ },
594
+ enumerable: false,
595
+ configurable: true
596
+ });
597
+ Object.defineProperty(BasePage.prototype, "_primaryComponentName", {
598
+ // Returns: String
599
+ // Returns the identifier of the primary UI element used for testing on the given test page.
600
+ get: function () {
601
+ console.warn('Please verify whether or not your page object should implement _primaryComponentName.');
602
+ return DUMMY_CHAR;
603
+ },
604
+ enumerable: false,
605
+ configurable: true
606
+ });
607
+ Object.defineProperty(BasePage.prototype, "_secondaryComponentName", {
608
+ // Returns: String
609
+ // Returns the identifier of the secondary UI element used for testing on the given test page. Often times, we'll want to set a
610
+ // prop on one component, and not set it on another to verify certain behaviors. This is why we have this secondary component.
611
+ get: function () {
612
+ console.warn('Please verify whether or not your page object should implement _secondaryComponentName.');
613
+ return DUMMY_CHAR;
614
+ },
615
+ enumerable: false,
616
+ configurable: true
617
+ });
618
+ Object.defineProperty(BasePage.prototype, "_testPageButtonScrollViewer", {
619
+ // The scrollviewer containing the list of buttons to navigate to each test page
620
+ get: function () {
621
+ return By(consts_2.TESTPAGE_BUTTONS_SCROLLVIEWER);
622
+ },
623
+ enumerable: false,
624
+ configurable: true
625
+ });
626
+ Object.defineProperty(BasePage.prototype, "ERRORMESSAGE_SUFFIX", {
627
+ /****************** Error Messages ******************/
628
+ get: function () {
629
+ return 'Please review logs and error screenshots for more information.';
630
+ },
631
+ enumerable: false,
632
+ configurable: true
633
+ });
634
+ Object.defineProperty(BasePage.prototype, "ERRORMESSAGE_APPLOAD", {
635
+ get: function () {
636
+ return 'The FluentTester app did not load correctly. ' + this.ERRORMESSAGE_SUFFIX;
637
+ },
638
+ enumerable: false,
639
+ configurable: true
640
+ });
641
+ Object.defineProperty(BasePage.prototype, "ERRORMESSAGE_PAGELOAD", {
642
+ get: function () {
643
+ return 'The ' + this._pageName + ' test page did not load correctly. ' + this.ERRORMESSAGE_SUFFIX;
644
+ },
645
+ enumerable: false,
646
+ configurable: true
647
+ });
648
+ Object.defineProperty(BasePage.prototype, "ERRORMESSAGE_ASSERT", {
649
+ get: function () {
650
+ return 'An assert popped up. ' + this.ERRORMESSAGE_SUFFIX;
651
+ },
652
+ enumerable: false,
653
+ configurable: true
654
+ });
655
+ return BasePage;
656
+ }());
657
+ exports.BasePage = BasePage;
658
+ //# sourceMappingURL=BasePage.js.map