@skbkontur/playwright-react-ui-components 1.14.1 → 1.14.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseComponentAssertions } from './BaseComponentAssertions';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TextOptions } from '../options';
|
|
3
3
|
import type { DropdownMenu } from '../components';
|
|
4
4
|
export declare class DropdownMenuAssertions extends BaseComponentAssertions {
|
|
5
5
|
private readonly dropdownMenu;
|
|
@@ -12,6 +12,4 @@ export declare class DropdownMenuAssertions extends BaseComponentAssertions {
|
|
|
12
12
|
toContainItems(itemsText: string[], options?: TextOptions): Promise<void>;
|
|
13
13
|
toContainItem(itemText: string, options?: TextOptions): Promise<void>;
|
|
14
14
|
notToContainItem(itemText: string, options?: TextOptions): Promise<void>;
|
|
15
|
-
toBeFocused(options?: FocusedOptions): Promise<void>;
|
|
16
|
-
notToBeFocused(options?: FocusedOptions): Promise<void>;
|
|
17
15
|
}
|
|
@@ -157,30 +157,6 @@ var DropdownMenuAssertions = /** @class */ (function (_super) {
|
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
-
DropdownMenuAssertions.prototype.toBeFocused = function (options) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
-
return __generator(this, function (_a) {
|
|
163
|
-
switch (_a.label) {
|
|
164
|
-
case 0: return [4 /*yield*/, (0, extensions_1.expect)(this.dropdownMenu).toBeFocusedEx(options)];
|
|
165
|
-
case 1:
|
|
166
|
-
_a.sent();
|
|
167
|
-
return [2 /*return*/];
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
DropdownMenuAssertions.prototype.notToBeFocused = function (options) {
|
|
173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
return __generator(this, function (_a) {
|
|
175
|
-
switch (_a.label) {
|
|
176
|
-
case 0: return [4 /*yield*/, (0, extensions_1.expect)(this.dropdownMenu).not.toBeFocusedEx(options)];
|
|
177
|
-
case 1:
|
|
178
|
-
_a.sent();
|
|
179
|
-
return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
160
|
return DropdownMenuAssertions;
|
|
185
161
|
}(BaseComponentAssertions_1.BaseComponentAssertions));
|
|
186
162
|
exports.DropdownMenuAssertions = DropdownMenuAssertions;
|
|
@@ -3,16 +3,15 @@ import type { TooltipType } from '../utils';
|
|
|
3
3
|
import { DropdownMenuAssertions } from '../assertions';
|
|
4
4
|
import { ComponentList } from './ComponentList';
|
|
5
5
|
import { MenuItem } from './MenuItem';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ClickOptions, InnerTextOptions } from '../options';
|
|
7
7
|
import { MenuComponent } from './MenuComponent';
|
|
8
|
-
import {
|
|
8
|
+
import { toItemsElementLocator, toTextElementLocator } from '../matchers/component/LocatorSymbols';
|
|
9
9
|
export declare class DropdownMenu extends MenuComponent {
|
|
10
10
|
readonly rootLocator: Locator;
|
|
11
|
-
readonly
|
|
11
|
+
readonly captionLocator: Locator;
|
|
12
12
|
private readonly portal;
|
|
13
13
|
readonly [toTextElementLocator]: () => Locator;
|
|
14
14
|
readonly [toItemsElementLocator]: () => Promise<Locator>;
|
|
15
|
-
readonly [toFocusableElementLocator]: () => Locator;
|
|
16
15
|
constructor(rootLocator: Locator);
|
|
17
16
|
getText(options?: InnerTextOptions): Promise<string>;
|
|
18
17
|
isMenuOpened(): Promise<boolean>;
|
|
@@ -26,8 +25,6 @@ export declare class DropdownMenu extends MenuComponent {
|
|
|
26
25
|
closedAfterSelect: boolean;
|
|
27
26
|
}): Promise<void>;
|
|
28
27
|
click(options?: ClickOptions): Promise<void>;
|
|
29
|
-
focus(options?: FocusOptions): Promise<void>;
|
|
30
|
-
blur(options?: BlurOptions): Promise<void>;
|
|
31
28
|
getTooltip(type: TooltipType): Promise<import("./Tooltip").Tooltip>;
|
|
32
29
|
/**
|
|
33
30
|
* Возвращает список меню по data-tid'ам из react-ui:
|
|
@@ -50,12 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
var _a, _b
|
|
53
|
+
var _a, _b;
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
55
|
exports.DropdownMenu = void 0;
|
|
56
|
-
var test_1 = require("@playwright/test");
|
|
57
56
|
var react_ui_1 = require("@skbkontur/react-ui");
|
|
58
57
|
var MenuFooter_1 = require("@skbkontur/react-ui/components/MenuFooter");
|
|
58
|
+
var PopupMenu_1 = require("@skbkontur/react-ui/internal/PopupMenu");
|
|
59
59
|
var Portal_1 = require("./Portal");
|
|
60
60
|
var utils_1 = require("../utils");
|
|
61
61
|
var assertions_1 = require("../assertions");
|
|
@@ -69,32 +69,31 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
69
69
|
function DropdownMenu(rootLocator) {
|
|
70
70
|
var _this = _super.call(this, rootLocator) || this;
|
|
71
71
|
_this.rootLocator = rootLocator;
|
|
72
|
-
_this[_a] = function () { return _this.
|
|
72
|
+
_this[_a] = function () { return _this.captionLocator; };
|
|
73
73
|
_this[_b] = function () { return _this.getItemsLocator(); };
|
|
74
|
-
_this
|
|
75
|
-
_this.buttonLocator = rootLocator.locator('button');
|
|
74
|
+
_this.captionLocator = rootLocator.locator((0, dataTidSelector_1.getDataTidSelector)(PopupMenu_1.PopupMenuDataTids.caption));
|
|
76
75
|
_this.portal = new Portal_1.Portal(rootLocator.locator('noscript'));
|
|
77
76
|
return _this;
|
|
78
77
|
}
|
|
79
78
|
DropdownMenu.prototype.getText = function (options) {
|
|
80
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
-
return __generator(this, function (
|
|
82
|
-
switch (
|
|
83
|
-
case 0: return [4 /*yield*/, this.
|
|
84
|
-
case 1: return [2 /*return*/,
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
switch (_c.label) {
|
|
82
|
+
case 0: return [4 /*yield*/, this.captionLocator.innerText(options)];
|
|
83
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
85
84
|
}
|
|
86
85
|
});
|
|
87
86
|
});
|
|
88
87
|
};
|
|
89
88
|
DropdownMenu.prototype.isMenuOpened = function () {
|
|
90
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
return __generator(this, function (
|
|
92
|
-
switch (
|
|
90
|
+
return __generator(this, function (_c) {
|
|
91
|
+
switch (_c.label) {
|
|
93
92
|
case 0: return [4 /*yield*/, this.waitFor()];
|
|
94
93
|
case 1:
|
|
95
|
-
|
|
94
|
+
_c.sent();
|
|
96
95
|
return [4 /*yield*/, this.portal.isVisible()];
|
|
97
|
-
case 2: return [2 /*return*/,
|
|
96
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
99
|
});
|
|
@@ -103,21 +102,21 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
103
102
|
return __awaiter(this, arguments, void 0, function (text, options) {
|
|
104
103
|
var items;
|
|
105
104
|
if (options === void 0) { options = { closedAfterSelect: true }; }
|
|
106
|
-
return __generator(this, function (
|
|
107
|
-
switch (
|
|
105
|
+
return __generator(this, function (_c) {
|
|
106
|
+
switch (_c.label) {
|
|
108
107
|
case 0: return [4 /*yield*/, this.getMenuItemsLocator(text)];
|
|
109
108
|
case 1:
|
|
110
|
-
items =
|
|
109
|
+
items = _c.sent();
|
|
111
110
|
return [4 /*yield*/, items.first().click()];
|
|
112
111
|
case 2:
|
|
113
|
-
|
|
112
|
+
_c.sent();
|
|
114
113
|
if (!options.closedAfterSelect) return [3 /*break*/, 4];
|
|
115
114
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
116
115
|
return [4 /*yield*/, this.portal.expect().toBeHidden()];
|
|
117
116
|
case 3:
|
|
118
117
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
_c.sent();
|
|
119
|
+
_c.label = 4;
|
|
121
120
|
case 4: return [2 /*return*/];
|
|
122
121
|
}
|
|
123
122
|
});
|
|
@@ -127,27 +126,27 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
127
126
|
return __awaiter(this, arguments, void 0, function (dataTid, options) {
|
|
128
127
|
var container, item;
|
|
129
128
|
if (options === void 0) { options = { closedAfterSelect: true }; }
|
|
130
|
-
return __generator(this, function (
|
|
131
|
-
switch (
|
|
129
|
+
return __generator(this, function (_c) {
|
|
130
|
+
switch (_c.label) {
|
|
132
131
|
case 0: return [4 /*yield*/, this.getPortalContainer()];
|
|
133
132
|
case 1:
|
|
134
|
-
container =
|
|
133
|
+
container = _c.sent();
|
|
135
134
|
item = container.locator((0, dataTidSelector_1.getDataTidSelector)(dataTid));
|
|
136
135
|
return [4 /*yield*/, item.count()];
|
|
137
136
|
case 2:
|
|
138
|
-
if ((
|
|
137
|
+
if ((_c.sent()) > 1) {
|
|
139
138
|
throw Error('DataTid должен быть уникальным');
|
|
140
139
|
}
|
|
141
140
|
return [4 /*yield*/, item.click()];
|
|
142
141
|
case 3:
|
|
143
|
-
|
|
142
|
+
_c.sent();
|
|
144
143
|
if (!options.closedAfterSelect) return [3 /*break*/, 5];
|
|
145
144
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
146
145
|
return [4 /*yield*/, this.portal.expect().toBeHidden()];
|
|
147
146
|
case 4:
|
|
148
147
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
_c.sent();
|
|
149
|
+
_c.label = 5;
|
|
151
150
|
case 5: return [2 /*return*/];
|
|
152
151
|
}
|
|
153
152
|
});
|
|
@@ -157,21 +156,21 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
157
156
|
return __awaiter(this, arguments, void 0, function (index, options) {
|
|
158
157
|
var items;
|
|
159
158
|
if (options === void 0) { options = { closedAfterSelect: true }; }
|
|
160
|
-
return __generator(this, function (
|
|
161
|
-
switch (
|
|
159
|
+
return __generator(this, function (_c) {
|
|
160
|
+
switch (_c.label) {
|
|
162
161
|
case 0: return [4 /*yield*/, this.getMenuItemsLocator()];
|
|
163
162
|
case 1:
|
|
164
|
-
items =
|
|
163
|
+
items = _c.sent();
|
|
165
164
|
return [4 /*yield*/, items.nth(index).click()];
|
|
166
165
|
case 2:
|
|
167
|
-
|
|
166
|
+
_c.sent();
|
|
168
167
|
if (!options.closedAfterSelect) return [3 /*break*/, 4];
|
|
169
168
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
170
169
|
return [4 /*yield*/, this.portal.expect().toBeHidden()];
|
|
171
170
|
case 3:
|
|
172
171
|
// note: ожидание закрытия меню, чтобы не было гонок
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
_c.sent();
|
|
173
|
+
_c.label = 4;
|
|
175
174
|
case 4: return [2 /*return*/];
|
|
176
175
|
}
|
|
177
176
|
});
|
|
@@ -179,38 +178,11 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
179
178
|
};
|
|
180
179
|
DropdownMenu.prototype.click = function (options) {
|
|
181
180
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
return __generator(this, function (
|
|
183
|
-
switch (
|
|
184
|
-
case 0: return [4 /*yield*/, this.
|
|
181
|
+
return __generator(this, function (_c) {
|
|
182
|
+
switch (_c.label) {
|
|
183
|
+
case 0: return [4 /*yield*/, this.captionLocator.click(options)];
|
|
185
184
|
case 1:
|
|
186
|
-
|
|
187
|
-
return [2 /*return*/];
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
DropdownMenu.prototype.focus = function (options) {
|
|
193
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
-
return __generator(this, function (_d) {
|
|
195
|
-
switch (_d.label) {
|
|
196
|
-
case 0: return [4 /*yield*/, (0, test_1.expect)(this.buttonLocator).toBeEnabled()];
|
|
197
|
-
case 1:
|
|
198
|
-
_d.sent();
|
|
199
|
-
return [4 /*yield*/, this.buttonLocator.focus(options)];
|
|
200
|
-
case 2:
|
|
201
|
-
_d.sent();
|
|
202
|
-
return [2 /*return*/];
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
DropdownMenu.prototype.blur = function (options) {
|
|
208
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
-
return __generator(this, function (_d) {
|
|
210
|
-
switch (_d.label) {
|
|
211
|
-
case 0: return [4 /*yield*/, this.buttonLocator.blur(options)];
|
|
212
|
-
case 1:
|
|
213
|
-
_d.sent();
|
|
185
|
+
_c.sent();
|
|
214
186
|
return [2 /*return*/];
|
|
215
187
|
}
|
|
216
188
|
});
|
|
@@ -228,14 +200,14 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
228
200
|
DropdownMenu.prototype.getMenuItems = function () {
|
|
229
201
|
return __awaiter(this, void 0, void 0, function () {
|
|
230
202
|
var container;
|
|
231
|
-
return __generator(this, function (
|
|
232
|
-
switch (
|
|
203
|
+
return __generator(this, function (_c) {
|
|
204
|
+
switch (_c.label) {
|
|
233
205
|
case 0: return [4 /*yield*/, this.getPortalContainer()];
|
|
234
206
|
case 1:
|
|
235
|
-
container =
|
|
207
|
+
container = _c.sent();
|
|
236
208
|
return [4 /*yield*/, container.locator((0, dataTidSelector_1.getDataTidSelector)(react_ui_1.SpinnerDataTids.root)).waitFor({ state: 'hidden' })];
|
|
237
209
|
case 2:
|
|
238
|
-
|
|
210
|
+
_c.sent();
|
|
239
211
|
return [2 /*return*/, new ComponentList_1.ComponentList(container, function (locator) {
|
|
240
212
|
return locator
|
|
241
213
|
.locator((0, dataTidSelector_1.getDataTidSelector)(react_ui_1.MenuItemDataTids.root))
|
|
@@ -250,23 +222,23 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
250
222
|
return __awaiter(this, void 0, void 0, function () {
|
|
251
223
|
var items;
|
|
252
224
|
var _this = this;
|
|
253
|
-
return __generator(this, function (
|
|
254
|
-
switch (
|
|
225
|
+
return __generator(this, function (_c) {
|
|
226
|
+
switch (_c.label) {
|
|
255
227
|
case 0: return [4 /*yield*/, this.getMenuItems()];
|
|
256
228
|
case 1:
|
|
257
|
-
items =
|
|
229
|
+
items = _c.sent();
|
|
258
230
|
return [4 /*yield*/, items.getFirstItemByPredicate(function (item) { return __awaiter(_this, void 0, void 0, function () {
|
|
259
231
|
var itemText;
|
|
260
|
-
return __generator(this, function (
|
|
261
|
-
switch (
|
|
232
|
+
return __generator(this, function (_c) {
|
|
233
|
+
switch (_c.label) {
|
|
262
234
|
case 0: return [4 /*yield*/, item.getText()];
|
|
263
235
|
case 1:
|
|
264
|
-
itemText =
|
|
236
|
+
itemText = _c.sent();
|
|
265
237
|
return [2 /*return*/, itemText.toLowerCase() === text.toLowerCase()];
|
|
266
238
|
}
|
|
267
239
|
});
|
|
268
240
|
}); })];
|
|
269
|
-
case 2: return [2 /*return*/,
|
|
241
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
270
242
|
}
|
|
271
243
|
});
|
|
272
244
|
});
|
|
@@ -274,11 +246,11 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
274
246
|
DropdownMenu.prototype.getMenuItemByIndex = function (index) {
|
|
275
247
|
return __awaiter(this, void 0, void 0, function () {
|
|
276
248
|
var items;
|
|
277
|
-
return __generator(this, function (
|
|
278
|
-
switch (
|
|
249
|
+
return __generator(this, function (_c) {
|
|
250
|
+
switch (_c.label) {
|
|
279
251
|
case 0: return [4 /*yield*/, this.getMenuItems()];
|
|
280
252
|
case 1:
|
|
281
|
-
items =
|
|
253
|
+
items = _c.sent();
|
|
282
254
|
return [2 /*return*/, items.getItemByIndex(index)];
|
|
283
255
|
}
|
|
284
256
|
});
|
|
@@ -290,11 +262,11 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
290
262
|
DropdownMenu.prototype.getMenuItemsLocator = function (byText) {
|
|
291
263
|
return __awaiter(this, void 0, void 0, function () {
|
|
292
264
|
var container, items;
|
|
293
|
-
return __generator(this, function (
|
|
294
|
-
switch (
|
|
265
|
+
return __generator(this, function (_c) {
|
|
266
|
+
switch (_c.label) {
|
|
295
267
|
case 0: return [4 /*yield*/, this.getPortalContainer()];
|
|
296
268
|
case 1:
|
|
297
|
-
container =
|
|
269
|
+
container = _c.sent();
|
|
298
270
|
items = container.locator((0, dataTidSelector_1.getDataTidSelector)(react_ui_1.MenuItemDataTids.root));
|
|
299
271
|
return [2 /*return*/, !byText ? items : items.getByText(byText)];
|
|
300
272
|
}
|
|
@@ -303,15 +275,15 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
303
275
|
};
|
|
304
276
|
DropdownMenu.prototype.getPortalContainer = function () {
|
|
305
277
|
return __awaiter(this, void 0, void 0, function () {
|
|
306
|
-
return __generator(this, function (
|
|
307
|
-
switch (
|
|
278
|
+
return __generator(this, function (_c) {
|
|
279
|
+
switch (_c.label) {
|
|
308
280
|
case 0: return [4 /*yield*/, this.isMenuOpened()];
|
|
309
281
|
case 1:
|
|
310
|
-
if (!!(
|
|
311
|
-
return [4 /*yield*/, this.
|
|
282
|
+
if (!!(_c.sent())) return [3 /*break*/, 3];
|
|
283
|
+
return [4 /*yield*/, this.captionLocator.click()];
|
|
312
284
|
case 2:
|
|
313
|
-
|
|
314
|
-
|
|
285
|
+
_c.sent();
|
|
286
|
+
_c.label = 3;
|
|
315
287
|
case 3: return [2 /*return*/, this.portal.getContainer()];
|
|
316
288
|
}
|
|
317
289
|
});
|
|
@@ -320,4 +292,4 @@ var DropdownMenu = /** @class */ (function (_super) {
|
|
|
320
292
|
return DropdownMenu;
|
|
321
293
|
}(MenuComponent_1.MenuComponent));
|
|
322
294
|
exports.DropdownMenu = DropdownMenu;
|
|
323
|
-
_a = LocatorSymbols_1.toTextElementLocator, _b = LocatorSymbols_1.toItemsElementLocator
|
|
295
|
+
_a = LocatorSymbols_1.toTextElementLocator, _b = LocatorSymbols_1.toItemsElementLocator;
|
package/package.json
CHANGED