@baloise/ds-testing 0.0.5-nightly.20240301
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/LICENSE +201 -0
- package/README.md +40 -0
- package/add-custom-commands.esm.d.ts +1 -0
- package/add-custom-commands.esm.js +4 -0
- package/add-override-commands.esm.d.ts +1 -0
- package/add-override-commands.esm.js +3 -0
- package/bal-input-stepper.command.esm.js +685 -0
- package/helpers.esm.js +359 -0
- package/index.esm.d.ts +1 -0
- package/index.esm.js +891 -0
- package/index.esm2.js +308 -0
- package/package.json +48 -0
- package/selectors.esm.d.ts +1 -0
- package/selectors.esm.js +1 -0
- package/src/add-custom-commands.d.ts +36 -0
- package/src/add-override-commands.d.ts +9 -0
- package/src/commands/custom/bal-accordion.command.d.ts +1 -0
- package/src/commands/custom/bal-accordion.types.d.ts +15 -0
- package/src/commands/custom/bal-datepicker.command.d.ts +1 -0
- package/src/commands/custom/bal-datepicker.types.d.ts +31 -0
- package/src/commands/custom/bal-field.command.d.ts +1 -0
- package/src/commands/custom/bal-field.types.d.ts +11 -0
- package/src/commands/custom/bal-hint.command.d.ts +1 -0
- package/src/commands/custom/bal-hint.types.d.ts +15 -0
- package/src/commands/custom/bal-input-stepper.command.d.ts +1 -0
- package/src/commands/custom/bal-input-stepper.types.d.ts +15 -0
- package/src/commands/custom/bal-modal.command.d.ts +1 -0
- package/src/commands/custom/bal-modal.types.d.ts +24 -0
- package/src/commands/custom/bal-pagination.command.d.ts +1 -0
- package/src/commands/custom/bal-pagination.types.d.ts +23 -0
- package/src/commands/custom/bal-popover.command.d.ts +1 -0
- package/src/commands/custom/bal-popover.types.d.ts +27 -0
- package/src/commands/custom/bal-popup.command.d.ts +1 -0
- package/src/commands/custom/bal-popup.types.d.ts +15 -0
- package/src/commands/custom/bal-select.command.d.ts +1 -0
- package/src/commands/custom/bal-select.types.d.ts +19 -0
- package/src/commands/custom/bal-snackbar.command.d.ts +1 -0
- package/src/commands/custom/bal-snackbar.types.d.ts +11 -0
- package/src/commands/custom/bal-steps.command.d.ts +1 -0
- package/src/commands/custom/bal-steps.types.d.ts +27 -0
- package/src/commands/custom/bal-tabs.command.d.ts +1 -0
- package/src/commands/custom/bal-tabs.types.d.ts +31 -0
- package/src/commands/custom/bal-toast.command.d.ts +1 -0
- package/src/commands/custom/bal-toast.types.d.ts +11 -0
- package/src/commands/custom/component.command.d.ts +1 -0
- package/src/commands/custom/component.types.d.ts +43 -0
- package/src/commands/custom/get.command.d.ts +1 -0
- package/src/commands/custom/get.types.d.ts +43 -0
- package/src/commands/custom/platform.command.d.ts +1 -0
- package/src/commands/custom/platform.types.d.ts +11 -0
- package/src/commands/custom/visit.command.d.ts +1 -0
- package/src/commands/custom/visit.types.d.ts +10 -0
- package/src/commands/helpers.d.ts +48 -0
- package/src/commands/overrides/blur.command.d.ts +1 -0
- package/src/commands/overrides/check.command.d.ts +1 -0
- package/src/commands/overrides/clear.command.d.ts +1 -0
- package/src/commands/overrides/click.command.d.ts +1 -0
- package/src/commands/overrides/focus.command.d.ts +1 -0
- package/src/commands/overrides/select.command.d.ts +1 -0
- package/src/commands/overrides/should.command.d.ts +1 -0
- package/src/commands/overrides/type.command.d.ts +1 -0
- package/src/commands/overrides/uncheck.command.d.ts +1 -0
- package/src/index.d.ts +25 -0
- package/src/legacy/accessors/accordion.accessor.d.ts +29 -0
- package/src/legacy/accessors/button.accessor.d.ts +23 -0
- package/src/legacy/accessors/checkbox.accessor.d.ts +25 -0
- package/src/legacy/accessors/date-picker.accessor.d.ts +24 -0
- package/src/legacy/accessors/drop-down.accessor.d.ts +31 -0
- package/src/legacy/accessors/error.accessor.d.ts +25 -0
- package/src/legacy/accessors/icon-accessor.d.ts +23 -0
- package/src/legacy/accessors/input.accessor.d.ts +30 -0
- package/src/legacy/accessors/link.accessor.d.ts +39 -0
- package/src/legacy/accessors/list.accessor.d.ts +23 -0
- package/src/legacy/accessors/mixins/andable.d.ts +5 -0
- package/src/legacy/accessors/mixins/attachable.d.ts +6 -0
- package/src/legacy/accessors/mixins/attributable.d.ts +7 -0
- package/src/legacy/accessors/mixins/blurable.d.ts +6 -0
- package/src/legacy/accessors/mixins/checkable.d.ts +7 -0
- package/src/legacy/accessors/mixins/clearable.d.ts +6 -0
- package/src/legacy/accessors/mixins/clickable.d.ts +7 -0
- package/src/legacy/accessors/mixins/containable.d.ts +5 -0
- package/src/legacy/accessors/mixins/disableable.d.ts +5 -0
- package/src/legacy/accessors/mixins/eachable.d.ts +5 -0
- package/src/legacy/accessors/mixins/existable.d.ts +5 -0
- package/src/legacy/accessors/mixins/findable.d.ts +5 -0
- package/src/legacy/accessors/mixins/invokable.d.ts +5 -0
- package/src/legacy/accessors/mixins/lengthable.d.ts +5 -0
- package/src/legacy/accessors/mixins/mixins.d.ts +12 -0
- package/src/legacy/accessors/mixins/nthSelectable.d.ts +7 -0
- package/src/legacy/accessors/mixins/selectable.d.ts +4 -0
- package/src/legacy/accessors/mixins/shouldable.d.ts +5 -0
- package/src/legacy/accessors/mixins/thenable.d.ts +5 -0
- package/src/legacy/accessors/mixins/typeable.d.ts +6 -0
- package/src/legacy/accessors/mixins/urlable.d.ts +6 -0
- package/src/legacy/accessors/mixins/visible.d.ts +5 -0
- package/src/legacy/accessors/mixins/waitable.d.ts +5 -0
- package/src/legacy/accessors/multi-select-button.accessor.d.ts +24 -0
- package/src/legacy/accessors/navigation.accessor.d.ts +22 -0
- package/src/legacy/accessors/radio.accessor.d.ts +23 -0
- package/src/legacy/accessors/select-button.accessor.d.ts +24 -0
- package/src/legacy/accessors/table.accessor.d.ts +27 -0
- package/src/legacy/accessors/tabs.accessor.d.ts +26 -0
- package/src/legacy/accessors/text.accessor.d.ts +23 -0
- package/src/legacy/accessors/tile.accessor.d.ts +27 -0
- package/src/legacy/accessors/toast.accessor.d.ts +24 -0
- package/src/legacy/accessors/tooltip.accessor.d.ts +23 -0
- package/src/legacy/accessors/typeahead.accessor.d.ts +26 -0
- package/src/legacy/index.d.ts +44 -0
- package/src/selectors/index.d.ts +342 -0
- package/src/selectors/selectors.util.d.ts +4 -0
- package/src/selectors.d.ts +1 -0
- package/src/viewports.d.ts +7 -0
- package/type.command.esm.js +471 -0
- package/viewports.esm.d.ts +1 -0
- package/viewports.esm.js +46 -0
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import { b as byTestId, s as selectors } from './index.esm2.js';
|
|
2
|
+
import { w as wrapOptions, l as log, c as checkAriaLabel, a as waitAfterFramePaint, b as waitAfterIdleCallback, d as areComponentsReady, e as deepReady, _ as _extends } from './helpers.esm.js';
|
|
3
|
+
import { balViewport } from './viewports.esm.js';
|
|
4
|
+
|
|
5
|
+
Cypress.Commands.add("getByTestId", function(testID, options) {
|
|
6
|
+
var o = wrapOptions(options);
|
|
7
|
+
var element = cy.get(byTestId(testID), o).waitForComponents(o);
|
|
8
|
+
element.then(o, function($el) {
|
|
9
|
+
return log("getByTestId", testID, $el, options);
|
|
10
|
+
});
|
|
11
|
+
return element;
|
|
12
|
+
});
|
|
13
|
+
Cypress.Commands.add("getDescribingElement", {
|
|
14
|
+
prevSubject: [
|
|
15
|
+
"element"
|
|
16
|
+
]
|
|
17
|
+
}, function(subject, options) {
|
|
18
|
+
var o = wrapOptions(options);
|
|
19
|
+
return cy.wrap(subject, o).then(function(subjectElement) {
|
|
20
|
+
var ariaDescribedBy = subjectElement.attr("aria-describedby");
|
|
21
|
+
if (ariaDescribedBy) {
|
|
22
|
+
return cy.get('[id="' + ariaDescribedBy + '"]', o).then(o, function($el) {
|
|
23
|
+
return log("-getDescribingElement", ariaDescribedBy, $el, options);
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
throw new Error("The subject element does not have an aria-describedby attribute.");
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
Cypress.Commands.add("shouldBeInvalid", {
|
|
31
|
+
prevSubject: [
|
|
32
|
+
"element"
|
|
33
|
+
]
|
|
34
|
+
}, function(subject, options) {
|
|
35
|
+
var o = wrapOptions(options);
|
|
36
|
+
cy.wrap(subject, o).should("have.attr", "aria-invalid", "true");
|
|
37
|
+
});
|
|
38
|
+
Cypress.Commands.add("shouldBeValid", {
|
|
39
|
+
prevSubject: [
|
|
40
|
+
"element"
|
|
41
|
+
]
|
|
42
|
+
}, function(subject, options) {
|
|
43
|
+
var o = wrapOptions(options);
|
|
44
|
+
cy.wrap(subject, o).should("not.have.attr", "aria-invalid", "true");
|
|
45
|
+
});
|
|
46
|
+
Cypress.Commands.add("getByLabelText", {
|
|
47
|
+
prevSubject: [
|
|
48
|
+
"optional"
|
|
49
|
+
]
|
|
50
|
+
}, function(subject, labelText, options) {
|
|
51
|
+
var o = wrapOptions(options);
|
|
52
|
+
if (subject) {
|
|
53
|
+
return cy.wrap(subject, o).contains("label", labelText, o).invoke(o, "attr", "for").then(function(forAttributeValue) {
|
|
54
|
+
return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"]', o);
|
|
55
|
+
}).then(o, function($el) {
|
|
56
|
+
return log(!!subject ? "-getByLabelText" : "getByLabelText", labelText, $el, options);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
return cy.contains("label", labelText, o).invoke(o, "attr", "for").then(function(forAttributeValue) {
|
|
60
|
+
return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"]', o);
|
|
61
|
+
}).then(o, function($el) {
|
|
62
|
+
return log(!!subject ? "-getByLabelText" : "getByLabelText", labelText, $el, options);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Cypress.Commands.add("getByPlaceholder", {
|
|
67
|
+
prevSubject: [
|
|
68
|
+
"optional"
|
|
69
|
+
]
|
|
70
|
+
}, function(subject, placeholder, options) {
|
|
71
|
+
var o = wrapOptions(options);
|
|
72
|
+
var element = subject ? cy.wrap(subject, o).find('input[placeholder="' + placeholder + '"], textarea[placeholder="' + placeholder + '"]', o).waitForComponents(o) : cy.get('input[placeholder="' + placeholder + '"], textarea[placeholder="' + placeholder + '"]', o).waitForComponents(o);
|
|
73
|
+
element.then(o, function($el) {
|
|
74
|
+
return log(!!subject ? "-getByPlaceholder" : "getByPlaceholder", placeholder, $el, options);
|
|
75
|
+
});
|
|
76
|
+
return element;
|
|
77
|
+
});
|
|
78
|
+
Cypress.Commands.add("getByRole", {
|
|
79
|
+
prevSubject: [
|
|
80
|
+
"optional"
|
|
81
|
+
]
|
|
82
|
+
}, function(subject, role, options) {
|
|
83
|
+
var findElements = function findElements() {
|
|
84
|
+
return subject ? cy.wrap(subject, o).find(role + ', [role="' + role + '"]', o) : cy.get(role + ', [role="' + role + '"]', o);
|
|
85
|
+
};
|
|
86
|
+
var filterVisibleElements = function filterVisibleElements(elements) {
|
|
87
|
+
return elements.filter(function(element) {
|
|
88
|
+
var isElementAriaHidden = options.hidden === true ? false : !!Cypress.$(element).attr("aria-hidden");
|
|
89
|
+
return !isElementAriaHidden;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
var filterLabeling = function filterLabeling(elements) {
|
|
93
|
+
return elements.filter(function(element) {
|
|
94
|
+
return checkAriaLabel(element, options.name);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var o = wrapOptions(options);
|
|
98
|
+
return findElements().then(function($buttons) {
|
|
99
|
+
var buttons = $buttons.toArray();
|
|
100
|
+
var visibleElements = filterVisibleElements(buttons);
|
|
101
|
+
var labeledElements = filterLabeling(visibleElements);
|
|
102
|
+
if (labeledElements.length > 0) {
|
|
103
|
+
var firstElement = cy.wrap(labeledElements[0]).waitForComponents();
|
|
104
|
+
firstElement.then(o, function($el) {
|
|
105
|
+
return log(!!subject ? "-getByRole" : "getByRole", role + " " + JSON.stringify(options), $el, options);
|
|
106
|
+
});
|
|
107
|
+
return firstElement;
|
|
108
|
+
}
|
|
109
|
+
return subject;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
Cypress.Commands.add("getControl", {
|
|
113
|
+
prevSubject: [
|
|
114
|
+
"element"
|
|
115
|
+
]
|
|
116
|
+
}, function(subject, labelText, options) {
|
|
117
|
+
var o = wrapOptions(options);
|
|
118
|
+
var clearedLabelText = ("" + (labelText || "")).trim();
|
|
119
|
+
return cy.wrap(subject, o).invoke(o, "attr", "id").then(function(id) {
|
|
120
|
+
return cy.get('button[aria-controls="' + id + '"]', o);
|
|
121
|
+
}).filter(function(_index, element) {
|
|
122
|
+
return checkAriaLabel(element, clearedLabelText);
|
|
123
|
+
}, o).then(o, function($el) {
|
|
124
|
+
return log("-getControl", "" + labelText, $el, options);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
Cypress.Commands.add("waitForBrowser", {
|
|
129
|
+
prevSubject: "optional"
|
|
130
|
+
}, function(subject, options) {
|
|
131
|
+
log("waitForBrowser", "", subject, options);
|
|
132
|
+
var o = wrapOptions(options);
|
|
133
|
+
return cy.wrap(subject, o).then(function() {
|
|
134
|
+
return waitAfterFramePaint();
|
|
135
|
+
}).then(function() {
|
|
136
|
+
return waitAfterIdleCallback();
|
|
137
|
+
}).wait(300, o) // animation timeout
|
|
138
|
+
.wrap(subject, o);
|
|
139
|
+
});
|
|
140
|
+
Cypress.Commands.add("waitAfterIdleCallback", {
|
|
141
|
+
prevSubject: "optional"
|
|
142
|
+
}, function(subject, options) {
|
|
143
|
+
log("waitAfterIdleCallback", "", subject, options);
|
|
144
|
+
var o = wrapOptions(options);
|
|
145
|
+
return cy.wrap(subject, o).then(function() {
|
|
146
|
+
return waitAfterIdleCallback();
|
|
147
|
+
}).wrap(subject, o);
|
|
148
|
+
});
|
|
149
|
+
Cypress.Commands.add("waitAfterFramePaint", {
|
|
150
|
+
prevSubject: "optional"
|
|
151
|
+
}, function(subject, options) {
|
|
152
|
+
log("waitAfterFramePaint", "", subject, options);
|
|
153
|
+
var o = wrapOptions(options);
|
|
154
|
+
return cy.wrap(subject, o).then(function() {
|
|
155
|
+
return waitAfterFramePaint();
|
|
156
|
+
}).wrap(subject, o);
|
|
157
|
+
});
|
|
158
|
+
Cypress.Commands.add("waitForComponents", {
|
|
159
|
+
prevSubject: "optional"
|
|
160
|
+
}, function(subject, options) {
|
|
161
|
+
cy.document({
|
|
162
|
+
log: false
|
|
163
|
+
}).then(function(document) {
|
|
164
|
+
return document.fonts.ready;
|
|
165
|
+
});
|
|
166
|
+
log("waitForComponents", "", subject, options);
|
|
167
|
+
var o = wrapOptions(options);
|
|
168
|
+
return cy.wrap(subject, o).then(function($el) {
|
|
169
|
+
return areComponentsReady($el);
|
|
170
|
+
}).then(function() {
|
|
171
|
+
return waitAfterFramePaint();
|
|
172
|
+
}).then(function() {
|
|
173
|
+
return waitAfterIdleCallback(o.timeout);
|
|
174
|
+
}).wrap(subject, o);
|
|
175
|
+
});
|
|
176
|
+
Cypress.Commands.add("wrapComponent", {
|
|
177
|
+
prevSubject: false
|
|
178
|
+
}, function(element, options) {
|
|
179
|
+
log("wrapComponent", "", element, options);
|
|
180
|
+
var o = wrapOptions(options);
|
|
181
|
+
return cy.wrap(element, o);
|
|
182
|
+
});
|
|
183
|
+
Cypress.Commands.add("getComponent", {
|
|
184
|
+
prevSubject: false
|
|
185
|
+
}, function(selector, options) {
|
|
186
|
+
log("getComponent", selector, null, options);
|
|
187
|
+
var o = wrapOptions(options);
|
|
188
|
+
return cy.get(selector, o).waitForComponents(o);
|
|
189
|
+
});
|
|
190
|
+
Cypress.Commands.add("disableAnimation", function() {
|
|
191
|
+
cy.window({
|
|
192
|
+
log: false
|
|
193
|
+
}).then(function(win) {
|
|
194
|
+
win.BaloiseDesignSystem.config.animated = false;
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
Cypress.Commands.add("disableLogger", function() {
|
|
198
|
+
cy.window({
|
|
199
|
+
log: false
|
|
200
|
+
}).then(function(win) {
|
|
201
|
+
win.BaloiseDesignSystem.config.logger = {
|
|
202
|
+
components: [],
|
|
203
|
+
event: false,
|
|
204
|
+
lifecycle: false,
|
|
205
|
+
render: false,
|
|
206
|
+
custom: false
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
Cypress.Commands.add("waitForDesignSystem", function() {
|
|
211
|
+
cy.document({
|
|
212
|
+
log: false
|
|
213
|
+
}).then(function(document) {
|
|
214
|
+
return document.fonts.ready;
|
|
215
|
+
});
|
|
216
|
+
cy.get("bal-app,.bal-app", {
|
|
217
|
+
log: false
|
|
218
|
+
}).first({
|
|
219
|
+
log: false
|
|
220
|
+
}).then(function($app) {
|
|
221
|
+
Cypress.log({
|
|
222
|
+
type: "parent",
|
|
223
|
+
$el: $app,
|
|
224
|
+
displayName: "bal-app",
|
|
225
|
+
message: "wait for DesignSystem to be ready"
|
|
226
|
+
});
|
|
227
|
+
}).waitForComponents({
|
|
228
|
+
log: false
|
|
229
|
+
}).invoke({
|
|
230
|
+
log: false
|
|
231
|
+
}, "attr", "ready").should(function($el) {
|
|
232
|
+
expect($el, "if bal-app is ready").to.eq("");
|
|
233
|
+
}).disableAnimation().disableLogger();
|
|
234
|
+
cy.get("bal-app,.bal-app", {
|
|
235
|
+
log: false
|
|
236
|
+
}).first({
|
|
237
|
+
log: false
|
|
238
|
+
}).then(function($app) {
|
|
239
|
+
Cypress.log({
|
|
240
|
+
type: "parent",
|
|
241
|
+
$el: $app,
|
|
242
|
+
displayName: "bal-app",
|
|
243
|
+
message: "DesignSystem is ready \uD83D\uDE80"
|
|
244
|
+
});
|
|
245
|
+
}).then(function() {
|
|
246
|
+
return waitAfterFramePaint();
|
|
247
|
+
}).then(function() {
|
|
248
|
+
return waitAfterIdleCallback();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
Cypress.Commands.add("platform", function(platform) {
|
|
253
|
+
Cypress.log({
|
|
254
|
+
name: "platform",
|
|
255
|
+
displayName: "platform",
|
|
256
|
+
message: platform
|
|
257
|
+
});
|
|
258
|
+
var key = platform || "desktop";
|
|
259
|
+
var viewport = balViewport[key];
|
|
260
|
+
return cy.viewport(viewport.width, viewport.height, {
|
|
261
|
+
log: false
|
|
262
|
+
}).then(function() {
|
|
263
|
+
return waitAfterFramePaint();
|
|
264
|
+
}).then(function() {
|
|
265
|
+
return waitAfterIdleCallback();
|
|
266
|
+
}).wait(32);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
Cypress.Commands.add("visitBalApp", function(url, options) {
|
|
270
|
+
cy.visit(url, options);
|
|
271
|
+
cy.get("bal-app,bal-doc-app,.bal-app", {
|
|
272
|
+
log: false
|
|
273
|
+
}).first({
|
|
274
|
+
log: false
|
|
275
|
+
}).then(function($app) {
|
|
276
|
+
return new Cypress.Promise(function(resolve) {
|
|
277
|
+
deepReady($app.get(0)).then(function() {
|
|
278
|
+
return resolve();
|
|
279
|
+
});
|
|
280
|
+
Cypress.log({
|
|
281
|
+
type: "parent",
|
|
282
|
+
$el: $app,
|
|
283
|
+
displayName: "bal-app",
|
|
284
|
+
message: "is ready \uD83D\uDE80"
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
Cypress.Commands.add("balAccordionIsOpen", {
|
|
291
|
+
prevSubject: true
|
|
292
|
+
}, function(subject, options) {
|
|
293
|
+
log("balAccordionIsOpen", "", subject, options);
|
|
294
|
+
var o = wrapOptions(options);
|
|
295
|
+
return cy.wrapComponent(subject, o).should("have.class", "bal-accordion--active", "true");
|
|
296
|
+
});
|
|
297
|
+
Cypress.Commands.add("balAccordionIsClosed", {
|
|
298
|
+
prevSubject: true
|
|
299
|
+
}, function(subject, options) {
|
|
300
|
+
log("balAccordionIsClosed", "", subject, options);
|
|
301
|
+
var o = wrapOptions(options);
|
|
302
|
+
return cy.wrapComponent(subject, o).should("not.have.class", "bal-accordion--active");
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
var getYear = function(date) {
|
|
306
|
+
return date.getFullYear();
|
|
307
|
+
};
|
|
308
|
+
var getMonth = function(date) {
|
|
309
|
+
return date.getMonth();
|
|
310
|
+
};
|
|
311
|
+
var formatDateString = function(date) {
|
|
312
|
+
var day = "" + date.getDate();
|
|
313
|
+
var month = "" + (date.getMonth() + 1);
|
|
314
|
+
var pad = function(text) {
|
|
315
|
+
return text.length === 1 ? "0" + text : text;
|
|
316
|
+
};
|
|
317
|
+
return date.getFullYear() + "-" + pad(month) + "-" + pad(day);
|
|
318
|
+
};
|
|
319
|
+
var selectorDayBox = function(date) {
|
|
320
|
+
return '[data-date="' + formatDateString(date) + '"]';
|
|
321
|
+
};
|
|
322
|
+
Cypress.Commands.add("balDatepickerToggle", {
|
|
323
|
+
prevSubject: true
|
|
324
|
+
}, function(subject, options) {
|
|
325
|
+
log("balDatepickerToggle", "", subject, options);
|
|
326
|
+
var o = wrapOptions(options);
|
|
327
|
+
return cy.wrapComponent(subject, o).find(".datepicker-trigger-icon", o).click(o).wrapComponent(subject, o);
|
|
328
|
+
});
|
|
329
|
+
Cypress.Commands.add("balDatepickerIsOpen", {
|
|
330
|
+
prevSubject: true
|
|
331
|
+
}, function(subject, options) {
|
|
332
|
+
log("balDatepickerIsOpen", "", subject, options);
|
|
333
|
+
var o = wrapOptions(options);
|
|
334
|
+
return cy.wrapComponent(subject, o).find("bal-popover", o).should("have.attr", "aria-presented", "true").wrapComponent(subject, o);
|
|
335
|
+
});
|
|
336
|
+
Cypress.Commands.add("balDatepickerIsClosed", {
|
|
337
|
+
prevSubject: true
|
|
338
|
+
}, function(subject, options) {
|
|
339
|
+
log("balDatepickerIsClosed", "", subject, options);
|
|
340
|
+
var o = wrapOptions(options);
|
|
341
|
+
return cy.wrapComponent(subject, o).find("bal-popover", o).should("not.have.attr", "aria-presented").wrapComponent(subject, o);
|
|
342
|
+
});
|
|
343
|
+
Cypress.Commands.add("balDatepickerPick", {
|
|
344
|
+
prevSubject: true
|
|
345
|
+
}, function(subject, date, options) {
|
|
346
|
+
log("balDatepickerPick", formatDateString(date), subject, options);
|
|
347
|
+
var o = wrapOptions(options);
|
|
348
|
+
return cy.wrapComponent(subject, o).balDatepickerIsOpen(o).within(function() {
|
|
349
|
+
cy.get(".bal-datepicker-pagination__month-and-year__select--month select", o).first(o).select(getMonth(date).toString(), o);
|
|
350
|
+
cy.get(".bal-datepicker-pagination__month-and-year__select--year select", o).first(o).select(getYear(date).toString(), o);
|
|
351
|
+
cy.get(selectorDayBox(date), o).click(o);
|
|
352
|
+
}).wrapComponent(subject, o);
|
|
353
|
+
});
|
|
354
|
+
Cypress.Commands.add("balDatepickerIsDateInRange", {
|
|
355
|
+
prevSubject: true
|
|
356
|
+
}, function(subject, date, options) {
|
|
357
|
+
log("balDatepickerIsDateInRange", formatDateString(date), subject, options);
|
|
358
|
+
var o = wrapOptions(options);
|
|
359
|
+
return cy.wrapComponent(subject, o).find(selectorDayBox(date), _extends({}, o, {
|
|
360
|
+
force: true
|
|
361
|
+
})).should("not.have.class", "is-disabled").wrapComponent(subject, o);
|
|
362
|
+
});
|
|
363
|
+
Cypress.Commands.add("balDatepickerIsDateNotInRange", {
|
|
364
|
+
prevSubject: true
|
|
365
|
+
}, function(subject, date, options) {
|
|
366
|
+
log("balDatepickerIsDateNotInRange", formatDateString(date), subject, options);
|
|
367
|
+
var o = wrapOptions(options);
|
|
368
|
+
return cy.wrapComponent(subject, o).find(selectorDayBox(date), _extends({}, o, {
|
|
369
|
+
force: true
|
|
370
|
+
})).should("have.class", "is-disabled").wrapComponent(subject, o);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
Cypress.Commands.add("balPopoverToggle", {
|
|
374
|
+
prevSubject: true
|
|
375
|
+
}, function(subject, options) {
|
|
376
|
+
log("balPopoverToggle", "", subject, options);
|
|
377
|
+
var o = wrapOptions(options);
|
|
378
|
+
return cy.wrapComponent(subject, o).find("[" + selectors.popover.trigger + "]", o).click(o).wrapComponent(subject, o);
|
|
379
|
+
});
|
|
380
|
+
Cypress.Commands.add("balPopoverIsOpen", {
|
|
381
|
+
prevSubject: true
|
|
382
|
+
}, function(subject, options) {
|
|
383
|
+
log("balPopoverIsOpen", "", subject, options);
|
|
384
|
+
var o = wrapOptions(options);
|
|
385
|
+
return cy.wrapComponent(subject, o).should("have.attr", "aria-presented", "true");
|
|
386
|
+
});
|
|
387
|
+
Cypress.Commands.add("balPopoverIsClosed", {
|
|
388
|
+
prevSubject: true
|
|
389
|
+
}, function(subject, options) {
|
|
390
|
+
log("balPopoverIsClosed", "", subject, options);
|
|
391
|
+
var o = wrapOptions(options);
|
|
392
|
+
return cy.wrapComponent(subject, o).should("not.have.attr", "aria-presented");
|
|
393
|
+
});
|
|
394
|
+
Cypress.Commands.add("balPopoverTriggerContains", {
|
|
395
|
+
prevSubject: true
|
|
396
|
+
}, function(subject, content, options) {
|
|
397
|
+
log("balPopoverTriggerContains", content, subject, options);
|
|
398
|
+
var o = wrapOptions(options);
|
|
399
|
+
return cy.wrapComponent(subject, o).find("[" + selectors.popover.trigger + "]", o).contains(content, options).wrapComponent(subject, o);
|
|
400
|
+
});
|
|
401
|
+
Cypress.Commands.add("balPopoverContentContains", {
|
|
402
|
+
prevSubject: true
|
|
403
|
+
}, function(subject, content, options) {
|
|
404
|
+
log("balPopoverContentContains", content, subject, options);
|
|
405
|
+
var o = wrapOptions(options);
|
|
406
|
+
return cy.wrapComponent(subject, o).find(selectors.popover.content, o).contains(content, options).wrapComponent(subject, o);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
Cypress.Commands.add("balPopupIsOpen", {
|
|
410
|
+
prevSubject: true
|
|
411
|
+
}, function(subject, options) {
|
|
412
|
+
log("balPopupIsOpen", "", subject, options);
|
|
413
|
+
var o = wrapOptions(options);
|
|
414
|
+
return cy.wrapComponent(subject, o).should("have.attr", "aria-presented", "true");
|
|
415
|
+
});
|
|
416
|
+
Cypress.Commands.add("balPopupIsClosed", {
|
|
417
|
+
prevSubject: true
|
|
418
|
+
}, function(subject, options) {
|
|
419
|
+
log("balPopupIsClosed", "", subject, options);
|
|
420
|
+
var o = wrapOptions(options);
|
|
421
|
+
return cy.wrapComponent(subject, o).should("not.have.attr", "aria-presented");
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
Cypress.Commands.add("balHintFindOverlay", {
|
|
425
|
+
prevSubject: true
|
|
426
|
+
}, function(subject, options) {
|
|
427
|
+
var o = wrapOptions(options);
|
|
428
|
+
return cy.wrapComponent(subject, o).find(selectors.hint.content, o).then(function($el) {
|
|
429
|
+
log("balHintFindOverlay", "", $el, options);
|
|
430
|
+
return $el;
|
|
431
|
+
}).waitForComponents(o);
|
|
432
|
+
});
|
|
433
|
+
Cypress.Commands.add("balHintFindCloseButton", {
|
|
434
|
+
prevSubject: true
|
|
435
|
+
}, function(subject, options) {
|
|
436
|
+
var o = wrapOptions(options);
|
|
437
|
+
return cy.wrapComponent(subject, o).find(selectors.hint.close, o).then(function($el) {
|
|
438
|
+
log("balHintFindCloseButton", "", $el, options);
|
|
439
|
+
return $el;
|
|
440
|
+
}).waitForComponents(o);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
Cypress.Commands.add("balModalFindOpen", {
|
|
444
|
+
prevSubject: false
|
|
445
|
+
}, function(options) {
|
|
446
|
+
var o = wrapOptions(options);
|
|
447
|
+
return cy.getComponent('bal-modal[aria-presented="true"]', o).then(function($el) {
|
|
448
|
+
log("balModalFindOpen", "", $el, options);
|
|
449
|
+
return $el;
|
|
450
|
+
}).waitForComponents();
|
|
451
|
+
});
|
|
452
|
+
Cypress.Commands.add("balModalIsOpen", {
|
|
453
|
+
prevSubject: true
|
|
454
|
+
}, function(subject, options) {
|
|
455
|
+
log("balAccordionIsOpen", "", subject, options);
|
|
456
|
+
var o = wrapOptions(options);
|
|
457
|
+
return cy.wrapComponent(subject, o).should("have.attr", "aria-presented", "true");
|
|
458
|
+
});
|
|
459
|
+
Cypress.Commands.add("balModalIsClosed", {
|
|
460
|
+
prevSubject: true
|
|
461
|
+
}, function(subject, options) {
|
|
462
|
+
log("balModalIsClosed", "", subject, options);
|
|
463
|
+
var o = wrapOptions(options);
|
|
464
|
+
return cy.wrapComponent(subject, o).should("not.have.attr", "aria-presented");
|
|
465
|
+
});
|
|
466
|
+
Cypress.Commands.add("balModalClose", {
|
|
467
|
+
prevSubject: true
|
|
468
|
+
}, function(subject, options) {
|
|
469
|
+
log("balModalIsClosed", "", subject, options);
|
|
470
|
+
var o = wrapOptions(options);
|
|
471
|
+
return cy.wrapComponent(subject, o).then(function($modal) {
|
|
472
|
+
return cy.wrapComponent($modal, o).find(".data-test-modal-close", o).waitForComponents().click();
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
Cypress.Commands.add("balPaginationFindPages", {
|
|
477
|
+
prevSubject: true
|
|
478
|
+
}, function(subject, options) {
|
|
479
|
+
var o = wrapOptions(options);
|
|
480
|
+
return cy.wrapComponent(subject, o).find(selectors.pagination.pages + ":visible", o).then(function($el) {
|
|
481
|
+
log("balPaginationFindPages", "", $el, options);
|
|
482
|
+
return $el;
|
|
483
|
+
}).waitForComponents(o);
|
|
484
|
+
});
|
|
485
|
+
Cypress.Commands.add("balPaginationFindCurrentPage", {
|
|
486
|
+
prevSubject: true
|
|
487
|
+
}, function(subject, options) {
|
|
488
|
+
var o = wrapOptions(options);
|
|
489
|
+
return cy.wrapComponent(subject, o).find("" + selectors.pagination.button + ".is-primary:visible", o).then(function($el) {
|
|
490
|
+
log("balPaginationFindCurrentPage", "", $el, options);
|
|
491
|
+
return $el;
|
|
492
|
+
}).waitForComponents(o);
|
|
493
|
+
});
|
|
494
|
+
Cypress.Commands.add("balPaginationFindNextButton", {
|
|
495
|
+
prevSubject: true
|
|
496
|
+
}, function(subject, options) {
|
|
497
|
+
var o = wrapOptions(options);
|
|
498
|
+
return cy.wrapComponent(subject, o).find(selectors.pagination.next, o).then(function($el) {
|
|
499
|
+
log("balPaginationFindNextButton", "", $el, options);
|
|
500
|
+
return $el;
|
|
501
|
+
}).waitForComponents(o);
|
|
502
|
+
});
|
|
503
|
+
Cypress.Commands.add("balPaginationFindPreviousButton", {
|
|
504
|
+
prevSubject: true
|
|
505
|
+
}, function(subject, options) {
|
|
506
|
+
var o = wrapOptions(options);
|
|
507
|
+
return cy.wrapComponent(subject, o).find(selectors.pagination.previous, o).then(function($el) {
|
|
508
|
+
log("balPaginationFindPreviousButton", "", $el, options);
|
|
509
|
+
return $el;
|
|
510
|
+
}).waitForComponents(o);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
Cypress.Commands.add("balSelectFindOptions", {
|
|
514
|
+
prevSubject: true
|
|
515
|
+
}, function(subject, options) {
|
|
516
|
+
var o = wrapOptions(options);
|
|
517
|
+
return cy.wrapComponent(subject, o).find(selectors.select.options, o).then(function($el) {
|
|
518
|
+
log("balSelectFindOptions", "", $el, options);
|
|
519
|
+
return $el;
|
|
520
|
+
}).waitForComponents(o);
|
|
521
|
+
});
|
|
522
|
+
Cypress.Commands.add("balSelectShouldHaveOptions", {
|
|
523
|
+
prevSubject: true
|
|
524
|
+
}, function(subject, labels, dataKey, options) {
|
|
525
|
+
if (dataKey === void 0) dataKey = "label";
|
|
526
|
+
log("balAccordionIsOpen", "", subject, options);
|
|
527
|
+
var o = wrapOptions(options);
|
|
528
|
+
return cy.wrapComponent(subject, o).balSelectFindOptions(o).should(function($o) {
|
|
529
|
+
var dataItems = $o.map(function(_, el) {
|
|
530
|
+
return Cypress.$(el).attr("data-" + dataKey);
|
|
531
|
+
});
|
|
532
|
+
expect(dataItems.get()).to.deep.eq(labels);
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
Cypress.Commands.add("balSelectFindChips", {
|
|
536
|
+
prevSubject: true
|
|
537
|
+
}, function(subject, options) {
|
|
538
|
+
var o = wrapOptions(options);
|
|
539
|
+
return cy.wrapComponent(subject, o).find(selectors.select.chips, o).then(function($el) {
|
|
540
|
+
log("balSelectFindChips", "", $el, options);
|
|
541
|
+
return $el;
|
|
542
|
+
}).waitForComponents(o);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
Cypress.Commands.add("balSnackbarFind", {
|
|
546
|
+
prevSubject: false
|
|
547
|
+
}, function(options) {
|
|
548
|
+
var o = wrapOptions(options);
|
|
549
|
+
return cy.getComponent(selectors.snackbar.main, o).then(function($el) {
|
|
550
|
+
log("balSnackbarFind", "", $el, options);
|
|
551
|
+
return $el;
|
|
552
|
+
}).waitForComponents(o);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
Cypress.Commands.add("balStepsFindItems", {
|
|
556
|
+
prevSubject: true
|
|
557
|
+
}, function(subject, options) {
|
|
558
|
+
var o = wrapOptions(options);
|
|
559
|
+
return cy.wrapComponent(subject, o).find(selectors.steps.option, o).then(function($el) {
|
|
560
|
+
log("balStepsFindItems", "", $el, options);
|
|
561
|
+
return $el;
|
|
562
|
+
}).waitForComponents(o);
|
|
563
|
+
});
|
|
564
|
+
Cypress.Commands.add("balStepsFindLabel", {
|
|
565
|
+
prevSubject: true
|
|
566
|
+
}, function(subject, options) {
|
|
567
|
+
var o = wrapOptions(options);
|
|
568
|
+
return cy.wrapComponent(subject, o).find(selectors.steps.optionLabel, o).then(function($el) {
|
|
569
|
+
log("balStepsFindLabel", "", $el, options);
|
|
570
|
+
return $el;
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
Cypress.Commands.add("balStepsShouldHaveItems", {
|
|
574
|
+
prevSubject: true
|
|
575
|
+
}, function(subject, labels, dataKey, options) {
|
|
576
|
+
if (dataKey === void 0) dataKey = "label";
|
|
577
|
+
var o = wrapOptions(options);
|
|
578
|
+
return cy.wrapComponent(subject, o).balStepsFindItems(o).should(function($o) {
|
|
579
|
+
var dataItems = $o.map(function(_, el) {
|
|
580
|
+
return Cypress.$(el).attr("data-" + dataKey);
|
|
581
|
+
});
|
|
582
|
+
expect(dataItems.get()).to.deep.eq(labels);
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
Cypress.Commands.add("balStepsItemShouldHaveState", {
|
|
586
|
+
prevSubject: true
|
|
587
|
+
}, function(subject, state, options) {
|
|
588
|
+
if (state === void 0) state = "done";
|
|
589
|
+
log("balStepsItemShouldHaveState", "", subject, options);
|
|
590
|
+
var o = wrapOptions(options);
|
|
591
|
+
return cy.wrapComponent(subject, o).should("have.class", "bal-steps__nav__item--" + state);
|
|
592
|
+
});
|
|
593
|
+
Cypress.Commands.add("balStepsItemShouldNotHaveState", {
|
|
594
|
+
prevSubject: true
|
|
595
|
+
}, function(subject, state, options) {
|
|
596
|
+
if (state === void 0) state = "done";
|
|
597
|
+
log("balStepsItemShouldNotHaveState", "", subject, options);
|
|
598
|
+
var o = wrapOptions(options);
|
|
599
|
+
return cy.wrapComponent(subject, o).should("not.have.class", "bal-steps__nav__item--" + state);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
Cypress.Commands.add("balTabsFindItems", {
|
|
603
|
+
prevSubject: true
|
|
604
|
+
}, function(subject, options) {
|
|
605
|
+
var o = wrapOptions(options);
|
|
606
|
+
return cy.wrapComponent(subject, o).find(selectors.tabs.item, o).then(function($el) {
|
|
607
|
+
log("balTabsFindItems", "", $el, options);
|
|
608
|
+
return $el;
|
|
609
|
+
}).waitForComponents(o);
|
|
610
|
+
});
|
|
611
|
+
Cypress.Commands.add("balTabsFindLabel", {
|
|
612
|
+
prevSubject: true
|
|
613
|
+
}, function(subject, options) {
|
|
614
|
+
var o = wrapOptions(options);
|
|
615
|
+
return cy.wrapComponent(subject, o).find(selectors.tabs.itemLabel, o).then(function($el) {
|
|
616
|
+
log("balTabsFindLabel", "", $el, options);
|
|
617
|
+
return $el;
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
Cypress.Commands.add("balTabsShouldHaveItems", {
|
|
621
|
+
prevSubject: true
|
|
622
|
+
}, function(subject, labels, dataKey, options) {
|
|
623
|
+
if (dataKey === void 0) dataKey = "label";
|
|
624
|
+
var o = wrapOptions(options);
|
|
625
|
+
return cy.wrapComponent(subject, o).balTabsFindItems(o).should(function($o) {
|
|
626
|
+
var dataItems = $o.map(function(_, el) {
|
|
627
|
+
return Cypress.$(el).attr("data-" + dataKey);
|
|
628
|
+
});
|
|
629
|
+
expect(dataItems.get()).to.deep.eq(labels);
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
Cypress.Commands.add("balTabItemShouldHaveState", {
|
|
633
|
+
prevSubject: true
|
|
634
|
+
}, function(subject, state, options) {
|
|
635
|
+
if (state === void 0) state = "done";
|
|
636
|
+
log("balTabItemShouldHaveState", "", subject, options);
|
|
637
|
+
var o = wrapOptions(options);
|
|
638
|
+
return cy.wrapComponent(subject, o).should("have.class", "bal-tabs__steps__item--" + state);
|
|
639
|
+
});
|
|
640
|
+
Cypress.Commands.add("balTabItemShouldBeActive", {
|
|
641
|
+
prevSubject: true
|
|
642
|
+
}, function(subject, active, options) {
|
|
643
|
+
if (active === void 0) active = true;
|
|
644
|
+
log("balTabItemShouldBeActive", "", subject, options);
|
|
645
|
+
var o = wrapOptions(options);
|
|
646
|
+
if (active) {
|
|
647
|
+
return cy.wrapComponent(subject, o).should("have.class", "bal-tabs__steps__item--active");
|
|
648
|
+
}
|
|
649
|
+
return cy.wrapComponent(subject, o).should("not.have.class", "bal-tabs__steps__item--active");
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
Cypress.Commands.add("balToastFind", {
|
|
653
|
+
prevSubject: false
|
|
654
|
+
}, function(options) {
|
|
655
|
+
var o = wrapOptions(options);
|
|
656
|
+
return cy.getComponent(selectors.toast.main, o).then(function($el) {
|
|
657
|
+
log("balToastFind", "", $el, options);
|
|
658
|
+
return $el;
|
|
659
|
+
}).waitForComponents(o);
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
Cypress.Commands.add("balFieldFindHint", {
|
|
663
|
+
prevSubject: true
|
|
664
|
+
}, function(subject, options) {
|
|
665
|
+
var o = wrapOptions(options);
|
|
666
|
+
return cy.wrapComponent(subject, o).find(selectors.field.hint, o).then(function($el) {
|
|
667
|
+
log("balFieldFindHint", "", $el, options);
|
|
668
|
+
return $el;
|
|
669
|
+
}).waitForComponents();
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
Cypress.Commands.add("balInputStepperIncrease", {
|
|
673
|
+
prevSubject: true
|
|
674
|
+
}, function(subject, options) {
|
|
675
|
+
log("balInputStepperIncrease", "", subject, options);
|
|
676
|
+
var o = wrapOptions(options);
|
|
677
|
+
return cy.wrapComponent(subject, o).find('[data-testid="bal-input-stepper-increase"]', o).click(o).wrapComponent(subject, o);
|
|
678
|
+
});
|
|
679
|
+
Cypress.Commands.add("balInputStepperDecrease", {
|
|
680
|
+
prevSubject: true
|
|
681
|
+
}, function(subject, options) {
|
|
682
|
+
log("balInputStepperDecrease", "", subject, options);
|
|
683
|
+
var o = wrapOptions(options);
|
|
684
|
+
return cy.wrapComponent(subject, o).find('[data-testid="bal-input-stepper-decrease"]', o).click(o).wrapComponent(subject, o);
|
|
685
|
+
});
|