@baloise/ds-testing 16.0.3-nightly.20240409 → 16.0.3-nightly.20240411

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.
@@ -4,11 +4,9 @@ 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,13 +49,13 @@ 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);
52
+ return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"], button[id="' + forAttributeValue + '"]', o);
55
53
  }).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);
58
+ return cy.get('input[id="' + forAttributeValue + '"], textarea[id="' + forAttributeValue + '"], button[id="' + forAttributeValue + '"]', o);
61
59
  }).then(o, function($el) {
62
60
  return log(!!subject ? "-getByLabelText" : "getByLabelText", labelText, $el, options);
63
61
  });
@@ -69,7 +67,7 @@ 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 element = subject ? cy.wrap(subject, o).find('input[placeholder="' + placeholder + '"], textarea[placeholder="' + placeholder + '"], [data-placeholder="' + placeholder + '"]', o).waitForComponents(o) : cy.get('input[placeholder="' + placeholder + '"], textarea[placeholder="' + placeholder + '"], [data-placeholder="' + placeholder + '"]', o).waitForComponents(o);
73
71
  element.then(o, function($el) {
74
72
  return log(!!subject ? "-getByPlaceholder" : "getByPlaceholder", placeholder, $el, options);
75
73
  });
@@ -100,11 +98,9 @@ Cypress.Commands.add("getByRole", {
100
98
  var visibleElements = filterVisibleElements(buttons);
101
99
  var labeledElements = filterLabeling(visibleElements);
102
100
  if (labeledElements.length > 0) {
103
- var firstElement = cy.wrap(labeledElements[0]).waitForComponents();
104
- firstElement.then(o, function($el) {
101
+ return cy.wrap(labeledElements[0], o).waitForComponents(o).then(o, function($el) {
105
102
  return log(!!subject ? "-getByRole" : "getByRole", role + " " + JSON.stringify(options), $el, options);
106
103
  });
107
- return firstElement;
108
104
  }
109
105
  return subject;
110
106
  });
@@ -163,8 +159,10 @@ Cypress.Commands.add("waitForComponents", {
163
159
  }).then(function(document) {
164
160
  return document.fonts.ready;
165
161
  });
166
- log("waitForComponents", "", subject, options);
167
162
  var o = wrapOptions(options);
163
+ if (o.log) {
164
+ log("waitForComponents", "", subject, options);
165
+ }
168
166
  return cy.wrap(subject, o).then(function($el) {
169
167
  return areComponentsReady($el);
170
168
  }).then(function() {
package/helpers.esm.js CHANGED
@@ -297,7 +297,9 @@ var wrapCommand = function(displayName, element, message, fn) {
297
297
  return function(selector) {
298
298
  return cy.wrapComponent(element, {
299
299
  log: false
300
- }).waitForComponents().find(selector, {
300
+ }).waitForComponents({
301
+ log: false
302
+ }).find(selector, {
301
303
  log: false
302
304
  }).then(function($el) {
303
305
  Cypress.log({
@@ -325,6 +327,7 @@ var log = function(displayName, message, $el, options) {
325
327
  message: message
326
328
  });
327
329
  }
330
+ return $el;
328
331
  };
329
332
  var areComponentsReady = function($el) {
330
333
  var queue = [];
@@ -350,10 +353,16 @@ function checkAriaLabel(element, label) {
350
353
  if (label === undefined || label === null || label === "") {
351
354
  return true;
352
355
  }
356
+ var text = Cypress.$(element).text().trim();
353
357
  var ariaLabel = Cypress.$(element).attr("aria-label");
354
358
  var title = Cypress.$(element).attr("title");
355
- var text = Cypress.$(element).text().trim();
356
- return text === label.trim() || ariaLabel === label.trim() || title === label.trim();
359
+ var value = Cypress.$(element).attr("value");
360
+ return [
361
+ text,
362
+ ariaLabel,
363
+ title,
364
+ value
365
+ ].includes(label.trim());
357
366
  }
358
367
 
359
368
  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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baloise/ds-testing",
3
- "version": "16.0.3-nightly.20240409",
3
+ "version": "16.0.3-nightly.20240411",
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-nightly.20240409",
15
+ "@baloise/ds-core": "16.0.3-nightly.20240411",
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
  }
@@ -42,7 +42,7 @@ export declare const isInputDate: isElementType;
42
42
  export declare const wrapOptions: (options: any) => any;
43
43
  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
44
  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;
45
+ export declare const log: (displayName: string, message: any, $el: any, options?: Partial<Cypress.Loggable>) => any;
46
46
  export declare const areComponentsReady: ($el: any) => Promise<void[]>;
47
47
  export declare const testOnPlatforms: (platforms: Platforms[], fn: (platform: Platforms) => Promise<void> | void) => void;
48
48
  export declare function checkAriaLabel(element: HTMLElement, label: string | undefined | null): boolean;