@globisnv/cypress-core 2.3.0 → 2.3.1
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.
|
@@ -15,6 +15,17 @@ const extractSelectorParts = (selector) => {
|
|
|
15
15
|
return { baseSelector: selector.slice(0, -1), index: last };
|
|
16
16
|
return { baseSelector: selector, index: 0 };
|
|
17
17
|
};
|
|
18
|
+
// Row index of an element repeated per row, undefined when it is not in a row. AG Grid rows carry it in `row-index`.
|
|
19
|
+
// A list form component in paging mode (ListFormComponent.pagingMode) draws its rows as plain `.svy-listformcomponent-row`
|
|
20
|
+
// siblings without that attribute, so there the position among them is the index. AG Grid rows of a list form component
|
|
21
|
+
// have that class too, inside the `row-index` cell, which is why `row-index` is checked first.
|
|
22
|
+
const getRowIndex = (el) => {
|
|
23
|
+
const rowIndexEl = el.closest('[row-index]');
|
|
24
|
+
if (rowIndexEl)
|
|
25
|
+
return Number(rowIndexEl.getAttribute('row-index'));
|
|
26
|
+
const pagingRow = el.closest('.svy-listformcomponent-row');
|
|
27
|
+
return pagingRow?.parentElement ? Array.from(pagingRow.parentElement.querySelectorAll(':scope > .svy-listformcomponent-row')).indexOf(pagingRow) : undefined;
|
|
28
|
+
};
|
|
18
29
|
// When index refers to a grid row (element repeated per row), GLO_getElement handles row filtering via the full selector.
|
|
19
30
|
// When index refers to a sub-input within a single element (e.g. a field with two inputs), the caller uses eq(index).
|
|
20
31
|
// This helper distinguishes the two cases synchronously.
|
|
@@ -23,7 +34,7 @@ const isGridRowSelector = (baseSelector, index) => {
|
|
|
23
34
|
return false;
|
|
24
35
|
const selectorStr = baseSelector.length === 2 ? `[data-cy$="${baseSelector[0]}.${baseSelector[1]}"]` : `[name="${baseSelector[0]}"]`;
|
|
25
36
|
const el = Cypress.$(`div[formslist]:not([hidden]) ${selectorStr}`)[0];
|
|
26
|
-
return !!el
|
|
37
|
+
return !!el && getRowIndex(el) !== undefined;
|
|
27
38
|
};
|
|
28
39
|
// Row queries must ignore grids that are not on screen, but neither obvious filter does that job.
|
|
29
40
|
// Servoy marks the *containers* hidden - `div[formslist][hidden]` for background programs,
|
|
@@ -40,8 +51,8 @@ const pickByRowIndex = (chain, index, log = false, timeout = defaultTimeout) =>
|
|
|
40
51
|
if (log)
|
|
41
52
|
Cypress.log({ name: 'idx', message: String(index) });
|
|
42
53
|
return chain.filter((i, el) => {
|
|
43
|
-
const
|
|
44
|
-
return
|
|
54
|
+
const rowIndex = getRowIndex(el);
|
|
55
|
+
return rowIndex !== undefined ? rowIndex === index : i === index;
|
|
45
56
|
}, { timeout });
|
|
46
57
|
};
|
|
47
58
|
Cypress.Commands.add('GLO_getElement', (selectorArg, options = {}) => {
|