@skbkontur/playwright-react-ui-components 1.18.0-beta.2 → 1.18.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/assertions/CurrencyLabelAssertions.js +3 -20
- package/build/src/components/CurrencyLabel.d.ts +2 -0
- package/build/src/components/CurrencyLabel.js +7 -3
- package/build/src/matchers/component/toHaveValue.d.ts +2 -2
- package/build/src/matchers/component/toHaveValue.js +34 -12
- package/build/src/matchers/componentMatchers.d.ts +4 -4
- package/build/src/utils/currencyLabel.d.ts +3 -0
- package/build/src/utils/currencyLabel.js +24 -0
- package/package.json +1 -1
|
@@ -52,20 +52,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
exports.CurrencyLabelAssertions = void 0;
|
|
55
|
-
var CurrencyHelper_1 = require("@skbkontur/react-ui/components/CurrencyInput/CurrencyHelper");
|
|
56
55
|
var extensions_1 = require("../extensions");
|
|
57
56
|
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
|
-
}
|
|
57
|
+
var currencyLabel_1 = require("../utils/currencyLabel");
|
|
69
58
|
var CurrencyLabelAssertions = /** @class */ (function (_super) {
|
|
70
59
|
__extends(CurrencyLabelAssertions, _super);
|
|
71
60
|
function CurrencyLabelAssertions(currencyLabel) {
|
|
@@ -75,19 +64,13 @@ var CurrencyLabelAssertions = /** @class */ (function (_super) {
|
|
|
75
64
|
}
|
|
76
65
|
CurrencyLabelAssertions.prototype.toHaveValue = function (value, assertionOptions) {
|
|
77
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var baseOptions,
|
|
67
|
+
var baseOptions, text;
|
|
79
68
|
var _a;
|
|
80
69
|
return __generator(this, function (_b) {
|
|
81
70
|
switch (_b.label) {
|
|
82
71
|
case 0:
|
|
83
72
|
baseOptions = (_a = this.currencyLabel.options) !== null && _a !== void 0 ? _a : {};
|
|
84
|
-
|
|
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;
|
|
73
|
+
text = (0, currencyLabel_1.getCurrencyLabelExpectedText)(value, baseOptions, assertionOptions);
|
|
91
74
|
return [4 /*yield*/, (0, extensions_1.expect)(this.currencyLabel.rootLocator).toHaveText(text, {
|
|
92
75
|
timeout: assertionOptions === null || assertionOptions === void 0 ? void 0 : assertionOptions.timeout,
|
|
93
76
|
})];
|
|
@@ -3,6 +3,7 @@ import { BaseComponent } from './BaseComponent';
|
|
|
3
3
|
import { CurrencyLabelAssertions } from '../assertions';
|
|
4
4
|
import { type TooltipType } from '../utils';
|
|
5
5
|
import type { GetAttributeOptions, InnerTextOptions } from '../options';
|
|
6
|
+
import { toValueElementLocator } from '../matchers/component/LocatorSymbols';
|
|
6
7
|
export type CurrencyLabelOptions = {
|
|
7
8
|
/** Символ валюты */
|
|
8
9
|
currencySymbol?: string;
|
|
@@ -14,6 +15,7 @@ export type CurrencyLabelOptions = {
|
|
|
14
15
|
export declare class CurrencyLabel extends BaseComponent {
|
|
15
16
|
readonly rootLocator: Locator;
|
|
16
17
|
readonly options: CurrencyLabelOptions;
|
|
18
|
+
readonly [toValueElementLocator]: () => Locator;
|
|
17
19
|
constructor(rootLocator: Locator, options?: CurrencyLabelOptions);
|
|
18
20
|
isDisabled(options?: GetAttributeOptions): Promise<boolean>;
|
|
19
21
|
getText(options?: InnerTextOptions): Promise<string>;
|
|
@@ -50,11 +50,13 @@ 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;
|
|
53
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
55
|
exports.CurrencyLabel = void 0;
|
|
55
56
|
var BaseComponent_1 = require("./BaseComponent");
|
|
56
57
|
var assertions_1 = require("../assertions");
|
|
57
58
|
var utils_1 = require("../utils");
|
|
59
|
+
var LocatorSymbols_1 = require("../matchers/component/LocatorSymbols");
|
|
58
60
|
var CurrencyLabel = /** @class */ (function (_super) {
|
|
59
61
|
__extends(CurrencyLabel, _super);
|
|
60
62
|
function CurrencyLabel(rootLocator, options) {
|
|
@@ -62,14 +64,15 @@ var CurrencyLabel = /** @class */ (function (_super) {
|
|
|
62
64
|
var _this = _super.call(this, rootLocator) || this;
|
|
63
65
|
_this.rootLocator = rootLocator;
|
|
64
66
|
_this.options = options;
|
|
67
|
+
_this[_a] = function () { return _this.rootLocator; };
|
|
65
68
|
return _this;
|
|
66
69
|
}
|
|
67
70
|
CurrencyLabel.prototype.isDisabled = function (options) {
|
|
68
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
-
return __generator(this, function (
|
|
70
|
-
switch (
|
|
72
|
+
return __generator(this, function (_b) {
|
|
73
|
+
switch (_b.label) {
|
|
71
74
|
case 0: return [4 /*yield*/, this.getAttribute(utils_1.DataVisualState.Disabled, options)];
|
|
72
|
-
case 1: return [2 /*return*/, (
|
|
75
|
+
case 1: return [2 /*return*/, (_b.sent()) !== null];
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
});
|
|
@@ -86,3 +89,4 @@ var CurrencyLabel = /** @class */ (function (_super) {
|
|
|
86
89
|
return CurrencyLabel;
|
|
87
90
|
}(BaseComponent_1.BaseComponent));
|
|
88
91
|
exports.CurrencyLabel = CurrencyLabel;
|
|
92
|
+
_a = LocatorSymbols_1.toValueElementLocator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ValueOptions } from '../../options';
|
|
1
|
+
import type { CurrencyLabelAssertionOptions, ValueOptions } from '../../options';
|
|
2
2
|
import type { ToWithValueElementLocator } from './LocatorSymbols';
|
|
3
3
|
export declare const toHaveValue: (this: import("@playwright/test").ExpectMatcherState, component: ToWithValueElementLocator, args_0: string | number | RegExp | readonly (string | RegExp)[] | {
|
|
4
4
|
start?: string;
|
|
5
5
|
end?: string;
|
|
6
|
-
}, args_1?: ValueOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
6
|
+
}, args_1?: ValueOptions | CurrencyLabelAssertionOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
@@ -40,6 +40,7 @@ exports.toHaveValue = void 0;
|
|
|
40
40
|
var test_1 = require("@playwright/test");
|
|
41
41
|
var components_1 = require("../../components");
|
|
42
42
|
var extensions_1 = require("../../extensions");
|
|
43
|
+
var currencyLabel_1 = require("../../utils/currencyLabel");
|
|
43
44
|
var LocatorSymbols_1 = require("./LocatorSymbols");
|
|
44
45
|
var createAsyncMatcher_1 = require("../createAsyncMatcher");
|
|
45
46
|
exports.toHaveValue = (0, createAsyncMatcher_1.createSymbolMatcher)('toHaveValue', LocatorSymbols_1.toValueElementLocator, function (_a, expected_1, options_1) { return __awaiter(void 0, [_a, expected_1, options_1], void 0, function (_b, expected, options) {
|
|
@@ -53,31 +54,36 @@ exports.toHaveValue = (0, createAsyncMatcher_1.createSymbolMatcher)('toHaveValue
|
|
|
53
54
|
switch (_c) {
|
|
54
55
|
case component instanceof components_1.Select: return [3 /*break*/, 1];
|
|
55
56
|
case component instanceof components_1.CurrencyInput: return [3 /*break*/, 3];
|
|
56
|
-
case component instanceof components_1.
|
|
57
|
-
case component instanceof components_1.
|
|
57
|
+
case component instanceof components_1.CurrencyLabel: return [3 /*break*/, 5];
|
|
58
|
+
case component instanceof components_1.ComboBox: return [3 /*break*/, 7];
|
|
59
|
+
case component instanceof components_1.DateRangePicker: return [3 /*break*/, 9];
|
|
58
60
|
}
|
|
59
|
-
return [3 /*break*/,
|
|
61
|
+
return [3 /*break*/, 11];
|
|
60
62
|
case 1: return [4 /*yield*/, checkSelect(isNot, locator, expected, options)];
|
|
61
63
|
case 2:
|
|
62
64
|
_d.sent();
|
|
63
|
-
return [3 /*break*/,
|
|
65
|
+
return [3 /*break*/, 13];
|
|
64
66
|
case 3: return [4 /*yield*/, checkCurrencyInput(component, isNot, locator, expected, options)];
|
|
65
67
|
case 4:
|
|
66
68
|
_d.sent();
|
|
67
|
-
return [3 /*break*/,
|
|
68
|
-
case 5: return [4 /*yield*/,
|
|
69
|
+
return [3 /*break*/, 13];
|
|
70
|
+
case 5: return [4 /*yield*/, checkCurrencyLabel(component, isNot, locator, expected, options)];
|
|
69
71
|
case 6:
|
|
70
72
|
_d.sent();
|
|
71
|
-
return [3 /*break*/,
|
|
72
|
-
case 7: return [4 /*yield*/,
|
|
73
|
+
return [3 /*break*/, 13];
|
|
74
|
+
case 7: return [4 /*yield*/, checkComboBox(component, isNot, locator, expected, options)];
|
|
73
75
|
case 8:
|
|
74
76
|
_d.sent();
|
|
75
|
-
return [3 /*break*/,
|
|
76
|
-
case 9: return [4 /*yield*/,
|
|
77
|
+
return [3 /*break*/, 13];
|
|
78
|
+
case 9: return [4 /*yield*/, checkDateRangePicker(component, expected)];
|
|
77
79
|
case 10:
|
|
78
80
|
_d.sent();
|
|
79
|
-
|
|
80
|
-
case 11: return [
|
|
81
|
+
return [3 /*break*/, 13];
|
|
82
|
+
case 11: return [4 /*yield*/, expectation.toHaveValue(expected, options)];
|
|
83
|
+
case 12:
|
|
84
|
+
_d.sent();
|
|
85
|
+
_d.label = 13;
|
|
86
|
+
case 13: return [2 /*return*/];
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
89
|
}); });
|
|
@@ -96,6 +102,22 @@ function checkSelect(isNot, locator, expected, options) {
|
|
|
96
102
|
});
|
|
97
103
|
});
|
|
98
104
|
}
|
|
105
|
+
function checkCurrencyLabel(component, isNot, locator, expectedValue, options) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var expectation, expectedText;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
expectation = isNot ? (0, test_1.expect)(locator).not : (0, test_1.expect)(locator);
|
|
112
|
+
expectedText = (0, currencyLabel_1.getCurrencyLabelExpectedText)(expectedValue, component.options, options);
|
|
113
|
+
return [4 /*yield*/, expectation.toHaveText(expectedText, { timeout: options === null || options === void 0 ? void 0 : options.timeout })];
|
|
114
|
+
case 1:
|
|
115
|
+
_a.sent();
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
99
121
|
function checkCurrencyInput(component, isNot, locator, expectedValue, options) {
|
|
100
122
|
return __awaiter(this, void 0, void 0, function () {
|
|
101
123
|
var expectation, expectation_1;
|
|
@@ -20,7 +20,7 @@ declare const matchers: {
|
|
|
20
20
|
readonly toHaveValue: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToWithValueElementLocator, args_0: string | number | RegExp | readonly (string | RegExp)[] | {
|
|
21
21
|
start?: string;
|
|
22
22
|
end?: string;
|
|
23
|
-
}, args_1?: import("..").ValueOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
23
|
+
}, args_1?: import("..").ValueOptions | import("..").CurrencyLabelAssertionOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
24
24
|
readonly toHaveText: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToTextElementLocator, args_0: string | RegExp | readonly (string | RegExp)[], args_1?: import("..").TextOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
25
25
|
readonly toHaveCount: (this: import("@playwright/test").ExpectMatcherState, component: import("..").ComponentList<any>, args_0: number, args_1?: import("..").CountOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
26
26
|
readonly toHaveHref: (this: import("@playwright/test").ExpectMatcherState, component: import("..").Link, args_0: string | RegExp, args_1?: import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
@@ -95,7 +95,7 @@ declare const matchers: {
|
|
|
95
95
|
readonly toHaveValueEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToWithValueElementLocator, args_0: string | number | RegExp | readonly (string | RegExp)[] | {
|
|
96
96
|
start?: string;
|
|
97
97
|
end?: string;
|
|
98
|
-
}, args_1?: import("..").ValueOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
98
|
+
}, args_1?: import("..").ValueOptions | import("..").CurrencyLabelAssertionOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
99
99
|
/**
|
|
100
100
|
* @deprecated will be removed in the next major version
|
|
101
101
|
* @see {@link toHaveText}
|
|
@@ -150,7 +150,7 @@ export declare const componentMatchers: import("@playwright/test").Expect<{
|
|
|
150
150
|
readonly toHaveValue: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToWithValueElementLocator, args_0: string | number | RegExp | readonly (string | RegExp)[] | {
|
|
151
151
|
start?: string;
|
|
152
152
|
end?: string;
|
|
153
|
-
}, args_1?: import("..").ValueOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
153
|
+
}, args_1?: import("..").ValueOptions | import("..").CurrencyLabelAssertionOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
154
154
|
readonly toHaveText: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToTextElementLocator, args_0: string | RegExp | readonly (string | RegExp)[], args_1?: import("..").TextOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
155
155
|
readonly toHaveCount: (this: import("@playwright/test").ExpectMatcherState, component: import("..").ComponentList<any>, args_0: number, args_1?: import("..").CountOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
156
156
|
readonly toHaveHref: (this: import("@playwright/test").ExpectMatcherState, component: import("..").Link, args_0: string | RegExp, args_1?: import("..").AttributeOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
@@ -225,7 +225,7 @@ export declare const componentMatchers: import("@playwright/test").Expect<{
|
|
|
225
225
|
readonly toHaveValueEx: (this: import("@playwright/test").ExpectMatcherState, component: import("./component/LocatorSymbols").ToWithValueElementLocator, args_0: string | number | RegExp | readonly (string | RegExp)[] | {
|
|
226
226
|
start?: string;
|
|
227
227
|
end?: string;
|
|
228
|
-
}, args_1?: import("..").ValueOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
228
|
+
}, args_1?: import("..").ValueOptions | import("..").CurrencyLabelAssertionOptions | undefined) => Promise<import("@playwright/test").MatcherReturnType>;
|
|
229
229
|
/**
|
|
230
230
|
* @deprecated will be removed in the next major version
|
|
231
231
|
* @see {@link toHaveText}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CurrencyLabelOptions } from '../components/CurrencyLabel';
|
|
2
|
+
import type { CurrencyLabelAssertionOptions } from '../options';
|
|
3
|
+
export declare function getCurrencyLabelExpectedText(value: string | number, baseOptions: CurrencyLabelOptions, assertionOptions?: CurrencyLabelAssertionOptions): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrencyLabelExpectedText = getCurrencyLabelExpectedText;
|
|
4
|
+
var CurrencyHelper_1 = require("@skbkontur/react-ui/components/CurrencyInput/CurrencyHelper");
|
|
5
|
+
/**
|
|
6
|
+
* Если `assertionOptions` не определен или в нем нет такого `key` - берем значение из `baseOptions`
|
|
7
|
+
* Иначе берем значение `key` из `assertionOptions`
|
|
8
|
+
*/
|
|
9
|
+
function pickOption(baseOptions, assertionOptions, key) {
|
|
10
|
+
var _a;
|
|
11
|
+
if (assertionOptions === undefined || !(key in assertionOptions)) {
|
|
12
|
+
return (_a = baseOptions[key]) !== null && _a !== void 0 ? _a : undefined;
|
|
13
|
+
}
|
|
14
|
+
return assertionOptions[key];
|
|
15
|
+
}
|
|
16
|
+
function getCurrencyLabelExpectedText(value, baseOptions, assertionOptions) {
|
|
17
|
+
var format = {
|
|
18
|
+
currencySymbol: pickOption(baseOptions, assertionOptions, 'currencySymbol'),
|
|
19
|
+
fractionDigits: pickOption(baseOptions, assertionOptions, 'fractionDigits'),
|
|
20
|
+
hideTrailingZeros: pickOption(baseOptions, assertionOptions, 'hideTrailingZeros'),
|
|
21
|
+
};
|
|
22
|
+
var formattedValue = typeof value === 'number' ? CurrencyHelper_1.CurrencyHelper.format(value, format) : CurrencyHelper_1.CurrencyHelper.formatString(value, format);
|
|
23
|
+
return format.currencySymbol ? "".concat(formattedValue, "\u00A0").concat(format.currencySymbol) : formattedValue;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/playwright-react-ui-components",
|
|
3
|
-
"version": "1.18.0-beta.
|
|
3
|
+
"version": "1.18.0-beta.3",
|
|
4
4
|
"description": "Пакет для взаимодействия с компонентами @skbkontur/react-ui при тестировании с помощью Playwright",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|