@m4l/testing 0.0.20 → 0.0.21-BC20260224-2

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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Registra los comandos de Accordions
3
+ */
4
+ export declare const registerAccordionsCommands: () => void;
@@ -0,0 +1,19 @@
1
+ const a = () => {
2
+ Cypress.Commands.add(
3
+ "m4lAccordionsValidateAccordions",
4
+ (o, c, r, t, l, i, n) => {
5
+ cy.get('[class^="M4LDataGrid-root"]').find("[role=row]").find("[role=gridcell]").eq(1).click(), cy.get(i).find("[role=tablist]").find("button").eq(n).should("have.text", r), cy.get('[class*="M4LTabContent-root"]').find("[role=listitem]").find("[role=list]").find('[class*="M4LAccordion-accordionRoot"]').eq(t).as("currentAccordion"), cy.get("@currentAccordion").find('[class*="M4LAccordion-accordionSummary"]').should("have.text", l).click(), cy.get("@currentAccordion").within(() => {
6
+ cy.get('[class*="MuiCollapse-hidden"]').should("exist");
7
+ }), cy.get("@currentAccordion").find('[class*="M4LAccordion-accordionSummary"]').click(), cy.get("@currentAccordion").within(() => {
8
+ cy.get('[class*="MuiCollapse-entered"]').should("exist");
9
+ }), o(c).forEach((e) => {
10
+ cy.get("@currentAccordion").find('[class*="M4LAccordion-accordionDetails"]').find('[role="property-value-form-role"]').eq(e.index).within(() => {
11
+ cy.log(`Validando nombre ${e.key}`), cy.get('[class*="M4LPropertyValue-name"]').should("have.text", e.key), cy.log(`Validando valor ${e.value}`), cy.get('[role="property-value-value-role"][class*="M4LPropertyValue-value"]').should("have.text", e.value);
12
+ });
13
+ });
14
+ }
15
+ );
16
+ };
17
+ export {
18
+ a as r
19
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Configuración del accordion
3
+ */
4
+ export type M4lAccordionsConfig = {
5
+ title: string;
6
+ key: string;
7
+ value: any;
8
+ index: number;
9
+ };
10
+
11
+ declare global {
12
+ namespace Cypress {
13
+ interface Chainable {
14
+ /**
15
+ * Valida los accordions
16
+ */
17
+ m4lAccordionsValidateAccordions(
18
+ accordions: (mockAccordions: M4lAccordionsConfig[]) => M4lAccordionsConfig[],
19
+ mockAccordions: M4lAccordionsConfig[],
20
+ tabTitle: string,
21
+ index: number,
22
+ title: string,
23
+ sectionGrid: string,
24
+ tabIndex: number,
25
+ ): Chainable<Element>;
26
+ }
27
+ }
28
+ }
29
+
30
+ export {};
@@ -1,42 +1,42 @@
1
- const u = () => {
2
- Cypress.Commands.add("m4lDataGrid", (e) => {
3
- cy.get(e).find('[class^="M4LDataGrid-root"]');
4
- }), Cypress.Commands.add("m4lDataGridValidateVisibleColumns", (e, d, l, r = 1) => {
5
- let a = 0, i = r;
6
- d(l).forEach((n) => {
7
- n.visible && (cy.log(`Validando columna visible: ${n.headerText} , index: ${i}`), i++, cy.m4lDataGrid(e).find("[role=row]").find(`[role=columnheader][aria-colindex=${i}]`).should("have.text", n.headerText), cy.m4lDataGrid(e).find("[role=row]").find(`[role=gridcell][aria-colindex=${i}]`).should("contain", n.value), cy.m4lDataGrid(e).find("[role=row]").find(`[role=columnheader][aria-colindex=${i}]`).then((s) => {
8
- const o = s.width();
9
- o !== void 0 && (a += o), cy.m4lDataGrid(e).find("[role=grid]").scrollTo(a, 0, { duration: 100, ensureScrollable: !1 });
1
+ const f = () => {
2
+ Cypress.Commands.add("m4lDataGrid", (e, n) => {
3
+ cy.get(e).find(`[class^="M4LDataGrid-root"][data-testid^="M4LDataGrid-root-${n}"]`);
4
+ }), Cypress.Commands.add("m4lDataGridValidateVisibleColumns", (e, n, l, a, r = 1) => {
5
+ let c = 0, t = r;
6
+ l(a).forEach((o) => {
7
+ o.visible && (cy.log(`Validando columna visible: ${o.headerText} , index: ${t}`), t++, cy.m4lDataGrid(e, n).find("[role=row]").find(`[role=columnheader][aria-colindex=${t}]`).should("have.text", o.headerText), cy.m4lDataGrid(e, n).find("[role=row]").find(`[role=gridcell][aria-colindex=${t}]`).should("contain", o.value), cy.m4lDataGrid(e, n).find("[role=row]").find(`[role=columnheader][aria-colindex=${t}]`).then((m) => {
8
+ const d = m.width();
9
+ d !== void 0 && (c += d), cy.m4lDataGrid(e, n).find("[role=grid]").scrollTo(c, 0, { duration: 100, ensureScrollable: !1 });
10
10
  }));
11
11
  });
12
- }), Cypress.Commands.add("m4lDataGridRow", (e, d, l) => {
13
- let r = 0, a = 0;
14
- const i = 10, n = d + 1;
15
- function s() {
16
- return cy.m4lDataGrid(e).find("[role=row]").not('[aria-rowindex="1"]').filter(`[aria-rowindex="${n}"]`).then((o) => {
17
- if (o.length > 0) {
18
- const t = o[0].getBoundingClientRect();
19
- if (t.top >= 0 && t.left >= 0 && t.bottom <= (window.innerHeight || document.documentElement.clientHeight) && t.right <= (window.innerWidth || document.documentElement.clientWidth))
20
- return cy.wrap(o);
12
+ }), Cypress.Commands.add("m4lDataGridRow", (e, n, l, a) => {
13
+ let r = 0, c = 0;
14
+ const t = 10, o = l + 1;
15
+ function m() {
16
+ return cy.m4lDataGrid(e, n).find("[role=row]").not('[aria-rowindex="1"]').filter(`[aria-rowindex="${o}"]`).then((d) => {
17
+ if (d.length > 0) {
18
+ const i = d[0].getBoundingClientRect();
19
+ if (i.top >= 0 && i.left >= 0 && i.bottom <= (window.innerHeight || document.documentElement.clientHeight) && i.right <= (window.innerWidth || document.documentElement.clientWidth))
20
+ return cy.wrap(d);
21
21
  }
22
- if (a >= i)
23
- throw new Error(`No se encontró la fila ${n} después de ${i} intentos`);
24
- return a++, cy.m4lDataGrid(e).find("[role=row]").not('[aria-rowindex="1"]').filter((m, t) => {
25
- const c = t.getBoundingClientRect();
26
- return c.top >= 0 && c.left >= 0 && c.bottom <= (window.innerHeight || document.documentElement.clientHeight) && c.right <= (window.innerWidth || document.documentElement.clientWidth);
27
- }).first().then((m) => {
28
- const t = m.height() || 0;
29
- return r += t, cy.m4lDataGrid(e).find("[role=grid]").scrollTo(0, r, { duration: 100, ensureScrollable: !1 }).then(() => s());
22
+ if (c >= t)
23
+ throw new Error(`No se encontró la fila ${o} después de ${t} intentos`);
24
+ return c++, cy.m4lDataGrid(e, n).find("[role=row]").not('[aria-rowindex="1"]').filter((u, i) => {
25
+ const s = i.getBoundingClientRect();
26
+ return s.top >= 0 && s.left >= 0 && s.bottom <= (window.innerHeight || document.documentElement.clientHeight) && s.right <= (window.innerWidth || document.documentElement.clientWidth);
27
+ }).first().then((u) => {
28
+ const i = u.height() || 0;
29
+ return r += i, cy.m4lDataGrid(e, n).find("[role=grid]").scrollTo(0, r, { duration: 100, ensureScrollable: !1 }).then(() => m());
30
30
  });
31
31
  });
32
32
  }
33
- return s().find(`[role=gridcell][aria-colindex="${l}"]`);
34
- }), Cypress.Commands.add("m4lDataGridRowAction", (e, d, l = 1, r = 1) => {
35
- cy.m4lDataGridRow(e, l, r).find("button").eq(0).should("be.visible", { timeout: 1e4 }).click(), cy.m4lMenuActionsItem(d);
36
- }), Cypress.Commands.add("m4lDataGridFindAllColumns", (e) => {
37
- cy.m4lDataGrid(e).find('[class^="M4LDataGrid-actionsConfigContainer"]').find("button").eq(2).click();
33
+ return m().find(`[role=gridcell][aria-colindex="${a}"]`);
34
+ }), Cypress.Commands.add("m4lDataGridRowAction", (e, n, l, a = 1, r = 1) => {
35
+ cy.m4lDataGridRow(e, n, a, r).find("button").eq(0).should("be.visible", { timeout: 1e4 }).click(), cy.m4lMenuActionsItem(l);
36
+ }), Cypress.Commands.add("m4lDataGridFindAllColumns", (e, n) => {
37
+ cy.m4lDataGrid(e, n).find('[class^="M4LDataGrid-actionsConfigContainer"]').find("button").eq(2).click();
38
38
  });
39
39
  };
40
40
  export {
41
- u as r
41
+ f as r
42
42
  };
@@ -1,13 +1,19 @@
1
- declare global {
2
- export type M4LDataGridCypressColumn = {
1
+ /**
2
+ * Configuración de columna para DataGrid en Cypress
3
+ */
4
+ export type M4LDataGridCypressColumn = {
5
+ key: string;
6
+ value: any;
7
+ headerText: string;
8
+ visible: boolean;
9
+ };
3
10
 
4
- key: string;
5
- value: any;
6
- headerText: string;
7
- visible: boolean;
8
- }
9
- export type M4LGetCypressDataGridColumnsConfig<T> = (data: T) => M4LDataGridCypressColumn[];
11
+ /**
12
+ * Función que obtiene la configuración de columnas del DataGrid
13
+ */
14
+ export type M4LGetCypressDataGridColumnsConfig<T> = (data: T) => M4LDataGridCypressColumn[];
10
15
 
16
+ declare global {
11
17
  namespace Cypress {
12
18
  interface Chainable {
13
19
  /**
@@ -15,16 +21,18 @@ declare global {
15
21
  * @param selector selector del grid
16
22
  * @returns el grid
17
23
  */
18
- m4lDataGrid(selector: string): Chainable<Element>
24
+ m4lDataGrid(selector: string, gridDataTestid: string): Chainable<Element>
19
25
  /**
20
26
  * Valida las columnas visibles del grid
21
27
  * @param selector selector del grid
28
+ * @param gridDataTestid testid del grid
22
29
  * @param getColumnsConfig función que obtiene las columnas visibles del grid
23
30
  * @param mockData datos del grid
24
31
  * @param baseColumnIndex índice de la columna a obtener
25
32
  */
26
33
  m4lDataGridValidateVisibleColumns<T>(
27
34
  selector: string,
35
+ gridDataTestid: string,
28
36
  getColumnsConfig: M4LGetCypressDataGridColumnsConfig<T>,
29
37
  mockData: T,
30
38
  baseColumnIndex?: number
@@ -32,14 +40,16 @@ declare global {
32
40
  /**
33
41
  * Obtiene la fila del grid especificada por el índice de base 1, garantizando que esté visible en el viewport
34
42
  * @param selector selector del grid
43
+ * @param gridDataTestid testid del grid
35
44
  * @param targetRowBaseOneIndex índice de la fila a obtener
36
45
  * @param baseOneColumnIndex índice de la columna a obtener
37
46
  * @returns la fila del grid
38
47
  */
39
- m4lDataGridRow(selector: string, targetRowBaseOneIndex: number, baseOneColumnIndex: number): Chainable<JQuery<HTMLElement>>;
48
+ m4lDataGridRow(selector: string, gridDataTestid: string, targetRowBaseOneIndex: number, baseOneColumnIndex: number): Chainable<JQuery<HTMLElement>>;
40
49
  /**
41
50
  * Obtiene el rowAction del menuActions asociado a la fila del grid especificada por el índice de base 1
42
51
  * @param selector selector del grid
52
+ * @param gridDataTestid testid del grid
43
53
  * @param menuItemIndex índice del item del menuActions
44
54
  * @param baseOneTargetRowIndex índice de la fila a obtener
45
55
  * @param baseColbaseOneColumnIndexumnIndex índice de la columna a obtener
@@ -47,6 +57,7 @@ declare global {
47
57
  */
48
58
  m4lDataGridRowAction(
49
59
  selector: string,
60
+ gridDataTestid: string,
50
61
  menuItemIndex: number,
51
62
  baseOnetargetRowIndex?: number,
52
63
  baseOneColumnIndex?: number,
@@ -54,8 +65,10 @@ declare global {
54
65
 
55
66
  /**
56
67
  * Busca y muestra todas las columnas del grid principal
68
+ * @param selector selector del grid
69
+ * @param gridDataTestid testid del grid
57
70
  */
58
- m4lDataGridFindAllColumns(selector: string): Chainable<Element>
71
+ m4lDataGridFindAllColumns(selector: string, gridDataTestid: string): Chainable<Element>
59
72
  }
60
73
  }
61
74
  }
@@ -1,12 +1,28 @@
1
- const n = () => {
1
+ const u = '[class*="M4LSplitLayout-splitDetail"]', E = () => {
2
2
  Cypress.Commands.add("m4lDynamicFilterInputClick", () => {
3
3
  cy.get('[class*="M4LDynamicFilter-root"]').find('[class*="M4LDynamicFilter-inputFilter"]').find("input").click();
4
- }), Cypress.Commands.add("m4lDynamicFilterApplyedDateField", (i) => {
5
- cy.m4lDynamicFilterInputClick(), cy.m4lPopover().find("li").contains(i).click(), cy.m4lPopover().find("button").contains("N_D:[common_actions.intro]").click();
6
- }), Cypress.Commands.add("m4lDynamicFilterRefreshButton", (i) => {
7
- cy.get(i).find('[class*="M4LDynamicFilter-root"]').find('[class*="M4LDynamicFilter-actions"]').find('[class*="MuiButtonBase-root"]').eq(1);
8
- });
4
+ }), Cypress.Commands.add("m4lDynamicFilterApplyedDateField", (e) => {
5
+ cy.m4lDynamicFilterInputClick(), cy.m4lPopover().find("li").contains(e).click(), cy.m4lPopover().find("button").contains("N_D:[common_actions.intro]").click();
6
+ }), Cypress.Commands.add("m4lDynamicFilterRefreshButton", (e) => {
7
+ cy.get(e).find('[class*="M4LDynamicFilter-root"]').find('[class*="M4LDynamicFilter-actions"]').find('[class*="MuiButtonBase-root"]').eq(1);
8
+ }), Cypress.Commands.add(
9
+ "m4lDynamicFilterValidateFilterAndSortOptions",
10
+ (e, a, n, o, c, l) => {
11
+ const i = () => cy.get('[role="presentation"]', { timeout: 1e3 }).should("exist"), r = (t) => {
12
+ i(), cy.get('[role="presentation"]', { timeout: 1e3 }).find("li").contains(t.key).click(), cy.get('[role="presentation"]', { timeout: 1e3 }).find('[class*="MuiPaper-root-MuiPopover-paper"]').should("be.visible").find("input").eq(t.inputIndex).click({ force: !0 });
13
+ }, d = () => {
14
+ cy.get("[role=presentation]").find("button").contains("N_D:[common_actions.intro]").click({ force: !0 });
15
+ }, p = (t) => {
16
+ ["select", "selectAsync", "boolean"].includes(t.type) ? (i(), cy.get('[role="presentation"]', { timeout: 1e3 }).find("li").eq(0).click({ force: !0 }), cy.get("[role=presentation]").find('[class*="MuiPaper-root-MuiPopover-paper"]').find('[class*="M4LWindowBase-headerWindowComponent"]').dblclick({ force: !0 })) : ["string", "number"].includes(t.type) && (i(), cy.get('[role="presentation"]', { timeout: 1e3 }).find("input").eq(1).type(t.value));
17
+ }, s = (t, m, y, T) => {
18
+ cy.log(`Validando filtro ${t.key}`), cy.get(m, { timeout: 1e3 }).find(y).eq(T).click(), r(t), p(t), d();
19
+ };
20
+ e(a).forEach((t) => {
21
+ l ? (s(t, n, o, c), cy.get(`${u} [class*="M4LDynamicFilter-actions"] button`).eq(1).click(), cy.wait(t.endpoint, { timeout: 1e3 })) : (s(t, n, o, c), cy.wait(t.endpoint, { timeout: 1e3 }).wait("@getList", { timeout: 1e3 }));
22
+ });
23
+ }
24
+ );
9
25
  };
10
26
  export {
11
- n as r
27
+ E as r
12
28
  };
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Configuración del filtro para DynamicFilter
3
+ */
4
+ export type M4lDynamicFilterConfig = {
5
+ type: string;
6
+ key: string;
7
+ value: string;
8
+ endpoint: string;
9
+ inputIndex: number;
10
+ };
11
+
1
12
  declare global {
2
13
  namespace Cypress {
3
14
  interface Chainable {
@@ -13,6 +24,17 @@ declare global {
13
24
  * Obtiene el botón de refrescar
14
25
  */
15
26
  m4lDynamicFilterRefreshButton(selector: string): Chainable<Element>;
27
+ /**
28
+ * Valida opciones de filtro y orden para DynamicFilter
29
+ */
30
+ m4lDynamicFilterValidateFilterAndSortOptions(
31
+ filters: (mockFilters: M4lDynamicFilterConfig[]) => M4lDynamicFilterConfig[],
32
+ mockFilters: M4lDynamicFilterConfig[],
33
+ filtersOrSort: string,
34
+ section: string,
35
+ index: number,
36
+ logs?: boolean,
37
+ ): Chainable<Element>;
16
38
  }
17
39
  }
18
40
  }
@@ -1,3 +1,4 @@
1
+ export * from './Accordions/commands';
1
2
  export * from './DataGrid/commands';
2
3
  export * from './DynamicFilter/commands';
3
4
  export * from './DynamicSort/commands';
@@ -1 +1,4 @@
1
1
  export { registerCommands } from './register';
2
+ export type { M4lDynamicFilterConfig } from './components/DynamicFilter/types';
3
+ export type { M4lAccordionsConfig } from './components/Accordions/types';
4
+ export type { M4LDataGridCypressColumn, M4LGetCypressDataGridColumnsConfig } from './components/DataGrid/types';
@@ -1,15 +1,16 @@
1
- import { r } from "./components/DataGrid/commands.js";
2
- import { r as m } from "./components/DynamicFilter/commands.js";
3
- import { r as o } from "./components/DynamicSort/commands.js";
4
- import { r as s } from "./components/MenuActions/commands.js";
5
- import { r as e } from "./components/Popover/commands.js";
1
+ import { r } from "./components/Accordions/commands.js";
2
+ import { r as m } from "./components/DataGrid/commands.js";
3
+ import { r as o } from "./components/DynamicFilter/commands.js";
4
+ import { r as s } from "./components/DynamicSort/commands.js";
5
+ import { r as e } from "./components/MenuActions/commands.js";
6
+ import { r as i } from "./components/Popover/commands.js";
6
7
  import { r as t } from "./components/PropertyValue/commands.js";
7
8
  import { r as a } from "./components/Tab/commands.js";
8
- import { r as i } from "./components/WindowBase/commands.js";
9
- import { r as n } from "./intercepts/noPrivileges/interceptCommands.js";
10
- const P = () => {
11
- r(), m(), o(), s(), e(), t(), a(), i(), n();
9
+ import { r as n } from "./components/WindowBase/commands.js";
10
+ import { r as d } from "./intercepts/noPrivileges/interceptCommands.js";
11
+ const v = () => {
12
+ r(), m(), o(), s(), e(), i(), t(), a(), n(), d();
12
13
  };
13
14
  export {
14
- P as r
15
+ v as r
15
16
  };
package/e2e/cypress.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference path="./commands/components/Accordions/types.d.ts" />
1
2
  /// <reference path="./commands/components/DataGrid/types.d.ts" />
2
3
  /// <reference path="./commands/components/DynamicFilter/types.d.ts" />
3
4
  /// <reference path="./commands/components/DynamicSort/types.d.ts" />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/testing",
3
3
  "description": "Shared testing utilities for MFs",
4
- "version": "0.0.20",
4
+ "version": "0.0.21-BC20260224-2+prueba-cypress",
5
5
  "license": "UNLICENSED",
6
6
  "author": "M4L Team",
7
7
  "scripts": {