@baloise/ds-testing 16.0.3 → 16.1.0-nightly.20240418

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,12 @@
1
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';
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, f as isDropDown } from './helpers.esm.js';
3
3
  import { balViewport } from './viewports.esm.js';
4
4
 
5
5
  Cypress.Commands.add("getByTestId", function(testID, options) {
6
6
  var o = wrapOptions(options);
7
- var element = cy.get(byTestId(testID), o).waitForComponents(o);
8
- element.then(o, function($el) {
7
+ return cy.get(byTestId(testID), o).waitForComponents(o).then(o, function($el) {
9
8
  return log("getByTestId", testID, $el, options);
10
9
  });
11
- return element;
12
10
  });
13
11
  Cypress.Commands.add("getDescribingElement", {
14
12
  prevSubject: [
@@ -51,14 +49,14 @@ Cypress.Commands.add("getByLabelText", {
51
49
  var o = wrapOptions(options);
52
50
  if (subject) {
53
51
  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) {
52
+ return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"], button[id="' + forAttributeValue + '"]', o);
53
+ }).first(o).then(o, function($el) {
56
54
  return log(!!subject ? "-getByLabelText" : "getByLabelText", labelText, $el, options);
57
55
  });
58
56
  } else {
59
57
  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) {
58
+ return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"], button[id="' + forAttributeValue + '"]', o);
59
+ }).first(o).then(o, function($el) {
62
60
  return log(!!subject ? "-getByLabelText" : "getByLabelText", labelText, $el, options);
63
61
  });
64
62
  }
@@ -69,7 +67,8 @@ Cypress.Commands.add("getByPlaceholder", {
69
67
  ]
70
68
  }, function(subject, placeholder, options) {
71
69
  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);
70
+ var selector = 'input[placeholder="' + placeholder + '"], textarea[placeholder="' + placeholder + '"], [data-placeholder="' + placeholder + '"]';
71
+ var element = subject ? cy.wrap(subject, o).find(selector, o).first(o).waitForComponents(o) : cy.get(selector, o).first(o).waitForComponents(o);
73
72
  element.then(o, function($el) {
74
73
  return log(!!subject ? "-getByPlaceholder" : "getByPlaceholder", placeholder, $el, options);
75
74
  });
@@ -85,7 +84,7 @@ Cypress.Commands.add("getByRole", {
85
84
  };
86
85
  var filterVisibleElements = function filterVisibleElements(elements) {
87
86
  return elements.filter(function(element) {
88
- var isElementAriaHidden = options.hidden === true ? false : !!Cypress.$(element).attr("aria-hidden");
87
+ var isElementAriaHidden = options.hidden === true ? false : Cypress.$(element).attr("aria-hidden") === "true";
89
88
  return !isElementAriaHidden;
90
89
  });
91
90
  };
@@ -100,11 +99,9 @@ Cypress.Commands.add("getByRole", {
100
99
  var visibleElements = filterVisibleElements(buttons);
101
100
  var labeledElements = filterLabeling(visibleElements);
102
101
  if (labeledElements.length > 0) {
103
- var firstElement = cy.wrap(labeledElements[0]).waitForComponents();
104
- firstElement.then(o, function($el) {
102
+ return cy.wrap(labeledElements[0], o).waitForComponents(o).then(o, function($el) {
105
103
  return log(!!subject ? "-getByRole" : "getByRole", role + " " + JSON.stringify(options), $el, options);
106
104
  });
107
- return firstElement;
108
105
  }
109
106
  return subject;
110
107
  });
@@ -163,8 +160,10 @@ Cypress.Commands.add("waitForComponents", {
163
160
  }).then(function(document) {
164
161
  return document.fonts.ready;
165
162
  });
166
- log("waitForComponents", "", subject, options);
167
163
  var o = wrapOptions(options);
164
+ if (o.log) {
165
+ log("waitForComponents", "", subject, options);
166
+ }
168
167
  return cy.wrap(subject, o).then(function($el) {
169
168
  return areComponentsReady($el);
170
169
  }).then(function() {
@@ -516,16 +515,21 @@ Cypress.Commands.add("balSelectFindOptions", {
516
515
  prevSubject: true
517
516
  }, function(subject, options) {
518
517
  var o = wrapOptions(options);
519
- return cy.wrapComponent(subject, o).find(selectors.select.options, o).then(function($el) {
520
- log("balSelectFindOptions", "", $el, options);
521
- return $el;
522
- }).waitForComponents(o);
518
+ if (isDropDown(subject)) {
519
+ return cy.wrapComponent(subject, o).find(selectors.dropdown.options, o).then(function($el) {
520
+ return log("balSelectFindOptions", "", $el, options);
521
+ }).waitForComponents(o);
522
+ } else {
523
+ return cy.wrapComponent(subject, o).find(selectors.select.options, o).then(function($el) {
524
+ return log("balSelectFindOptions", "", $el, options);
525
+ }).waitForComponents(o);
526
+ }
523
527
  });
524
528
  Cypress.Commands.add("balSelectShouldHaveOptions", {
525
529
  prevSubject: true
526
530
  }, function(subject, labels, dataKey, options) {
527
531
  if (dataKey === void 0) dataKey = "label";
528
- log("balAccordionIsOpen", "", subject, options);
532
+ log("balSelectShouldHaveOptions", "", subject, options);
529
533
  var o = wrapOptions(options);
530
534
  return cy.wrapComponent(subject, o).balSelectFindOptions(o).should(function($o) {
531
535
  var dataItems = $o.map(function(_, el) {
@@ -538,9 +542,9 @@ Cypress.Commands.add("balSelectFindChips", {
538
542
  prevSubject: true
539
543
  }, function(subject, options) {
540
544
  var o = wrapOptions(options);
541
- return cy.wrapComponent(subject, o).find(selectors.select.chips, o).then(function($el) {
542
- log("balSelectFindChips", "", $el, options);
543
- return $el;
545
+ var selector = isDropDown(subject) ? selectors.dropdown.chips : selectors.select.chips;
546
+ return cy.wrapComponent(subject, o).find(selector, o).then(function($el) {
547
+ return log("balSelectFindChips", "", $el, options);
544
548
  }).waitForComponents(o);
545
549
  });
546
550
 
package/helpers.esm.js CHANGED
@@ -268,6 +268,9 @@ var isTabs = function(el) {
268
268
  var isSteps = function(el) {
269
269
  return isElement(el, "BAL-STEPS");
270
270
  };
271
+ var isDropDown = function(el) {
272
+ return isElement(el, "BAL-DROPDOWN");
273
+ };
271
274
  var isSlider = function(el) {
272
275
  return isElement(el, "BAL-INPUT-SLIDER");
273
276
  };
@@ -297,7 +300,9 @@ var wrapCommand = function(displayName, element, message, fn) {
297
300
  return function(selector) {
298
301
  return cy.wrapComponent(element, {
299
302
  log: false
300
- }).waitForComponents().find(selector, {
303
+ }).waitForComponents({
304
+ log: false
305
+ }).find(selector, {
301
306
  log: false
302
307
  }).then(function($el) {
303
308
  Cypress.log({
@@ -325,6 +330,7 @@ var log = function(displayName, message, $el, options) {
325
330
  message: message
326
331
  });
327
332
  }
333
+ return $el;
328
334
  };
329
335
  var areComponentsReady = function($el) {
330
336
  var queue = [];
@@ -350,10 +356,16 @@ function checkAriaLabel(element, label) {
350
356
  if (label === undefined || label === null || label === "") {
351
357
  return true;
352
358
  }
359
+ var text = Cypress.$(element).text().trim();
353
360
  var ariaLabel = Cypress.$(element).attr("aria-label");
354
361
  var title = Cypress.$(element).attr("title");
355
- var text = Cypress.$(element).text().trim();
356
- return text === label.trim() || ariaLabel === label.trim() || title === label.trim();
362
+ var value = Cypress.$(element).attr("value");
363
+ return [
364
+ text,
365
+ ariaLabel,
366
+ title,
367
+ value
368
+ ].includes(label.trim());
357
369
  }
358
370
 
359
- export { hasTestId as A, isSteps as B, _extends as _, waitAfterFramePaint as a, waitAfterIdleCallback as b, checkAriaLabel as c, areComponentsReady as d, deepReady as e, isAccordion as f, isCheckbox as g, isDatepicker as h, isButton as i, isInput as j, isInputDate as k, log as l, isNumberInput as m, isTextarea as n, isSlider as o, isRadio as p, isSelect as q, wrapCommand as r, isTag as s, testOnPlatforms as t, hasClass as u, isHint as v, wrapOptions as w, isLabel as x, isInputStepper as y, isTabs as z };
371
+ export { isTabs as A, hasTestId as B, isSteps as C, _extends as _, waitAfterFramePaint as a, waitAfterIdleCallback as b, checkAriaLabel as c, areComponentsReady as d, deepReady as e, isDropDown as f, isAccordion as g, isCheckbox as h, isButton as i, isDatepicker as j, isInput as k, log as l, isInputDate as m, isNumberInput as n, isTextarea as o, isSlider as p, isRadio as q, isSelect as r, wrapCommand as s, testOnPlatforms as t, isTag as u, isHint as v, wrapOptions as w, hasClass as x, isLabel as y, isInputStepper as z };
package/index.esm2.js CHANGED
@@ -216,6 +216,20 @@ var byDataSelectors = function(dateTestId, dataSelectors, value) {
216
216
  * Multi select tag .
217
217
  */ chips: byTestId("bal-select-chip")
218
218
  },
219
+ dropdown: {
220
+ /**
221
+ * Native input element.
222
+ */ input: "[data-native]",
223
+ /**
224
+ * Select option.
225
+ */ options: "bal-option",
226
+ /**
227
+ * Trigger to open and close the popup.
228
+ */ trigger: byTestId("bal-dropdown-trigger"),
229
+ /**
230
+ * Multi select tag .
231
+ */ chips: byTestId("bal-dropdown-chip")
232
+ },
219
233
  popover: {
220
234
  /**
221
235
  * Popover trigger.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baloise/ds-testing",
3
- "version": "16.0.3",
3
+ "version": "16.1.0-nightly.20240418",
4
4
  "description": "The Baloise Design-System is an open source project for styling awesome web applications that follow the Baloise corporate styling guidelines.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "homepage": "https://design.baloise.dev",
13
13
  "license": "Apache-2.0",
14
14
  "dependencies": {
15
- "@baloise/ds-core": "16.0.3",
15
+ "@baloise/ds-core": "16.1.0-nightly.20240418",
16
16
  "cypress-file-upload": "~5.0.8"
17
17
  },
18
18
  "module": "./index.esm.js",
@@ -38,6 +38,6 @@ declare namespace Cypress {
38
38
  /**
39
39
  * Gets a element by the role
40
40
  */
41
- getByRole(role: 'button' | 'label', options: Partial<GetByRoleOptions & Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery>;
41
+ getByRole(role: 'button' | 'label' | 'option' | 'input', options: Partial<GetByRoleOptions & Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery>;
42
42
  }
43
43
  }
@@ -27,6 +27,7 @@ export declare const isSelect: isElementType;
27
27
  export declare const isTag: isElementType;
28
28
  export declare const isTabs: isElementType;
29
29
  export declare const isSteps: isElementType;
30
+ export declare const isDropDown: isElementType;
30
31
  export declare const isSlider: isElementType;
31
32
  export declare const isHint: isElementType;
32
33
  export declare const isTextarea: isElementType;
@@ -42,7 +43,7 @@ export declare const isInputDate: isElementType;
42
43
  export declare const wrapOptions: (options: any) => any;
43
44
  export declare const wrapCommand: (displayName: string, element: Cypress.Chainable<JQuery>, message: any, fn: ($el: any) => Cypress.Chainable<JQuery> | void) => (selector: string) => Cypress.Chainable<JQuery<HTMLElement>>;
44
45
  export declare const shouldLog: (options?: Partial<Cypress.Loggable>) => boolean;
45
- export declare const log: (displayName: string, message: any, $el: any, options?: Partial<Cypress.Loggable>) => void;
46
+ export declare const log: (displayName: string, message: any, $el: any, options?: Partial<Cypress.Loggable>) => any;
46
47
  export declare const areComponentsReady: ($el: any) => Promise<void[]>;
47
48
  export declare const testOnPlatforms: (platforms: Platforms[], fn: (platform: Platforms) => Promise<void> | void) => void;
48
49
  export declare function checkAriaLabel(element: HTMLElement, label: string | undefined | null): boolean;
@@ -229,6 +229,24 @@ export declare const selectors: {
229
229
  */
230
230
  chips: string;
231
231
  };
232
+ dropdown: {
233
+ /**
234
+ * Native input element.
235
+ */
236
+ input: string;
237
+ /**
238
+ * Select option.
239
+ */
240
+ options: string;
241
+ /**
242
+ * Trigger to open and close the popup.
243
+ */
244
+ trigger: string;
245
+ /**
246
+ * Multi select tag .
247
+ */
248
+ chips: string;
249
+ };
232
250
  popover: {
233
251
  /**
234
252
  * Popover trigger.
@@ -1,5 +1,5 @@
1
1
  import { s as selectors, p as parseDataTestID, a as byDataSelectors } from './index.esm2.js';
2
- import { f as isAccordion, i as isButton, g as isCheckbox, h as isDatepicker, j as isInput, k as isInputDate, m as isNumberInput, n as isTextarea, o as isSlider, p as isRadio, q as isSelect, r as wrapCommand, w as wrapOptions, s as isTag, u as hasClass, v as isHint, x as isLabel, y as isInputStepper, z as isTabs, A as hasTestId, B as isSteps } from './helpers.esm.js';
2
+ import { g as isAccordion, i as isButton, h as isCheckbox, j as isDatepicker, k as isInput, m as isInputDate, n as isNumberInput, o as isTextarea, p as isSlider, q as isRadio, r as isSelect, f as isDropDown, s as wrapCommand, w as wrapOptions, u as isTag, v as isHint, l as log, x as hasClass, y as isLabel, z as isInputStepper, A as isTabs, B as hasTestId, C as isSteps } from './helpers.esm.js';
3
3
 
4
4
  Cypress.Commands.overwrite("blur", function(originalFn, element, options) {
5
5
  var command = wrapCommand("blur", element, "", function($el) {
@@ -38,6 +38,9 @@ Cypress.Commands.overwrite("blur", function(originalFn, element, options) {
38
38
  if (isSelect(element)) {
39
39
  return command(selectors.select.input);
40
40
  }
41
+ if (isDropDown(element)) {
42
+ return command(selectors.dropdown.input);
43
+ }
41
44
  return originalFn(element, options);
42
45
  });
43
46
 
@@ -90,13 +93,29 @@ Cypress.Commands.overwrite("clear", function(originalFn, element, options) {
90
93
  if (isSelect(element)) {
91
94
  return command(".bal-select__control__input");
92
95
  }
96
+ if (isDropDown(element)) {
97
+ return command(selectors.dropdown.input);
98
+ }
93
99
  return originalFn(element, options);
94
100
  });
95
101
 
96
102
  Cypress.Commands.overwrite("click", function(originalFn, element, options) {
97
- var command = wrapCommand("click", element, "", function($el) {
98
- return originalFn($el, wrapOptions(options));
99
- });
103
+ var command = function(selector) {
104
+ return cy.wrapComponent(element, {
105
+ log: false
106
+ }).waitForComponents({
107
+ log: false
108
+ }).find(selector, {
109
+ log: false
110
+ }).click({
111
+ force: true,
112
+ log: false
113
+ }).then(function($el) {
114
+ return log("click", "", $el);
115
+ }).wrapComponent(element, {
116
+ log: false
117
+ });
118
+ };
100
119
  if (isAccordion(element)) {
101
120
  return command(selectors.accordion.trigger);
102
121
  }
@@ -112,12 +131,15 @@ Cypress.Commands.overwrite("click", function(originalFn, element, options) {
112
131
  if (isRadio(element)) {
113
132
  return command(selectors.radio.label);
114
133
  }
115
- if (isTag(element) && hasClass(element, "sc-bal-select")) {
116
- return command(".delete");
134
+ if (isTag(element)) {
135
+ return command(selectors.tag.close);
117
136
  }
118
137
  if (isHint(element)) {
119
138
  return command(selectors.hint.trigger);
120
139
  }
140
+ if (isDropDown(element)) {
141
+ return command(selectors.dropdown.trigger);
142
+ }
121
143
  return originalFn(element, options);
122
144
  });
123
145
 
@@ -158,6 +180,9 @@ Cypress.Commands.overwrite("focus", function(originalFn, element, options) {
158
180
  if (isSelect(element)) {
159
181
  return command(selectors.select.input);
160
182
  }
183
+ if (isDropDown(element)) {
184
+ return command(selectors.dropdown.input);
185
+ }
161
186
  return originalFn(element, options);
162
187
  });
163
188
 
@@ -337,6 +362,40 @@ var shouldAndAndCommand = function(originalFn, element, condition, key, value, o
337
362
  return originalFn(element, "not.have.attr", "data-value", key.join(","), value);
338
363
  }
339
364
  }
365
+ if (hasClass(element, "bal-dropdown__root__input")) {
366
+ var parseKey = function() {
367
+ return typeof key === "string" ? key : key.map(function(k) {
368
+ return k.trim();
369
+ }).sort().join(",");
370
+ };
371
+ switch(condition){
372
+ case "have.value":
373
+ return originalFn(element, "have.attr", "data-label", parseKey(), value);
374
+ case "not.have.value":
375
+ return originalFn(element, "not.have.attr", "data-label", parseKey(), value);
376
+ }
377
+ }
378
+ if (isDropDown(element)) {
379
+ var nativeEl = element.find(selectors.dropdown.input, {
380
+ log: false
381
+ });
382
+ var parseKey1 = function() {
383
+ return typeof key === "string" ? key : key.map(function(k) {
384
+ return k.trim();
385
+ }).sort().join(",");
386
+ };
387
+ switch(condition){
388
+ case "have.focus":
389
+ case "not.have.focus":
390
+ case "be.disabled":
391
+ case "not.be.disabled":
392
+ return originalFn(nativeEl, condition, key, value, options);
393
+ case "have.value":
394
+ return originalFn(nativeEl, "have.attr", "data-label", parseKey1(), value);
395
+ case "not.have.value":
396
+ return originalFn(nativeEl, "not.have.attr", "data-label", parseKey1(), value);
397
+ }
398
+ }
340
399
  if (isTabs(element)) {
341
400
  switch(condition){
342
401
  case "have.value":
@@ -407,6 +466,39 @@ Cypress.Commands.overwrite("select", function(originalFn, element, values, optio
407
466
  log: false
408
467
  });
409
468
  }
469
+ if (isDropDown(element)) {
470
+ var valueArray1 = [];
471
+ if (typeof values === "string") {
472
+ valueArray1.push(values);
473
+ } else {
474
+ valueArray1 = [].concat(values);
475
+ }
476
+ log("select", valueArray1, element, options);
477
+ if (valueArray1.length === 0) {
478
+ return cy.wrap(element, {
479
+ log: false
480
+ }).clear({
481
+ log: false
482
+ });
483
+ }
484
+ return cy.wrap(element, {
485
+ log: false
486
+ }).within({
487
+ log: false
488
+ }, function() {
489
+ for(var index = 0; index < valueArray1.length; index++){
490
+ var label = valueArray1[index];
491
+ cy.getByRole("option", {
492
+ name: label,
493
+ log: false
494
+ }).click({
495
+ log: false
496
+ });
497
+ }
498
+ }).wrap(element, {
499
+ log: false
500
+ });
501
+ }
410
502
  if (isTabs(element)) {
411
503
  if (typeof values === "string") {
412
504
  return cy.wrap(element, {
@@ -447,6 +539,9 @@ Cypress.Commands.overwrite("type", function(originalFn, element, content, option
447
539
  if (isInput(element)) {
448
540
  return command(selectors.input.native);
449
541
  }
542
+ if (isDropDown(element)) {
543
+ return command(selectors.dropdown.input);
544
+ }
450
545
  if (isInputDate(element)) {
451
546
  return command(selectors.dateInput.native);
452
547
  }