@skbkontur/playwright-react-ui-components 1.18.0-beta.1 → 1.18.0-beta.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.
@@ -0,0 +1,8 @@
1
+ import { BaseComponentAssertions } from './BaseComponentAssertions';
2
+ import type { CurrencyLabel } from '../components';
3
+ import type { CurrencyLabelAssertionOptions } from '../options';
4
+ export declare class CurrencyLabelAssertions extends BaseComponentAssertions {
5
+ private readonly currencyLabel;
6
+ constructor(currencyLabel: CurrencyLabel);
7
+ toHaveValue(value: string | number, assertionOptions?: CurrencyLabelAssertionOptions): Promise<void>;
8
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.CurrencyLabelAssertions = void 0;
55
+ var CurrencyHelper_1 = require("@skbkontur/react-ui/components/CurrencyInput/CurrencyHelper");
56
+ var extensions_1 = require("../extensions");
57
+ var BaseComponentAssertions_1 = require("./BaseComponentAssertions");
58
+ /**
59
+ * Если `assertionOptions` не определен или в нем нет такого `key` - берем значение из `baseOptions`
60
+ * Иначе берем значение `key` из `assertionOptions`
61
+ */
62
+ function pickOption(baseOptions, assertionOptions, key) {
63
+ var _a;
64
+ if (assertionOptions === undefined || !(key in assertionOptions)) {
65
+ return (_a = baseOptions[key]) !== null && _a !== void 0 ? _a : undefined;
66
+ }
67
+ return assertionOptions[key];
68
+ }
69
+ var CurrencyLabelAssertions = /** @class */ (function (_super) {
70
+ __extends(CurrencyLabelAssertions, _super);
71
+ function CurrencyLabelAssertions(currencyLabel) {
72
+ var _this = _super.call(this, currencyLabel) || this;
73
+ _this.currencyLabel = currencyLabel;
74
+ return _this;
75
+ }
76
+ CurrencyLabelAssertions.prototype.toHaveValue = function (value, assertionOptions) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var baseOptions, format, formattedValue, text;
79
+ var _a;
80
+ return __generator(this, function (_b) {
81
+ switch (_b.label) {
82
+ case 0:
83
+ baseOptions = (_a = this.currencyLabel.options) !== null && _a !== void 0 ? _a : {};
84
+ format = {
85
+ currencySymbol: pickOption(baseOptions, assertionOptions, 'currencySymbol'),
86
+ fractionDigits: pickOption(baseOptions, assertionOptions, 'fractionDigits'),
87
+ hideTrailingZeros: pickOption(baseOptions, assertionOptions, 'hideTrailingZeros'),
88
+ };
89
+ formattedValue = typeof value === 'number' ? CurrencyHelper_1.CurrencyHelper.format(value, format) : CurrencyHelper_1.CurrencyHelper.formatString(value, format);
90
+ text = format.currencySymbol ? "".concat(formattedValue, "\u00A0").concat(format.currencySymbol) : formattedValue;
91
+ return [4 /*yield*/, (0, extensions_1.expect)(this.currencyLabel.rootLocator).toHaveText(text, {
92
+ timeout: assertionOptions === null || assertionOptions === void 0 ? void 0 : assertionOptions.timeout,
93
+ })];
94
+ case 1:
95
+ _b.sent();
96
+ return [2 /*return*/];
97
+ }
98
+ });
99
+ });
100
+ };
101
+ return CurrencyLabelAssertions;
102
+ }(BaseComponentAssertions_1.BaseComponentAssertions));
103
+ exports.CurrencyLabelAssertions = CurrencyLabelAssertions;
@@ -11,6 +11,7 @@ export { RadioAssertions } from './RadioAssertions';
11
11
  export { RadioGroupAssertions } from './RadioGroupAssertions';
12
12
  export { InputAssertions } from './InputAssertions';
13
13
  export { CurrencyInputAssertions } from './CurrencyInputAssertions';
14
+ export { CurrencyLabelAssertions } from './CurrencyLabelAssertions';
14
15
  export { TokenAssertions } from './TokenAssertions';
15
16
  export { TokenInputAssertions } from './TokenInputAssertions';
16
17
  export { TextareaAssertions } from './TextareaAssertions';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PagingAssertions = exports.KebabAssertions = exports.FxInputAssertions = exports.FileUploaderAssertions = exports.DateInputAssertions = exports.AutocompleteAssertions = exports.SpinnerAssertions = exports.LoaderAssertions = exports.TabAssertions = exports.TabsAssertions = exports.LinkAssertions = exports.ToggleAssertions = exports.SelectAssertions = exports.ToastAssertions = exports.DropdownAssertions = exports.DropdownMenuAssertions = exports.DateRangePickerAssertions = exports.DatePickerAssertions = exports.TextareaAssertions = exports.TokenInputAssertions = exports.TokenAssertions = exports.CurrencyInputAssertions = exports.InputAssertions = exports.RadioGroupAssertions = exports.RadioAssertions = exports.MenuItemAssertations = exports.LabelAssertions = exports.ComponentListAssertions = exports.ComboBoxAssertions = exports.CheckboxAssertions = exports.TooltipAssertions = exports.PortalAssertions = exports.ButtonAssertions = exports.BaseComponentAssertions = void 0;
3
+ exports.PagingAssertions = exports.KebabAssertions = exports.FxInputAssertions = exports.FileUploaderAssertions = exports.DateInputAssertions = exports.AutocompleteAssertions = exports.SpinnerAssertions = exports.LoaderAssertions = exports.TabAssertions = exports.TabsAssertions = exports.LinkAssertions = exports.ToggleAssertions = exports.SelectAssertions = exports.ToastAssertions = exports.DropdownAssertions = exports.DropdownMenuAssertions = exports.DateRangePickerAssertions = exports.DatePickerAssertions = exports.TextareaAssertions = exports.TokenInputAssertions = exports.TokenAssertions = exports.CurrencyLabelAssertions = exports.CurrencyInputAssertions = exports.InputAssertions = exports.RadioGroupAssertions = exports.RadioAssertions = exports.MenuItemAssertations = exports.LabelAssertions = exports.ComponentListAssertions = exports.ComboBoxAssertions = exports.CheckboxAssertions = exports.TooltipAssertions = exports.PortalAssertions = exports.ButtonAssertions = exports.BaseComponentAssertions = void 0;
4
4
  var BaseComponentAssertions_1 = require("./BaseComponentAssertions");
5
5
  Object.defineProperty(exports, "BaseComponentAssertions", { enumerable: true, get: function () { return BaseComponentAssertions_1.BaseComponentAssertions; } });
6
6
  var ButtonAssertions_1 = require("./ButtonAssertions");
@@ -27,6 +27,8 @@ var InputAssertions_1 = require("./InputAssertions");
27
27
  Object.defineProperty(exports, "InputAssertions", { enumerable: true, get: function () { return InputAssertions_1.InputAssertions; } });
28
28
  var CurrencyInputAssertions_1 = require("./CurrencyInputAssertions");
29
29
  Object.defineProperty(exports, "CurrencyInputAssertions", { enumerable: true, get: function () { return CurrencyInputAssertions_1.CurrencyInputAssertions; } });
30
+ var CurrencyLabelAssertions_1 = require("./CurrencyLabelAssertions");
31
+ Object.defineProperty(exports, "CurrencyLabelAssertions", { enumerable: true, get: function () { return CurrencyLabelAssertions_1.CurrencyLabelAssertions; } });
30
32
  var TokenAssertions_1 = require("./TokenAssertions");
31
33
  Object.defineProperty(exports, "TokenAssertions", { enumerable: true, get: function () { return TokenAssertions_1.TokenAssertions; } });
32
34
  var TokenInputAssertions_1 = require("./TokenInputAssertions");
@@ -2,9 +2,8 @@ import type { Locator, Page } from '@playwright/test';
2
2
  import { BaseComponentAssertions } from '../assertions';
3
3
  import type { ClickOptions, GetAttributeOptions, HoverOptions, IsVisibleOptions, ScrollIntoViewIfNeededOptions, WaitForOptions } from '../options';
4
4
  import { toVisibleElementLocator, toRootElementLocator, toHaveAttributeElementLocator } from '../matchers/component/LocatorSymbols';
5
- import type { Tooltip } from './Tooltip';
6
5
  export declare abstract class BaseComponent {
7
- rootLocator: Locator;
6
+ readonly rootLocator: Locator;
8
7
  readonly page: Page;
9
8
  readonly [toVisibleElementLocator]: () => Locator;
10
9
  readonly [toRootElementLocator]: () => Locator;
@@ -19,6 +18,5 @@ export declare abstract class BaseComponent {
19
18
  waitFor(options?: WaitForOptions): Promise<void>;
20
19
  hasAttribute(name: string, options?: GetAttributeOptions): Promise<boolean>;
21
20
  getAttribute(name: string, options?: GetAttributeOptions): Promise<string | null>;
22
- getTooltipAsync<TTooltip extends Tooltip>(TooltipClass: new (target: BaseComponent) => TTooltip, customId?: string): Promise<TTooltip>;
23
21
  expect(): BaseComponentAssertions;
24
22
  }
@@ -157,21 +157,6 @@ var BaseComponent = /** @class */ (function () {
157
157
  });
158
158
  });
159
159
  };
160
- BaseComponent.prototype.getTooltipAsync = function (TooltipClass, customId) {
161
- return __awaiter(this, void 0, void 0, function () {
162
- var tooltip;
163
- return __generator(this, function (_d) {
164
- switch (_d.label) {
165
- case 0:
166
- tooltip = new TooltipClass(this);
167
- return [4 /*yield*/, tooltip.initAsync(customId)];
168
- case 1:
169
- _d.sent();
170
- return [2 /*return*/, tooltip];
171
- }
172
- });
173
- });
174
- };
175
160
  BaseComponent.prototype.expect = function () {
176
161
  return new assertions_1.BaseComponentAssertions(this);
177
162
  };
@@ -0,0 +1,22 @@
1
+ import type { Locator } from '@playwright/test';
2
+ import { BaseComponent } from './BaseComponent';
3
+ import { CurrencyLabelAssertions } from '../assertions';
4
+ import { type TooltipType } from '../utils';
5
+ import type { GetAttributeOptions, InnerTextOptions } from '../options';
6
+ export type CurrencyLabelOptions = {
7
+ /** Символ валюты */
8
+ currencySymbol?: string;
9
+ /** Минимальное количество отображаемых знаков после запятой */
10
+ fractionDigits?: number;
11
+ /** Убирает лишние нули после запятой */
12
+ hideTrailingZeros?: boolean;
13
+ };
14
+ export declare class CurrencyLabel extends BaseComponent {
15
+ readonly rootLocator: Locator;
16
+ readonly options: CurrencyLabelOptions;
17
+ constructor(rootLocator: Locator, options?: CurrencyLabelOptions);
18
+ isDisabled(options?: GetAttributeOptions): Promise<boolean>;
19
+ getText(options?: InnerTextOptions): Promise<string>;
20
+ getTooltip(type: TooltipType): Promise<import("./Tooltip").Tooltip>;
21
+ expect(): CurrencyLabelAssertions;
22
+ }
@@ -51,57 +51,38 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
51
51
  }
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.ValidationTooltip = void 0;
55
- var Tooltip_1 = require("./Tooltip");
56
- var Portal_1 = require("./Portal");
57
- function isFocusable(value) {
58
- return typeof (value === null || value === void 0 ? void 0 : value.focus) === 'function';
59
- }
60
- var ValidationTooltip = /** @class */ (function (_super) {
61
- __extends(ValidationTooltip, _super);
62
- function ValidationTooltip(targetControl) {
63
- var _this = _super.call(this, targetControl) || this;
64
- _this.portal = new Portal_1.Portal(_this.targetControl.rootLocator.locator('../../noscript'));
54
+ exports.CurrencyLabel = void 0;
55
+ var BaseComponent_1 = require("./BaseComponent");
56
+ var assertions_1 = require("../assertions");
57
+ var utils_1 = require("../utils");
58
+ var CurrencyLabel = /** @class */ (function (_super) {
59
+ __extends(CurrencyLabel, _super);
60
+ function CurrencyLabel(rootLocator, options) {
61
+ if (options === void 0) { options = {}; }
62
+ var _this = _super.call(this, rootLocator) || this;
63
+ _this.rootLocator = rootLocator;
64
+ _this.options = options;
65
65
  return _this;
66
66
  }
67
- ValidationTooltip.prototype.showAsync = function () {
67
+ CurrencyLabel.prototype.isDisabled = function (options) {
68
68
  return __awaiter(this, void 0, void 0, function () {
69
69
  return __generator(this, function (_a) {
70
70
  switch (_a.label) {
71
- case 0: return [4 /*yield*/, this.targetControl.rootLocator.press('Tab')];
72
- case 1:
73
- _a.sent();
74
- if (!isFocusable(this.targetControl)) return [3 /*break*/, 3];
75
- return [4 /*yield*/, this.targetControl.focus()];
76
- case 2:
77
- _a.sent();
78
- return [3 /*break*/, 5];
79
- case 3: return [4 /*yield*/, this.targetControl.rootLocator.focus()];
80
- case 4:
81
- _a.sent();
82
- _a.label = 5;
83
- case 5: return [2 /*return*/];
71
+ case 0: return [4 /*yield*/, this.getAttribute(utils_1.DataVisualState.Disabled, options)];
72
+ case 1: return [2 /*return*/, (_a.sent()) !== null];
84
73
  }
85
74
  });
86
75
  });
87
76
  };
88
- ValidationTooltip.prototype.initAsync = function (customTid) {
89
- return __awaiter(this, void 0, void 0, function () {
90
- return __generator(this, function (_a) {
91
- switch (_a.label) {
92
- case 0: return [4 /*yield*/, this.portal.rootLocator.count()];
93
- case 1:
94
- if ((_a.sent()) > 1) {
95
- this.portal = new Portal_1.Portal(this.targetControl.rootLocator.locator('../following-sibling::noscript[1]'));
96
- }
97
- return [4 /*yield*/, _super.prototype.initAsync.call(this, customTid)];
98
- case 2:
99
- _a.sent();
100
- return [2 /*return*/];
101
- }
102
- });
103
- });
77
+ CurrencyLabel.prototype.getText = function (options) {
78
+ return this.rootLocator.innerText(options);
79
+ };
80
+ CurrencyLabel.prototype.getTooltip = function (type) {
81
+ return (0, utils_1.getTooltip)(type, this);
82
+ };
83
+ CurrencyLabel.prototype.expect = function () {
84
+ return new assertions_1.CurrencyLabelAssertions(this);
104
85
  };
105
- return ValidationTooltip;
106
- }(Tooltip_1.Tooltip));
107
- exports.ValidationTooltip = ValidationTooltip;
86
+ return CurrencyLabel;
87
+ }(BaseComponent_1.BaseComponent));
88
+ exports.CurrencyLabel = CurrencyLabel;
@@ -3,18 +3,20 @@ import { BaseComponent } from './BaseComponent';
3
3
  import { TooltipAssertions } from '../assertions';
4
4
  import type { InnerTextOptions } from '../options';
5
5
  import { toTextElementLocator } from '../matchers/component/LocatorSymbols';
6
- import { Portal } from './Portal';
7
6
  export declare class Tooltip extends BaseComponent {
8
- protected portal: Portal;
9
- protected targetControl: BaseComponent;
7
+ readonly rootLocator: Locator;
8
+ private readonly closeLocator;
9
+ private readonly contentLocator;
10
10
  readonly [toTextElementLocator]: () => Locator;
11
- constructor(targetControl: BaseComponent);
11
+ constructor(rootLocator: Locator);
12
12
  getText(options?: InnerTextOptions): Promise<string>;
13
13
  getContent(): Locator;
14
- get contentLocator(): Locator;
15
- get crossLocator(): Locator;
16
14
  close(): Promise<void>;
17
15
  expect(): TooltipAssertions;
18
- protected showAsync(): Promise<void>;
19
- initAsync(customTid?: string): Promise<void>;
20
16
  }
17
+ /**
18
+ * @deprecated createXXXControl feature for migration from '@skbkontur/react-ui-playwright-controls'
19
+ * Task: IF-2498
20
+ */
21
+ export declare const createTooltipControl: (context: Locator, options?: import("..").DataTIdOption) => Tooltip;
22
+ export type TooltipControl = Tooltip;
@@ -52,24 +52,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  var _a;
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.Tooltip = void 0;
55
+ exports.createTooltipControl = exports.Tooltip = void 0;
56
56
  var Tooltip_1 = require("@skbkontur/react-ui/components/Tooltip");
57
57
  var BaseComponent_1 = require("./BaseComponent");
58
58
  var assertions_1 = require("../assertions");
59
59
  var dataTidSelector_1 = require("../utils/dataTidSelector");
60
60
  var LocatorSymbols_1 = require("../matchers/component/LocatorSymbols");
61
- var Portal_1 = require("./Portal");
61
+ var createComponentFactory_1 = require("../utils/createComponentFactory");
62
62
  var Tooltip = /** @class */ (function (_super) {
63
63
  __extends(Tooltip, _super);
64
- function Tooltip(targetControl) {
65
- var _this = _super.call(this, targetControl.rootLocator) || this;
64
+ function Tooltip(rootLocator) {
65
+ var _this = _super.call(this, rootLocator) || this;
66
+ _this.rootLocator = rootLocator;
66
67
  _this[_a] = function () { return _this.rootLocator; };
67
- var parentContainer = targetControl.rootLocator.locator('xpath=..');
68
- var exactNoscriptLocator = parentContainer.locator('> noscript');
69
- _this.portal = new Portal_1.Portal(exactNoscriptLocator);
70
- var page = targetControl.rootLocator.page();
71
- _this.rootLocator = page.locator("[data-tid='PopupContent']");
72
- _this.targetControl = targetControl;
68
+ _this.contentLocator = rootLocator.locator((0, dataTidSelector_1.getDataTidSelector)(Tooltip_1.TooltipDataTids.content));
69
+ _this.closeLocator = rootLocator.locator((0, dataTidSelector_1.getDataTidSelector)(Tooltip_1.TooltipDataTids.crossIcon));
73
70
  return _this;
74
71
  }
75
72
  Tooltip.prototype.getText = function (options) {
@@ -78,25 +75,11 @@ var Tooltip = /** @class */ (function (_super) {
78
75
  Tooltip.prototype.getContent = function () {
79
76
  return this.contentLocator;
80
77
  };
81
- Object.defineProperty(Tooltip.prototype, "contentLocator", {
82
- get: function () {
83
- return this.rootLocator.locator((0, dataTidSelector_1.getDataTidSelector)(Tooltip_1.TooltipDataTids.content));
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(Tooltip.prototype, "crossLocator", {
89
- get: function () {
90
- return this.rootLocator.locator((0, dataTidSelector_1.getDataTidSelector)(Tooltip_1.TooltipDataTids.crossIcon));
91
- },
92
- enumerable: false,
93
- configurable: true
94
- });
95
78
  Tooltip.prototype.close = function () {
96
79
  return __awaiter(this, void 0, void 0, function () {
97
80
  return __generator(this, function (_b) {
98
81
  switch (_b.label) {
99
- case 0: return [4 /*yield*/, this.crossLocator.click()];
82
+ case 0: return [4 /*yield*/, this.closeLocator.click()];
100
83
  case 1:
101
84
  _b.sent();
102
85
  return [4 /*yield*/, this.waitFor({ state: 'hidden' })];
@@ -110,33 +93,12 @@ var Tooltip = /** @class */ (function (_super) {
110
93
  Tooltip.prototype.expect = function () {
111
94
  return new assertions_1.TooltipAssertions(this);
112
95
  };
113
- Tooltip.prototype.showAsync = function () {
114
- return Promise.resolve();
115
- };
116
- Tooltip.prototype.initAsync = function (customTid) {
117
- return __awaiter(this, void 0, void 0, function () {
118
- var container, page;
119
- return __generator(this, function (_b) {
120
- switch (_b.label) {
121
- case 0: return [4 /*yield*/, this.showAsync()];
122
- case 1:
123
- _b.sent();
124
- if (!(customTid === undefined || customTid === null)) return [3 /*break*/, 3];
125
- return [4 /*yield*/, this.portal.getContainer()];
126
- case 2:
127
- container = _b.sent();
128
- this.rootLocator = container.locator("[data-tid='PopupContent']");
129
- return [3 /*break*/, 4];
130
- case 3:
131
- page = this.targetControl.rootLocator.page();
132
- this.rootLocator = page.locator("[data-tid='".concat(customTid, "']"));
133
- _b.label = 4;
134
- case 4: return [2 /*return*/];
135
- }
136
- });
137
- });
138
- };
139
96
  return Tooltip;
140
97
  }(BaseComponent_1.BaseComponent));
141
98
  exports.Tooltip = Tooltip;
142
99
  _a = LocatorSymbols_1.toTextElementLocator;
100
+ /**
101
+ * @deprecated createXXXControl feature for migration from '@skbkontur/react-ui-playwright-controls'
102
+ * Task: IF-2498
103
+ */
104
+ exports.createTooltipControl = (0, createComponentFactory_1.createComponentTIdFactory)(Tooltip);
@@ -1,14 +1,13 @@
1
1
  export { BaseComponent } from './BaseComponent';
2
2
  export { ComponentList } from './ComponentList';
3
3
  export { MenuComponent } from './MenuComponent';
4
- export { InfoTooltip } from './InfoTooltip';
5
- export { ValidationTooltip } from './ValidationTooltip';
6
- export { Tooltip } from './Tooltip';
7
4
  export { Button, createButtonControl, type ButtonControl } from './Button';
5
+ export { Tooltip, createTooltipControl, type TooltipControl } from './Tooltip';
8
6
  export { Portal, createPortalControl, type PortalControl } from './Portal';
9
7
  export { Checkbox, createCheckboxControl, type CheckboxControl } from './Checkbox';
10
8
  export { ComboBox, createComboBoxControl, type ComboBoxControl } from './ComboBox';
11
9
  export { Label, createLabelControl, type LabelControl } from './Label';
10
+ export { CurrencyLabel } from './CurrencyLabel';
12
11
  export { MenuItem, createMenuItemControl, type MenuItemControl } from './MenuItem';
13
12
  export { Radio, createRadioControl, type RadioControl } from './Radio';
14
13
  export { RadioGroup, createRadioGroupControl, type RadioGroupControl } from './RadioGroup';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTabsControl = exports.Tabs = exports.createLinkControl = exports.Link = exports.createToggleControl = exports.Toggle = exports.createSelectControl = exports.Select = exports.createToastControl = exports.Toast = exports.createDropdownControl = exports.Dropdown = exports.createDropdownMenuControl = exports.DropdownMenu = exports.createTextareaControl = exports.Textarea = exports.createDateRangePickerControl = exports.DateRangePicker = exports.createDatePickerControl = exports.DatePicker = exports.createTokenInputControl = exports.TokenInput = exports.createTokenControl = exports.Token = exports.createCurrencyInputControl = exports.CurrencyInput = exports.createInputControl = exports.Input = exports.createRadioGroupControl = exports.RadioGroup = exports.createRadioControl = exports.Radio = exports.createMenuItemControl = exports.MenuItem = exports.createLabelControl = exports.Label = exports.createComboBoxControl = exports.ComboBox = exports.createCheckboxControl = exports.Checkbox = exports.createPortalControl = exports.Portal = exports.createButtonControl = exports.Button = exports.Tooltip = exports.ValidationTooltip = exports.InfoTooltip = exports.MenuComponent = exports.ComponentList = exports.BaseComponent = void 0;
3
+ exports.createTabsControl = exports.Tabs = exports.createLinkControl = exports.Link = exports.createToggleControl = exports.Toggle = exports.createSelectControl = exports.Select = exports.createToastControl = exports.Toast = exports.createDropdownControl = exports.Dropdown = exports.createDropdownMenuControl = exports.DropdownMenu = exports.createTextareaControl = exports.Textarea = exports.createDateRangePickerControl = exports.DateRangePicker = exports.createDatePickerControl = exports.DatePicker = exports.createTokenInputControl = exports.TokenInput = exports.createTokenControl = exports.Token = exports.createCurrencyInputControl = exports.CurrencyInput = exports.createInputControl = exports.Input = exports.createRadioGroupControl = exports.RadioGroup = exports.createRadioControl = exports.Radio = exports.createMenuItemControl = exports.MenuItem = exports.CurrencyLabel = exports.createLabelControl = exports.Label = exports.createComboBoxControl = exports.ComboBox = exports.createCheckboxControl = exports.Checkbox = exports.createPortalControl = exports.Portal = exports.createTooltipControl = exports.Tooltip = exports.createButtonControl = exports.Button = exports.MenuComponent = exports.ComponentList = exports.BaseComponent = void 0;
4
4
  exports.createPagingControl = exports.Paging = exports.createKebabControl = exports.Kebab = exports.createFxInputControl = exports.FxInput = exports.createFileUploaderControl = exports.FileUploader = exports.createDateInputControl = exports.DateInput = exports.createAutocompleteControl = exports.Autocomplete = exports.createSpinnerControl = exports.Spinner = exports.createLoaderControl = exports.Loader = exports.createTabControl = exports.Tab = void 0;
5
5
  var BaseComponent_1 = require("./BaseComponent");
6
6
  Object.defineProperty(exports, "BaseComponent", { enumerable: true, get: function () { return BaseComponent_1.BaseComponent; } });
@@ -8,15 +8,12 @@ var ComponentList_1 = require("./ComponentList");
8
8
  Object.defineProperty(exports, "ComponentList", { enumerable: true, get: function () { return ComponentList_1.ComponentList; } });
9
9
  var MenuComponent_1 = require("./MenuComponent");
10
10
  Object.defineProperty(exports, "MenuComponent", { enumerable: true, get: function () { return MenuComponent_1.MenuComponent; } });
11
- var InfoTooltip_1 = require("./InfoTooltip");
12
- Object.defineProperty(exports, "InfoTooltip", { enumerable: true, get: function () { return InfoTooltip_1.InfoTooltip; } });
13
- var ValidationTooltip_1 = require("./ValidationTooltip");
14
- Object.defineProperty(exports, "ValidationTooltip", { enumerable: true, get: function () { return ValidationTooltip_1.ValidationTooltip; } });
15
- var Tooltip_1 = require("./Tooltip");
16
- Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return Tooltip_1.Tooltip; } });
17
11
  var Button_1 = require("./Button");
18
12
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
19
13
  Object.defineProperty(exports, "createButtonControl", { enumerable: true, get: function () { return Button_1.createButtonControl; } });
14
+ var Tooltip_1 = require("./Tooltip");
15
+ Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return Tooltip_1.Tooltip; } });
16
+ Object.defineProperty(exports, "createTooltipControl", { enumerable: true, get: function () { return Tooltip_1.createTooltipControl; } });
20
17
  var Portal_1 = require("./Portal");
21
18
  Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return Portal_1.Portal; } });
22
19
  Object.defineProperty(exports, "createPortalControl", { enumerable: true, get: function () { return Portal_1.createPortalControl; } });
@@ -29,6 +26,8 @@ Object.defineProperty(exports, "createComboBoxControl", { enumerable: true, get:
29
26
  var Label_1 = require("./Label");
30
27
  Object.defineProperty(exports, "Label", { enumerable: true, get: function () { return Label_1.Label; } });
31
28
  Object.defineProperty(exports, "createLabelControl", { enumerable: true, get: function () { return Label_1.createLabelControl; } });
29
+ var CurrencyLabel_1 = require("./CurrencyLabel");
30
+ Object.defineProperty(exports, "CurrencyLabel", { enumerable: true, get: function () { return CurrencyLabel_1.CurrencyLabel; } });
32
31
  var MenuItem_1 = require("./MenuItem");
33
32
  Object.defineProperty(exports, "MenuItem", { enumerable: true, get: function () { return MenuItem_1.MenuItem; } });
34
33
  Object.defineProperty(exports, "createMenuItemControl", { enumerable: true, get: function () { return MenuItem_1.createMenuItemControl; } });
@@ -1,3 +1,3 @@
1
1
  import type { AttributeOptions, EnabledOptions } from '../../options';
2
2
  import type { ControlElementLocator } from './LocatorSymbols';
3
- export declare const toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: ControlElementLocator, args_0?: EnabledOptions | AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
3
+ export declare const toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: ControlElementLocator, args_0?: AttributeOptions | EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
@@ -3,7 +3,7 @@ declare const matchers: {
3
3
  readonly toBeVisible: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").VisibleElementLocator, args_0?: import("..").VisibleOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
4
4
  readonly toBeHidden: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").VisibleElementLocator, args_0?: import("..").HiddenOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
5
5
  readonly toBeEnabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
6
- readonly toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
6
+ readonly toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").AttributeOptions | import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
7
7
  readonly toBeFocused: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToBeFocusableElementLocator, args_0?: import("..").FocusedOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
8
8
  readonly toBeChecked: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToBeCheckableElementLocator, args_0?: import("..").CheckedOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
9
9
  readonly toBeAutoMode: (this: import("@playwright/test").ExpectMatcherState, component: import("..").FxInput, args_0?: import("..").VisibleOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
@@ -72,7 +72,7 @@ declare const matchers: {
72
72
  * @deprecated will be removed in the next major version
73
73
  * @see {@link toBeDisabled}
74
74
  */
75
- readonly toBeDisabledEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
75
+ readonly toBeDisabledEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").AttributeOptions | import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
76
76
  /**
77
77
  * @deprecated will be removed in the next major version
78
78
  * @see {@link toBeFocused}
@@ -133,7 +133,7 @@ export declare const componentMatchers: import("@playwright/test").Expect<{
133
133
  readonly toBeVisible: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").VisibleElementLocator, args_0?: import("..").VisibleOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
134
134
  readonly toBeHidden: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").VisibleElementLocator, args_0?: import("..").HiddenOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
135
135
  readonly toBeEnabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
136
- readonly toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
136
+ readonly toBeDisabled: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").AttributeOptions | import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
137
137
  readonly toBeFocused: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToBeFocusableElementLocator, args_0?: import("..").FocusedOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
138
138
  readonly toBeChecked: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToBeCheckableElementLocator, args_0?: import("..").CheckedOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
139
139
  readonly toBeAutoMode: (this: import("@playwright/test").ExpectMatcherState, component: import("..").FxInput, args_0?: import("..").VisibleOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
@@ -202,7 +202,7 @@ export declare const componentMatchers: import("@playwright/test").Expect<{
202
202
  * @deprecated will be removed in the next major version
203
203
  * @see {@link toBeDisabled}
204
204
  */
205
- readonly toBeDisabledEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").EnabledOptions | import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
205
+ readonly toBeDisabledEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ControlElementLocator, args_0?: import("..").AttributeOptions | import("..").EnabledOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
206
206
  /**
207
207
  * @deprecated will be removed in the next major version
208
208
  * @see {@link toBeFocused}
@@ -1,3 +1,4 @@
1
+ import type { CurrencyLabelOptions } from '../components/CurrencyLabel';
1
2
  export type VisibleOptions = {
2
3
  /**
3
4
  * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
@@ -80,3 +81,10 @@ export type TransformOptions = {
80
81
  */
81
82
  timeout?: number;
82
83
  };
84
+ export type CurrencyLabelAssertionOptions = CurrencyLabelOptions & {
85
+ /**
86
+ * Time to retry the assertion for in milliseconds.
87
+ * Defaults to `timeout` in TestConfig.expect.
88
+ */
89
+ timeout?: number;
90
+ };
@@ -1,4 +1,4 @@
1
- import type { Tooltip } from '../components';
1
+ import { Tooltip } from '../components';
2
2
  import type { BaseComponent } from '../components';
3
3
  import { TooltipType } from './constants';
4
4
  export declare function getTooltip(type: TooltipType, component: BaseComponent): Promise<Tooltip>;
@@ -37,29 +37,58 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getTooltip = getTooltip;
40
- var InfoTooltip_1 = require("../components/InfoTooltip");
41
- var ValidationTooltip_1 = require("../components/ValidationTooltip");
40
+ var Popup_1 = require("@skbkontur/react-ui/internal/Popup");
41
+ var components_1 = require("../components");
42
+ var components_2 = require("../components");
42
43
  var constants_1 = require("./constants");
44
+ var dataTidSelector_1 = require("./dataTidSelector");
45
+ function isFocusable(value) {
46
+ return typeof (value === null || value === void 0 ? void 0 : value.focus) === 'function';
47
+ }
43
48
  function getTooltip(type, component) {
44
49
  return __awaiter(this, void 0, void 0, function () {
45
- var tooltip;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
50
+ var portal, _a, locator, container;
51
+ return __generator(this, function (_b) {
52
+ switch (_b.label) {
48
53
  case 0:
49
- switch (type) {
50
- case constants_1.TooltipType.Validation:
51
- tooltip = new ValidationTooltip_1.ValidationTooltip(component);
52
- break;
53
- case constants_1.TooltipType.Information:
54
- tooltip = new InfoTooltip_1.InfoTooltip(component);
55
- break;
56
- default:
57
- throw new Error("\u041F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u0443\u043C\u0435\u0435\u0442 \u0440\u0430\u0431\u043E\u0442\u0430\u0442\u044C \u0441 \u0442\u0438\u043F\u043E\u043C \u0442\u0443\u043B\u0442\u0438\u043F\u0430: ".concat(type));
54
+ _a = type;
55
+ switch (_a) {
56
+ case constants_1.TooltipType.Validation: return [3 /*break*/, 1];
57
+ case constants_1.TooltipType.Information: return [3 /*break*/, 8];
58
+ }
59
+ return [3 /*break*/, 9];
60
+ case 1: return [4 /*yield*/, component.rootLocator.press('Tab')];
61
+ case 2:
62
+ _b.sent();
63
+ if (!isFocusable(component)) return [3 /*break*/, 4];
64
+ return [4 /*yield*/, component.focus()];
65
+ case 3:
66
+ _b.sent();
67
+ return [3 /*break*/, 6];
68
+ case 4: return [4 /*yield*/, component.rootLocator.focus()];
69
+ case 5:
70
+ _b.sent();
71
+ _b.label = 6;
72
+ case 6:
73
+ locator = component.rootLocator.locator('../../noscript');
74
+ return [4 /*yield*/, locator.count()];
75
+ case 7:
76
+ if ((_b.sent()) > 1) {
77
+ locator = component.rootLocator.locator('../following-sibling::noscript[1]');
78
+ }
79
+ portal = new components_1.Portal(locator);
80
+ return [3 /*break*/, 10];
81
+ case 8:
82
+ {
83
+ portal = new components_1.Portal(component.rootLocator.locator('../noscript'));
84
+ return [3 /*break*/, 10];
58
85
  }
59
- return [4 /*yield*/, tooltip.initAsync()];
60
- case 1:
61
- _a.sent();
62
- return [2 /*return*/, tooltip];
86
+ _b.label = 9;
87
+ case 9: throw new Error("Unknown tooltip type: ".concat(type));
88
+ case 10: return [4 /*yield*/, portal.getContainer()];
89
+ case 11:
90
+ container = _b.sent();
91
+ return [2 /*return*/, new components_2.Tooltip(container.locator((0, dataTidSelector_1.getDataTidSelector)(Popup_1.PopupDataTids.content)))];
63
92
  }
64
93
  });
65
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/playwright-react-ui-components",
3
- "version": "1.18.0-beta.1",
3
+ "version": "1.18.0-beta.2",
4
4
  "description": "Пакет для взаимодействия с компонентами @skbkontur/react-ui при тестировании с помощью Playwright",
5
5
  "main": "build/index.js",
6
6
  "files": [
@@ -1,6 +0,0 @@
1
- import type { BaseComponent } from './BaseComponent';
2
- import { Tooltip } from './Tooltip';
3
- export declare class InfoTooltip extends Tooltip {
4
- constructor(targetControl: BaseComponent);
5
- protected showAsync(): Promise<void>;
6
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.InfoTooltip = void 0;
19
- var Tooltip_1 = require("./Tooltip");
20
- var InfoTooltip = /** @class */ (function (_super) {
21
- __extends(InfoTooltip, _super);
22
- function InfoTooltip(targetControl) {
23
- return _super.call(this, targetControl) || this;
24
- }
25
- InfoTooltip.prototype.showAsync = function () {
26
- return Promise.resolve();
27
- };
28
- return InfoTooltip;
29
- }(Tooltip_1.Tooltip));
30
- exports.InfoTooltip = InfoTooltip;
@@ -1,7 +0,0 @@
1
- import type { BaseComponent } from './BaseComponent';
2
- import { Tooltip } from './Tooltip';
3
- export declare class ValidationTooltip extends Tooltip {
4
- constructor(targetControl: BaseComponent);
5
- protected showAsync(): Promise<void>;
6
- initAsync(customTid?: string): Promise<void>;
7
- }