@m4l/testing 0.0.23 → 0.0.24
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/e2e/commands/components/Filters/types.d.ts +3 -3
- package/e2e/commands/components/Form/commands.d.ts +4 -0
- package/e2e/commands/components/Form/commands.js +11 -0
- package/e2e/commands/components/Form/cypress/assertInitialFormState/assertInitialFormState.d.ts +5 -0
- package/e2e/commands/components/Form/cypress/assertInitialFormState/assertInitialFormState.js +20 -0
- package/e2e/commands/components/Form/cypress/assertInitialFormState/type.d.ts +105 -0
- package/e2e/commands/components/Form/cypress/assertInitialFormState/type.js +1 -0
- package/e2e/commands/components/Form/cypress/assertMandatoryFields/assertMandatoryFields.d.ts +17 -0
- package/e2e/commands/components/Form/cypress/assertMandatoryFields/assertMandatoryFields.js +14 -0
- package/e2e/commands/components/Form/cypress/assertMandatoryFields/type.d.ts +28 -0
- package/e2e/commands/components/Form/cypress/assertMandatoryFields/type.js +1 -0
- package/e2e/commands/components/Form/cypress/constants.d.ts +3 -0
- package/e2e/commands/components/Form/cypress/constants.js +6 -0
- package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/fillAndAssertFormFields.d.ts +8 -0
- package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/fillAndAssertFormFields.js +29 -0
- package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/type.d.ts +5 -0
- package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/type.js +1 -0
- package/e2e/commands/components/Form/cypress/getFormScope/getFormScope.d.ts +20 -0
- package/e2e/commands/components/Form/cypress/getFormScope/getFormScope.js +8 -0
- package/e2e/commands/components/Form/cypress/proceedFormStep/proceedFormStep.d.ts +10 -0
- package/e2e/commands/components/Form/cypress/proceedFormStep/proceedFormStep.js +6 -0
- package/e2e/commands/components/Form/cypress/proceedFormStep/type.d.ts +13 -0
- package/e2e/commands/components/Form/helpers/getFieldNameDomElement.d.ts +7 -0
- package/e2e/commands/components/Form/helpers/getFieldNameDomElement.js +13 -0
- package/e2e/commands/components/Form/types.d.ts +88 -0
- package/e2e/commands/components/WindowBase/commands.js +18 -14
- package/e2e/commands/components/WindowBase/types.d.ts +24 -8
- package/e2e/commands/components/index.d.ts +1 -0
- package/e2e/commands/index.d.ts +3 -0
- package/e2e/commands/register.js +4 -3
- package/e2e/cypress.d.ts +2 -1
- package/index.js +23 -23
- package/package.json +9 -41
|
@@ -42,7 +42,7 @@ declare global {
|
|
|
42
42
|
* 0
|
|
43
43
|
* );
|
|
44
44
|
*/
|
|
45
|
-
m4lFiltersAndSortsOptionsValidation(
|
|
45
|
+
m4lFiltersAndSortsOptionsValidation (
|
|
46
46
|
filters: (mockFilters: M4lFiltersAndSortsConfig[]) => M4lFiltersAndSortsConfig[],
|
|
47
47
|
/**
|
|
48
48
|
* Mock of the filters to validate
|
|
@@ -70,7 +70,7 @@ declare global {
|
|
|
70
70
|
* @example
|
|
71
71
|
* cy.m4lDynamicFilterAndSortsPersist('[class*="M4LSplitLayout-splitDetail"]', 'Filter', 2);
|
|
72
72
|
*/
|
|
73
|
-
m4lFiltersAndSortsPersistValidation(
|
|
73
|
+
m4lFiltersAndSortsPersistValidation (
|
|
74
74
|
/**
|
|
75
75
|
* Selector for the section to validate
|
|
76
76
|
*/
|
|
@@ -88,4 +88,4 @@ declare global {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export {};
|
|
91
|
+
export { };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as s } from "./cypress/assertInitialFormState/assertInitialFormState.js";
|
|
2
|
+
import { a as r } from "./cypress/assertMandatoryFields/assertMandatoryFields.js";
|
|
3
|
+
import { f as m } from "./cypress/fillAndAssertFormFields/fillAndAssertFormFields.js";
|
|
4
|
+
import { g as o } from "./cypress/getFormScope/getFormScope.js";
|
|
5
|
+
import { p as e } from "./cypress/proceedFormStep/proceedFormStep.js";
|
|
6
|
+
const l = () => {
|
|
7
|
+
Cypress.Commands.add("m4lAssertInitialFormState", s), Cypress.Commands.add("m4lAssertMandatoryFields", r), Cypress.Commands.add("m4lGetFormScope", o), Cypress.Commands.add("m4lFillAndAssertFormFields", m), Cypress.Commands.add("m4lProceedFormStep", e);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
l as r
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { W as n, D as c } from "../constants.js";
|
|
2
|
+
import { g as d } from "../../helpers/getFieldNameDomElement.js";
|
|
3
|
+
import { g as h } from "../getFormScope/getFormScope.js";
|
|
4
|
+
const a = (e, o, t) => h(t).find(d(e.typeElement)).eq(e.index ?? o), i = (e, o) => {
|
|
5
|
+
e.forEach((t, s) => {
|
|
6
|
+
a(t, s, o).should("be.visible"), a(t, s, o).should("have.value", t.expectedValue ?? ""), t.enabled === !1 ? a(t, s, o).should("have.attr", "readonly") : a(t, s, o).should("not.have.attr", "readonly");
|
|
7
|
+
});
|
|
8
|
+
}, f = (e) => "steps" in e, g = (e) => {
|
|
9
|
+
const { endpointToWait: o } = e;
|
|
10
|
+
if (o && cy.wait(o), cy.get(n).should("be.visible"), f(e)) {
|
|
11
|
+
const { steps: t, labelNextButton: s = c } = e;
|
|
12
|
+
t.sort((r, l) => r.stepperIndex - l.stepperIndex).forEach((r, l) => {
|
|
13
|
+
l > 0 && cy.contains('[data-testid="M4LTypography-root"]', s).should("be.visible").click(), i(r.inputs, r.stepperIndex);
|
|
14
|
+
});
|
|
15
|
+
} else
|
|
16
|
+
i(e.inputs);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
g as a
|
|
20
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
interface BaseInput {
|
|
2
|
+
/**
|
|
3
|
+
* Index of the field in the form
|
|
4
|
+
*/
|
|
5
|
+
index?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Value of the field visible by default
|
|
8
|
+
*/
|
|
9
|
+
valueVisibleByDefault?: string;
|
|
10
|
+
}
|
|
11
|
+
interface InputWithoutOptions extends BaseInput {
|
|
12
|
+
/**
|
|
13
|
+
* Type of the element in the form (input, textarea)
|
|
14
|
+
*/
|
|
15
|
+
typeElement: 'input' | 'textarea';
|
|
16
|
+
/**
|
|
17
|
+
* Type of the value of the input (string, number)
|
|
18
|
+
*/
|
|
19
|
+
typeValue?: 'string' | 'number';
|
|
20
|
+
/**
|
|
21
|
+
* Value to write in the input
|
|
22
|
+
*/
|
|
23
|
+
valueToWrite?: string;
|
|
24
|
+
}
|
|
25
|
+
interface InputWithOptions extends BaseInput {
|
|
26
|
+
typeElement: 'select';
|
|
27
|
+
/**
|
|
28
|
+
* Alias of the endpoint to wait for. (Cypress alias syntax with intercept)
|
|
29
|
+
* Example: '@localesList'
|
|
30
|
+
*/
|
|
31
|
+
endpointToWait: string;
|
|
32
|
+
/**
|
|
33
|
+
* Options of the autocomplete. Only used for autocompleteAsync or select type.
|
|
34
|
+
*/
|
|
35
|
+
options: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Index to select in the list of options
|
|
38
|
+
* by default is index 0 (first option)
|
|
39
|
+
*/
|
|
40
|
+
optionIndexToSelect?: number;
|
|
41
|
+
}
|
|
42
|
+
export type InputsForm = InputWithoutOptions | InputWithOptions;
|
|
43
|
+
interface AssertInitialFormStateBaseParams {
|
|
44
|
+
/**
|
|
45
|
+
* Endpoint to wait for. (Cypress alias syntax with intercept)
|
|
46
|
+
* Example: '@getForm'
|
|
47
|
+
*/
|
|
48
|
+
endpointToWait?: string;
|
|
49
|
+
}
|
|
50
|
+
export type InitialField = Omit<InputsForm, 'valueToWrite' | 'optionIndexToSelect' | 'options' | 'valueVisibleByDefault'> & {
|
|
51
|
+
/**
|
|
52
|
+
* Expected value of the field when form is initially loaded. By default is empty string.
|
|
53
|
+
* Example: 'demo_operative'
|
|
54
|
+
*/
|
|
55
|
+
expectedValue?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the field should be enabled on initial load.
|
|
58
|
+
* By default the assertion expects enabled.
|
|
59
|
+
*/
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Step to validate.
|
|
64
|
+
* Example:
|
|
65
|
+
* {
|
|
66
|
+
* stepperIndex: 1,
|
|
67
|
+
* inputs: [{ typeElement: 'input', valueVisibleByDefault: '' }]
|
|
68
|
+
* }
|
|
69
|
+
*/
|
|
70
|
+
export interface Step {
|
|
71
|
+
/**
|
|
72
|
+
* Stepper index to validate.
|
|
73
|
+
* Example: 1
|
|
74
|
+
*/
|
|
75
|
+
stepperIndex: number;
|
|
76
|
+
/**
|
|
77
|
+
* Inputs to validate in the selected step.
|
|
78
|
+
*/
|
|
79
|
+
inputs: InitialField[];
|
|
80
|
+
}
|
|
81
|
+
export interface AssertInitialFormStateWithStepper extends AssertInitialFormStateBaseParams {
|
|
82
|
+
/**
|
|
83
|
+
* Steps to validate.
|
|
84
|
+
* Example:
|
|
85
|
+
* [{ stepperIndex: 1, inputs: [{ typeElement: 'input', valueVisibleByDefault: '' }] }]
|
|
86
|
+
*/
|
|
87
|
+
steps: Step[];
|
|
88
|
+
/**
|
|
89
|
+
* Label of the next button.
|
|
90
|
+
* By default: 'N_D:[stepper.label_next_button]'
|
|
91
|
+
*/
|
|
92
|
+
labelNextButton?: string;
|
|
93
|
+
inputs?: never;
|
|
94
|
+
}
|
|
95
|
+
export interface AssertInitialFormStateWithoutStepper extends AssertInitialFormStateBaseParams {
|
|
96
|
+
/**
|
|
97
|
+
* Inputs to validate when the form has no stepper.
|
|
98
|
+
* Example:
|
|
99
|
+
* [{ typeElement: 'input', index: 0, expectedValue: '' }]
|
|
100
|
+
*/
|
|
101
|
+
inputs: InitialField[];
|
|
102
|
+
steps?: never;
|
|
103
|
+
}
|
|
104
|
+
export type AssertInitialFormState = AssertInitialFormStateWithStepper | AssertInitialFormStateWithoutStepper;
|
|
105
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AssertMandatoryFields } from './type';
|
|
2
|
+
/**
|
|
3
|
+
* function to assert mandatory fields
|
|
4
|
+
* @param props - The properties to assert mandatory fields
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* formFieldItems: [
|
|
8
|
+
* {
|
|
9
|
+
* name: 'name',
|
|
10
|
+
* evaluateField: true,
|
|
11
|
+
* mandatory: true,
|
|
12
|
+
* },
|
|
13
|
+
* ],
|
|
14
|
+
* propertyValueSelector: '[data-testid="m4l-property-value-root-name"]',
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare const assertMandatoryFields: ({ formFieldItems, propertyValueSelector }: AssertMandatoryFields) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { g as r } from "../getFormScope/getFormScope.js";
|
|
2
|
+
const a = (s, e) => r().find(`${e}[data-testid*="${s}"]`), l = ({ formFieldItems: s, propertyValueSelector: e }) => {
|
|
3
|
+
s.forEach((t) => {
|
|
4
|
+
if (t.evaluateField !== !1)
|
|
5
|
+
if (a(t.name, e).should("contain.text", t.label), t.mandatory === !0) {
|
|
6
|
+
const o = a(t.name, e).find('[class*="M4LHelperError-root"]');
|
|
7
|
+
o.should("exist"), o.should("be.visible");
|
|
8
|
+
} else
|
|
9
|
+
a(t.name, e).find('[class*="M4LHelperError-root"]').should("not.exist");
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
l as a
|
|
14
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type FormConfig = {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
evaluateField: boolean;
|
|
5
|
+
mandatory?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface AssertMandatoryFields {
|
|
8
|
+
/**
|
|
9
|
+
* Form field items to assert if are mandatory
|
|
10
|
+
* @example
|
|
11
|
+
* [
|
|
12
|
+
* {
|
|
13
|
+
* name: 'name',
|
|
14
|
+
* value: 'John Doe',
|
|
15
|
+
* evaluateValue: true,
|
|
16
|
+
* text: 'Name',
|
|
17
|
+
* mandatory: true,
|
|
18
|
+
* },
|
|
19
|
+
* ]
|
|
20
|
+
*/
|
|
21
|
+
formFieldItems: FormConfig[];
|
|
22
|
+
/**
|
|
23
|
+
* Property value selector to assert mandatory fields. This property containts the selector of the property value of the form field.
|
|
24
|
+
* @example
|
|
25
|
+
* '[data-testid="m4l-property-value-root-name"]'
|
|
26
|
+
*/
|
|
27
|
+
propertyValueSelector: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/fillAndAssertFormFields.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FillAndAssertFormFields } from './type';
|
|
2
|
+
/**
|
|
3
|
+
* Fill and validate the inputs of the form with the data of the form
|
|
4
|
+
* @param inputs - The inputs to validate
|
|
5
|
+
* @param stepIndex - The step index to get the scope of the form
|
|
6
|
+
* @returns void
|
|
7
|
+
*/
|
|
8
|
+
export declare const fillAndAssertFormFields: ({ inputs, stepIndex }: FillAndAssertFormFields) => void;
|
package/e2e/commands/components/Form/cypress/fillAndAssertFormFields/fillAndAssertFormFields.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { g as r } from "../../helpers/getFieldNameDomElement.js";
|
|
2
|
+
import { g as i } from "../getFormScope/getFormScope.js";
|
|
3
|
+
const c = (l) => l.get('[class*="MuiAutocomplete-listbox"]').find('[class*="MuiMenuItem-root"]'), d = ({ inputs: l, stepIndex: s }) => {
|
|
4
|
+
l.forEach((e, a) => {
|
|
5
|
+
const o = i(s).find(r(e.typeElement)).eq(e?.index ?? a);
|
|
6
|
+
switch (e.valueVisibleByDefault && o.should("have.value", e.valueVisibleByDefault), e.typeElement) {
|
|
7
|
+
case "input":
|
|
8
|
+
if (e.typeValue === "number") {
|
|
9
|
+
const t = "text string testing";
|
|
10
|
+
o.type(t).should("not.have.value", t);
|
|
11
|
+
}
|
|
12
|
+
e.valueToWrite && o.should("be.visible").click().type(e.valueToWrite).should("have.value", e.valueToWrite);
|
|
13
|
+
break;
|
|
14
|
+
case "textarea":
|
|
15
|
+
e.valueToWrite && o.should("be.visible").click().type(e.valueToWrite);
|
|
16
|
+
break;
|
|
17
|
+
case "select":
|
|
18
|
+
if (o.should("be.visible").click(), e.endpointToWait && cy.wait(e.endpointToWait), e.options) {
|
|
19
|
+
for (let t = 0; t < e.options.length; t++)
|
|
20
|
+
c(o).eq(t).should("contain.text", e.options?.[t]);
|
|
21
|
+
c(o).eq(e.optionIndexToSelect ?? 0).click(), i(s).find("input").eq(e?.index ?? a).should("have.value", e.options?.[0]);
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
d as f
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to get the scope of the form based on the step index (if provided)
|
|
3
|
+
* or the whole form if no step index is provided
|
|
4
|
+
* @param stepIndex - The step index to get the scope of the form
|
|
5
|
+
* @returns The scope of the form. Examples:
|
|
6
|
+
* - Example with stepper:
|
|
7
|
+
* ```ts
|
|
8
|
+
* cy.get('[class*="M4LWindowBase-contentWindowBase"]')
|
|
9
|
+
* .find('[class*="M4LStepper-contentArea"]')
|
|
10
|
+
* .find('[class*="M4LStepper-stepContent"]')
|
|
11
|
+
* .eq(1)
|
|
12
|
+
* .find('[class*="M4LPaperForm-containerContent"]');
|
|
13
|
+
* ```
|
|
14
|
+
* - Example without stepper:
|
|
15
|
+
* ```ts
|
|
16
|
+
* cy.get('[class*="M4LWindowBase-contentWindowBase"]')
|
|
17
|
+
* .find('[class*="M4LPaperForm-containerContent"]');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const getFormScope: (stepIndex?: number) => Cypress.Chainable<JQuery<HTMLElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProceedFormStep } from './type';
|
|
2
|
+
/**
|
|
3
|
+
* Function to proceed to the next step or submit the form by clicking the button with the given label
|
|
4
|
+
* @param buttonLabel - The label of the button to click
|
|
5
|
+
* @param force - The force to click the button if true, the button will be clicked with force
|
|
6
|
+
* @returns The click action of the button with the given label
|
|
7
|
+
* @example
|
|
8
|
+
* cy.proceedFormStep({ buttonLabel: 'N_D:[stepper.label_next_button]', force: false });
|
|
9
|
+
*/
|
|
10
|
+
export declare const proceedFormStep: ({ buttonLabel, force }: ProceedFormStep) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ProceedFormStep {
|
|
2
|
+
/**
|
|
3
|
+
* The label of the button to click
|
|
4
|
+
* @example
|
|
5
|
+
* 'N_D:[stepper.label_next_button]'
|
|
6
|
+
*/
|
|
7
|
+
buttonLabel: string;
|
|
8
|
+
/**
|
|
9
|
+
* The force to click the button if true, the button will be clicked with force
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
force?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputsForm } from '../cypress/assertInitialFormState/type';
|
|
2
|
+
/**
|
|
3
|
+
* Function to get the name of the DOM element based on the type of the element
|
|
4
|
+
* @param typeElement - The type of the element
|
|
5
|
+
* @returns The name of the DOM element
|
|
6
|
+
*/
|
|
7
|
+
export declare const getFieldNameDomElement: (typeElement: InputsForm["typeElement"]) => "input" | "textarea";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AssertInitialFormState } from './cypress/assertInitialFormState/type';
|
|
2
|
+
import { AssertMandatoryFields } from './cypress/assertMandatoryFields/type';
|
|
3
|
+
import { ProceedFormStep } from './cypress/proceedFormStep/type';
|
|
4
|
+
import { FillAndAssertFormFields } from './cypress/fillAndAssertFormFields/type';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
namespace Cypress {
|
|
8
|
+
interface Chainable {
|
|
9
|
+
/**
|
|
10
|
+
* Assert initial state of a Form, with or without stepper.
|
|
11
|
+
* You need send the params with the inputs to validate.
|
|
12
|
+
* @example
|
|
13
|
+
* // Option 1: Without stepper
|
|
14
|
+
* cy.m4lAssertInitialFormState({
|
|
15
|
+
* inputs: [{ typeElement: 'input', index: 0, expectedValue: 'John Doe' }],
|
|
16
|
+
* });
|
|
17
|
+
* // Option 2: With stepper
|
|
18
|
+
* cy.m4lAssertInitialFormState({
|
|
19
|
+
* steps: [{ stepperIndex: 1, inputs: [{ typeElement: 'input', index: 0, expectedValue: 'John Doe' }] }],
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
m4lAssertInitialFormState (params: AssertInitialFormState): Chainable<void>
|
|
23
|
+
/**
|
|
24
|
+
* function to assert mandatory fields
|
|
25
|
+
* @param props - The properties to assert mandatory fields
|
|
26
|
+
* @example
|
|
27
|
+
* {
|
|
28
|
+
* formFieldItems: [
|
|
29
|
+
* {
|
|
30
|
+
* name: 'name',
|
|
31
|
+
* evaluateField: true,
|
|
32
|
+
* mandatory: true,
|
|
33
|
+
* },
|
|
34
|
+
* ],
|
|
35
|
+
* propertyValueSelector: '[data-testid="m4l-property-value-root-name"]',
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
m4lAssertMandatoryFields (params: AssertMandatoryFields): Chainable<void>
|
|
39
|
+
/**
|
|
40
|
+
* Function to get the scope of the form based on the step index (if provided)
|
|
41
|
+
* or the whole form if no step index is provided
|
|
42
|
+
* @param stepIndex (optional) - The step index to get the scope of the form
|
|
43
|
+
* @returns The scope of the form. Examples:
|
|
44
|
+
* - Example with stepper:
|
|
45
|
+
* ```ts
|
|
46
|
+
* cy.get('[class*="M4LWindowBase-contentWindowBase"]')
|
|
47
|
+
* .find('[class*="M4LStepper-contentArea"]')
|
|
48
|
+
* .find('[class*="M4LStepper-stepContent"]')
|
|
49
|
+
* .eq(1)
|
|
50
|
+
* .find('[class*="M4LPaperForm-containerContent"]');
|
|
51
|
+
* ```
|
|
52
|
+
* - Example without stepper:
|
|
53
|
+
* ```ts
|
|
54
|
+
* cy.get('[class*="M4LWindowBase-contentWindowBase"]')
|
|
55
|
+
* .find('[class*="M4LPaperForm-containerContent"]');
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
m4lGetFormScope (stepIndex?: number): Chainable<JQuery<HTMLElement>>
|
|
59
|
+
/**
|
|
60
|
+
* Fill and validate the inputs of the form with the data of the form
|
|
61
|
+
* @param inputs - The inputs to validate
|
|
62
|
+
* @param stepIndex - The step index to get the scope of the form
|
|
63
|
+
* @returns Chainable<void>
|
|
64
|
+
* @example
|
|
65
|
+
* cy.m4lFillAndAssertFormFields({
|
|
66
|
+
* inputs: [
|
|
67
|
+
* { typeElement: 'input', index: 0, valueToWrite: 'John Doe' },
|
|
68
|
+
* { typeElement: 'textarea', index: 0, valueToWrite: 'John Doe' },
|
|
69
|
+
* { typeElement: 'select', index: 0, options: ['Option 1', 'Option 2'], optionIndexToSelect: 0, endpointToWait: '@getOptions' },
|
|
70
|
+
* ],
|
|
71
|
+
* stepIndex: 1,
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
m4lFillAndAssertFormFields (params: FillAndAssertFormFields): Chainable<void>
|
|
75
|
+
/**
|
|
76
|
+
* Function to proceed to the next step or submit the form by clicking the button with the given label
|
|
77
|
+
* @param buttonLabel - The label of the button to click
|
|
78
|
+
* @param force - The force to click the button if true, the button will be clicked with force
|
|
79
|
+
* @returns Chainable<void>
|
|
80
|
+
* @example
|
|
81
|
+
* cy.proceedFormStep({ buttonLabel: 'N_D:[stepper.label_next_button]', force: false });
|
|
82
|
+
*/
|
|
83
|
+
m4lProceedFormStep (params: ProceedFormStep): Chainable<void>
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { };
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e = () => {
|
|
2
2
|
Cypress.Commands.add("m4lWindowBaseHeader", () => {
|
|
3
3
|
cy.get('[class^="M4LDragResizeWindowRND-draggableHandle"]').find('[class^="M4LDragResizeWindowRND-draggableCancel"]');
|
|
4
|
-
}), Cypress.Commands.add("m4lWindowBaseLeftAction", (
|
|
5
|
-
cy.m4lWindowBaseHeader().find("button").eq(
|
|
6
|
-
}), Cypress.Commands.add("m4lWindowBaseLeftActionClick", (
|
|
7
|
-
cy.m4lWindowBaseLeftAction(
|
|
8
|
-
}), Cypress.Commands.add("m4lWindowBaseMenuAction", (
|
|
9
|
-
cy.m4lWindowBaseHeader().find('[class*="M4LMenuActions-root-M4LWindowBase-menuActionsWindowBase"]').find("button").eq(0).click(), cy.get("[role=presentation]").find('[class^="MuiPaper-root"]').find("[role=menuitem]").eq(
|
|
10
|
-
}), Cypress.Commands.add("m4lWindowBaseMenuActionDisabled", (
|
|
11
|
-
cy.m4lWindowBaseMenuAction(
|
|
12
|
-
}), Cypress.Commands.add("m4lDialogWindowActions", (
|
|
13
|
-
cy.get('[class^="MuiDialog-container"]').find('[class^="M4LWindowBase-root"]').should("contain",
|
|
14
|
-
}), Cypress.Commands.add("m4lDialogWindowActionsValidateTitle", (
|
|
15
|
-
cy.get('[class^="M4LGridLayout-root"]').find('[class*="M4LPopupsViewer-root"]').find('[class*="M4LDragResizeWindowRND-draggableHandle"]').find('[class*="M4LTypography-root"]').should("have.text",
|
|
4
|
+
}), Cypress.Commands.add("m4lWindowBaseLeftAction", (s) => {
|
|
5
|
+
cy.m4lWindowBaseHeader().find("button").eq(s);
|
|
6
|
+
}), Cypress.Commands.add("m4lWindowBaseLeftActionClick", (s) => {
|
|
7
|
+
cy.m4lWindowBaseLeftAction(s).click({ force: !0 });
|
|
8
|
+
}), Cypress.Commands.add("m4lWindowBaseMenuAction", (s) => {
|
|
9
|
+
cy.m4lWindowBaseHeader().find('[class*="M4LMenuActions-root-M4LWindowBase-menuActionsWindowBase"]').find("button").eq(0).click(), cy.get("[role=presentation]").find('[class^="MuiPaper-root"]').find("[role=menuitem]").eq(s);
|
|
10
|
+
}), Cypress.Commands.add("m4lWindowBaseMenuActionDisabled", (s) => {
|
|
11
|
+
cy.m4lWindowBaseMenuAction(s).should("have.attr", "aria-disabled", "true");
|
|
12
|
+
}), Cypress.Commands.add("m4lDialogWindowActions", (s) => {
|
|
13
|
+
cy.get('[class^="MuiDialog-container"]').find('[class^="M4LWindowBase-root"]').should("contain", s);
|
|
14
|
+
}), Cypress.Commands.add("m4lDialogWindowActionsValidateTitle", (s) => {
|
|
15
|
+
cy.get('[class^="M4LGridLayout-root"]').find('[class*="M4LPopupsViewer-root"]').find('[class*="M4LDragResizeWindowRND-draggableHandle"]').find('[class*="M4LTypography-root"]').should("have.text", s);
|
|
16
|
+
}), Cypress.Commands.add("m4lAssertModuleHeaderTitle", (s) => {
|
|
17
|
+
cy.get('[class*="M4LWindowBase-root"]').find('[class*="M4LWindowBase-headerContentWindowBase"]').find('[class*="M4LWindowBase-containerTitleSubtitle"]').should("be.visible").should("contain.text", s);
|
|
18
|
+
}), Cypress.Commands.add("m4lAssertModuleHeaderIcon", (s) => {
|
|
19
|
+
cy.get('[class*="M4LWindowBase-root"]').find('[class*="M4LWindowBase-headerContentWindowBase"]').find('[class*="M4LIcon-root"]').find('[class*="M4LIcon-icon"]').should("be.visible").invoke("css", "mask").should("contain", s);
|
|
16
20
|
});
|
|
17
21
|
};
|
|
18
22
|
export {
|
|
19
|
-
|
|
23
|
+
e as r
|
|
20
24
|
};
|
|
@@ -6,13 +6,13 @@ declare global {
|
|
|
6
6
|
* @example
|
|
7
7
|
* cy.m4lWindowBaseHeader().find('button').first().click();
|
|
8
8
|
*/
|
|
9
|
-
m4lWindowBaseHeader(): Chainable<Element>
|
|
9
|
+
m4lWindowBaseHeader (): Chainable<Element>
|
|
10
10
|
/**
|
|
11
11
|
* Gets a button on the left side of the module by 0-based index.
|
|
12
12
|
* @example
|
|
13
13
|
* cy.m4lWindowBaseLeftAction(0).click(); // first left button
|
|
14
14
|
*/
|
|
15
|
-
m4lWindowBaseLeftAction(
|
|
15
|
+
m4lWindowBaseLeftAction (
|
|
16
16
|
/**
|
|
17
17
|
* Button position
|
|
18
18
|
*/
|
|
@@ -23,7 +23,7 @@ declare global {
|
|
|
23
23
|
* @example
|
|
24
24
|
* cy.m4lWindowBaseLeftActionClick(0);
|
|
25
25
|
*/
|
|
26
|
-
m4lWindowBaseLeftActionClick(
|
|
26
|
+
m4lWindowBaseLeftActionClick (
|
|
27
27
|
/**
|
|
28
28
|
* Button position
|
|
29
29
|
*/
|
|
@@ -34,7 +34,7 @@ declare global {
|
|
|
34
34
|
* @example
|
|
35
35
|
* cy.m4lWindowBaseMenuAction(0).click(); // click first menu item
|
|
36
36
|
*/
|
|
37
|
-
m4lWindowBaseMenuAction(
|
|
37
|
+
m4lWindowBaseMenuAction (
|
|
38
38
|
/**
|
|
39
39
|
* Button position
|
|
40
40
|
*/
|
|
@@ -45,7 +45,7 @@ declare global {
|
|
|
45
45
|
* @example
|
|
46
46
|
* cy.m4lWindowBaseMenuActionDisabled(2);
|
|
47
47
|
*/
|
|
48
|
-
m4lWindowBaseMenuActionDisabled(
|
|
48
|
+
m4lWindowBaseMenuActionDisabled (
|
|
49
49
|
/**
|
|
50
50
|
* Button position
|
|
51
51
|
*/
|
|
@@ -56,7 +56,7 @@ declare global {
|
|
|
56
56
|
* @example
|
|
57
57
|
* cy.m4lDialogWindowActions('Confirm').find('button').contains('Accept').click();
|
|
58
58
|
*/
|
|
59
|
-
m4lDialogWindowActions(
|
|
59
|
+
m4lDialogWindowActions (
|
|
60
60
|
/**
|
|
61
61
|
* Dialog title
|
|
62
62
|
*/
|
|
@@ -67,7 +67,7 @@ declare global {
|
|
|
67
67
|
* @example
|
|
68
68
|
* cy.m4lDialogWindowActionsValidateTitle('Edit item');
|
|
69
69
|
*/
|
|
70
|
-
m4lDialogWindowActionsValidateTitle(
|
|
70
|
+
m4lDialogWindowActionsValidateTitle (
|
|
71
71
|
/**
|
|
72
72
|
* Dialog title
|
|
73
73
|
*/
|
|
@@ -77,8 +77,24 @@ declare global {
|
|
|
77
77
|
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
78
78
|
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
79
79
|
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
|
80
|
+
/**
|
|
81
|
+
* Validate title module of the Window Base
|
|
82
|
+
* @example
|
|
83
|
+
* ```
|
|
84
|
+
* cy.assertModuleHeaderTitle('N_D:[module_name]');
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
m4lAssertModuleHeaderTitle (title: string): Chainable<Element>
|
|
88
|
+
/**
|
|
89
|
+
* Validate icon module of the Window Base
|
|
90
|
+
* @example
|
|
91
|
+
* ```
|
|
92
|
+
* cy.assertModuleHeaderIcon('i_common_general_action_add');
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
m4lAssertModuleHeaderIcon (icon: string): Chainable<Element>
|
|
80
96
|
}
|
|
81
97
|
}
|
|
82
98
|
}
|
|
83
99
|
|
|
84
|
-
export {};
|
|
100
|
+
export { };
|
package/e2e/commands/index.d.ts
CHANGED
|
@@ -2,3 +2,6 @@ export { registerCommands } from './register';
|
|
|
2
2
|
export type { M4lFiltersAndSortsConfig } from './components/Filters/types';
|
|
3
3
|
export type { M4lPropertyValuesAccordionsConfig } from './components/Accordions/types';
|
|
4
4
|
export type { M4LDataGridCypressColumn, M4LGetCypressDataGridColumnsConfig } from './components/DataGrid/types';
|
|
5
|
+
export * from './components/Form/cypress/assertInitialFormState/type';
|
|
6
|
+
export * from './components/Form/cypress/assertMandatoryFields/type';
|
|
7
|
+
export * from './components/Form/cypress/fillAndAssertFormFields/type';
|
package/e2e/commands/register.js
CHANGED
|
@@ -10,9 +10,10 @@ import { r as n } from "./components/WindowBase/commands.js";
|
|
|
10
10
|
import { r as d } from "./components/CommonActions/commands.js";
|
|
11
11
|
import { r as p } from "./components/Filters/commands.js";
|
|
12
12
|
import { r as g } from "./intercepts/noPrivileges/interceptCommands.js";
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import { r as C } from "./components/Form/commands.js";
|
|
14
|
+
const B = () => {
|
|
15
|
+
r(), m(), o(), s(), e(), i(), t(), a(), n(), d(), p(), g(), C();
|
|
15
16
|
};
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
B as r
|
|
18
19
|
};
|
package/e2e/cypress.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
/// <reference path="./commands/components/Tab/types.d.ts" />
|
|
10
10
|
/// <reference path="./commands/components/CommonActions/types.d.ts" />
|
|
11
11
|
/// <reference path="./commands/intercepts/noPrivileges/types.d.ts" />
|
|
12
|
+
/// <reference path="./commands/components/Form/types.d.ts" />
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
declare global {
|
|
@@ -20,4 +21,4 @@ declare global {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export {};
|
|
24
|
+
export { };
|
package/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { act as t } from "react";
|
|
2
|
+
import { beforeEach as s, describe as f, expect as a } from "vitest";
|
|
3
|
+
import { cleanup as p, fireEvent as i, renderHook as n, screen as x, waitFor as c, within as d } from "@testing-library/react";
|
|
4
|
+
import { r as u } from "./e2e/commands/register.js";
|
|
5
|
+
import { c as C } from "./testTools/utils.js";
|
|
6
|
+
import { t as b } from "./testComponents/DataGrid/helpers.js";
|
|
7
|
+
import { t as h } from "./testComponents/DynamicFilter/helpers.js";
|
|
8
|
+
import { t as w } from "./testComponents/DynamicSort/helpers.js";
|
|
9
9
|
import { default as H } from "@testing-library/user-event";
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
t as act,
|
|
12
|
+
s as beforeEach,
|
|
13
|
+
p as cleanup,
|
|
14
|
+
f as describe,
|
|
15
|
+
a as expect,
|
|
16
|
+
i as fireEvent,
|
|
17
|
+
u as registerCommands,
|
|
18
|
+
C as render,
|
|
19
|
+
n as renderHook,
|
|
20
|
+
x as screen,
|
|
21
|
+
b as testColumnConfigs,
|
|
22
|
+
h as testFilterFields,
|
|
23
|
+
w as testSortFields,
|
|
24
24
|
H as userEvent,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
c as waitFor,
|
|
26
|
+
d as within
|
|
27
27
|
};
|
package/package.json
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/testing",
|
|
3
3
|
"description": "Shared testing utilities for MFs",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.24",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "M4L Team",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"clean": "npx -y rimraf node_modules **/node_modules/ **/dist/ dist yarn.lock .yarn .config/yarn package-lock.json",
|
|
9
|
-
"typescript": "tsc --noEmit",
|
|
10
|
-
"build": "yarn lint:fix && tsc && vite build && buildM4lPackage",
|
|
11
|
-
"build:only": "vite build && buildM4lPackage",
|
|
12
|
-
"buildM4Lpackage:monorepo": "node ../m4l_vite_plugins/dist/bin/buildM4lPackage.js",
|
|
13
|
-
"build:monorepo": "yarn lint:fix && tsc && vite build",
|
|
14
|
-
"build:only:monorepo": "tsc && vite build && yarn buildM4Lpackage:monorepo",
|
|
15
|
-
"release": "yarn build && npm publish ./dist",
|
|
16
|
-
"release:monorepo": "yarn build:monorepo && cd dist && npm publish",
|
|
17
|
-
"release:monorepo:beta": "yarn build:monorepo && cd dist && npm publish --tag beta",
|
|
18
|
-
"release:monorepo:beta:only": "cd dist && npm publish --tag beta",
|
|
19
|
-
"lint": "npx eslint . --max-warnings 0",
|
|
20
|
-
"lint:fix": "yarn lint --fix --max-warnings 0",
|
|
21
|
-
"lefthook:install": "lefthook install",
|
|
22
|
-
"test": "vitest --config vitest.config.ts",
|
|
23
|
-
"test:only": "vitest --config vitest.config.ts --allowOnly",
|
|
24
|
-
"coverage": "vitest run --coverage",
|
|
25
|
-
"coverage:ui": "vitest --ui run --coverage ",
|
|
26
|
-
"docs": "typedoc --entryPointStrategy expand --tsconfig ./tsconfig.json"
|
|
27
|
-
},
|
|
28
7
|
"lint-staged": {
|
|
29
8
|
"*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
|
|
30
9
|
},
|
|
@@ -60,23 +39,6 @@
|
|
|
60
39
|
"react": "18.3.1",
|
|
61
40
|
"vitest": "3.1.1"
|
|
62
41
|
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@m4l/components": "^9.0.0",
|
|
65
|
-
"@m4l/config": "^1.1.2",
|
|
66
|
-
"@m4l/vite-plugins": "^1.1.5",
|
|
67
|
-
"@types/node": "^22.7.3",
|
|
68
|
-
"@types/react": "18.3.23",
|
|
69
|
-
"@types/react-dom": "18.3.7",
|
|
70
|
-
"eslint": "9.28.0",
|
|
71
|
-
"lefthook": "1.11.13",
|
|
72
|
-
"lint-staged": "15.5.2",
|
|
73
|
-
"react": "18.3.1",
|
|
74
|
-
"react-dom": "18.3.1",
|
|
75
|
-
"typescript": "5.8.3",
|
|
76
|
-
"vite": "6.3.5",
|
|
77
|
-
"vite-plugin-dts": "^4.2.1",
|
|
78
|
-
"vitest": "3.1.1"
|
|
79
|
-
},
|
|
80
42
|
"resolutions": {
|
|
81
43
|
"glob": "^10.4.5",
|
|
82
44
|
"react": "18.3.1",
|
|
@@ -98,7 +60,7 @@
|
|
|
98
60
|
],
|
|
99
61
|
"type": "module",
|
|
100
62
|
"source": "./index.js",
|
|
101
|
-
"main": "./index.
|
|
63
|
+
"main": "./src/index.ts",
|
|
102
64
|
"module": "./index.js",
|
|
103
65
|
"types": "./index.d.ts",
|
|
104
66
|
"sideEffects": false,
|
|
@@ -108,5 +70,11 @@
|
|
|
108
70
|
"engines": {
|
|
109
71
|
"node": ">=12.0.0"
|
|
110
72
|
},
|
|
111
|
-
"packageManager": "yarn@4.5.0"
|
|
73
|
+
"packageManager": "yarn@4.5.0",
|
|
74
|
+
"private": false,
|
|
75
|
+
"exports": {
|
|
76
|
+
".": {
|
|
77
|
+
"import": "./index.js"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
112
80
|
}
|