Skip to content

Commit

Permalink
FORMS-16943: added dateToDaysSinceEpoch method (#1455)
Browse files Browse the repository at this point in the history
* FORMS-16943: added dateToDaysSinceEpoch method

* FORMS-16943: added dateToDaysSinceEpoch method

* FORMS-16943: added authoring and runtime test for date comparison validation

* FORMS-16943: added authoring and runtime test for date comparison validation

* FORMS-16943: updated tests

* FORMS-16943: updated tests

* FORMS-16943: updated tests

---------

Co-authored-by: Arun Kumar Attri <[email protected]>
  • Loading branch information
arunattri26 and Arun Kumar Attri authored Nov 26, 2024
1 parent a9be9e8 commit 75e25e7
Show file tree
Hide file tree
Showing 20 changed files with 1,463 additions and 297 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="sling:Folder"
lcFolder="{Long}0"
type="lcFolder">
<jcr:content
jcr:primaryType="nt:unstructured"
jcr:title="navigate-in-panel">
<folderThumbnail/>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
jcr:primaryType="dam:Asset">
<jcr:content
cq:conf="\0"
jcr:lastModified="{Date}2024-08-20T06:03:38.597Z"
jcr:primaryType="dam:AssetContent"
sling:resourceType="fd/fm/af/render"
guide="1"
type="guide">
<metadata
fd:version="2.1"
jcr:language="en"
jcr:primaryType="nt:unstructured"
xmp:CreatorTool="AEM Forms AF Wizard"
allowedRenderFormat="HTML"
author="admin"
dorType="none"
formmodel="none"
themeRef="/libs/fd/af/themes/canvas"
title="basic"/>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
jcr:primaryType="dam:Asset">
<jcr:content
cq:conf="\0"
jcr:lastModified="{Date}2024-08-20T10:32:12.709Z"
jcr:primaryType="dam:AssetContent"
sling:resourceType="fd/fm/af/render"
guide="1"
type="guide">
<metadata
fd:version="2.1"
jcr:language="en"
jcr:primaryType="nt:unstructured"
xmp:CreatorTool="AEM Forms AF Wizard"
allowedRenderFormat="HTML"
author="admin"
dorType="none"
formmodel="none"
themeRef="/libs/fd/af/themes/canvas"
title="blank"/>
</jcr:content>
</jcr:root>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="sling:Folder"/>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:deviceGroups="[/etc/mobile/groups/responsive]"
cq:lastModified="{Date}2024-08-20T10:32:12.710Z"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="blank"
sling:configRef="/conf/forms/core-components-it/samples/ruleeditor/navigate-in-panel/blank/"
sling:resourceType="forms-components-examples/components/page">
<guideContainer
fd:version="2.1"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container"
dorType="none"
fieldType="form"
thankYouOption="page"
themeRef="/libs/fd/af/themes/canvas"
title="blank"/>
</jcr:content>
</jcr:root>
14 changes: 7 additions & 7 deletions ui.frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui.frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"dependencies": {
"@aemforms/af-core": "^0.22.111",
"@aemforms/af-formatters": "^0.22.109",
"@aemforms/af-custom-functions": "1.0.10"
"@aemforms/af-custom-functions": "1.0.12"
}
}
18 changes: 17 additions & 1 deletion ui.frontend/src/customFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,21 @@ export const customFunctions = {
* @param {object} globals - An object containing read-only form instance, read-only target field instance and methods for form modifications.
* @returns {string} - The captcha token.
*/
fetchCaptchaToken: cf.fetchCaptchaToken
fetchCaptchaToken: cf.fetchCaptchaToken,

/**
* Converts a date to the number of days since the Unix epoch (1970-01-01).
*
* If the input date is a number, it is assumed to represent the number of days since the epoch,
* including both integer and decimal parts. In this case, only the integer part is returned as the number of days.
*
* @param {string|Date|number} date - The date to convert.
* Can be:
* - An ISO string (yyyy-mm-dd)
* - A Date object
* - A number representing the days since the epoch, where the integer part is the number of days and the decimal part is the fraction of the day
*
* @returns {number} - The number of days since the Unix epoch
*/
dateToDaysSinceEpoch: cf.dateToDaysSinceEpoch
};
6 changes: 5 additions & 1 deletion ui.tests/test-module/libs/commons/guideSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ var selectors = {

ruleEditor : {
action : {
configure: "#EditableToolbar [data-action='CONFIGURE']",
editRule : "#EditableToolbar [data-action='editexpression']",
createRuleButton : "#create-rule-button",
saveRule : ".exp-Save-Button",
Expand All @@ -181,16 +182,19 @@ var selectors = {
EVENT_AND_COMPARISON_OPERATOR : ".choice-model.u-coral-clearFix.EVENT_AND_COMPARISON_OPERATOR",
PRIMITIVE_EXPRESSION : ".choice-model.u-coral-clearFix.PRIMITIVE_EXPRESSION.choice-model-inline",
BLOCK_STATEMENT : ".choice-model.u-coral-clearFix.BLOCK_STATEMENT",
PARAMETER : ".Parameters .choice-model.u-coral-clearFix.EXPRESSION"
PARAMETER : ".Parameters .choice-model.u-coral-clearFix.EXPRESSION",
STRING_LITERAL : ".choice-model.u-coral-clearFix .STRING_LITERAL",
},
ruleSummary : {
CREATED_RULE: "#rule-summary table[handle='table'] tr[title='Button - Click']",
DATE_PICKER_RULE: "#rule-summary table[handle='table'] tr[title='Date Input - Validate']",
SUBMISSION_SUCCESS_RULE: "#rule-summary table[handle='table'] tr[title='FORM - Successful Submission']",
SUBMISSION_FAILURE_RULE: "#rule-summary table[handle='table'] tr[title='FORM - Error in Submission']",
CUSTOM_SUBMIT_FORM_RULE: "#rule-summary table[handle='table'] tr[title='Submit - Click']",
},
operator : {
CONTAINS : "coral-selectlist [value='CONTAINS']",
EQUALS_TO : "coral-selectlist [value='EQUALS_TO']",
HIDE : "coral-selectlist [value='HIDE_STATEMENT']",
SAVE_FORM: "coral-selectlist [value='SAVE_FORM']",
FUNCTION_CALL : "coral-selectlist [value='FUNCTION_CALL']",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
const commons = require('../../../libs/commons/commons'),
sitesSelectors = require('../../../libs/commons/sitesSelectors'),
formsSelectors = require('../../../libs/commons/guideSelectors'),
afConstants = require('../../../libs/commons/formsConstants');

describe('Rule editor navigate-in-panel rule authoring',function(){
let toggle_array = [];

before(() => {
cy.fetchFeatureToggles().then((response) => {
if (response.status === 200) {
toggle_array = response.body.enabled;
}
});
});

context('Open Forms Editor', function() {
const formPath = "/content/forms/af/core-components-it/samples/ruleeditor/navigate-in-panel/blank",
formContainerPath = formPath + afConstants.FORM_EDITOR_FORM_CONTAINER_SUFFIX,
buttonEditPath = formContainerPath + "/" + afConstants.components.forms.resourceType.formbutton.split("/").pop(),
panelEditPath = formContainerPath + "/" + afConstants.components.forms.resourceType.panelcontainer.split("/").pop(),
buttonEditPathSelector = "[data-path='" + buttonEditPath + "']";

it('should add rule to focus previousItem in Panel on button click', function () {
if (toggle_array.includes("FT_FORMS-10781")) {
cy.openAuthoring(formPath);
cy.selectLayer("Edit");
cy.get(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/*']").should("exist");

cy.insertComponent(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/*']",
"Adaptive Form Panel", afConstants.components.forms.resourceType.panelcontainer);
cy.get(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/panelcontainer/*']").should("exist");
cy.wait(1000);

cy.insertComponent(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/panelcontainer/*']",
"Adaptive Form Text Box", afConstants.components.forms.resourceType.formtextinput);
cy.insertComponent(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/panelcontainer/*']",
"Adaptive Form Text Box", afConstants.components.forms.resourceType.formtextinput);

cy.insertComponent(sitesSelectors.overlays.overlay.component + "[data-path='" + formContainerPath + "/*']",
"Adaptive Form Button", afConstants.components.forms.resourceType.formbutton);
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + buttonEditPathSelector);

// Edit rule option not existing on button toolbar
cy.get(formsSelectors.ruleEditor.action.editRule).should("exist");
cy.initializeEventHandlerOnChannel("af-rule-editor-initialized").as("isRuleEditorInitialized");
cy.get(formsSelectors.ruleEditor.action.editRule).click();

// click on create option from rule editor header
cy.get("@isRuleEditorInitialized").its('done').should('equal', true);
createNavigateInPanelRule();

// check and close rule editor
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.closeRuleEditor).should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.closeRuleEditor).click();

cy.get(sitesSelectors.overlays.overlay.component + buttonEditPathSelector).should("exist");
cy.selectLayer("Edit");
cy.deleteComponentByPath(buttonEditPath);
cy.deleteComponentByPath(panelEditPath);
}
})
})

const createNavigateInPanelRule = function() {
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.createRuleButton).should("be.visible").click();
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sideToggleButton + ":first").click();

// // Forms Objects option is not existing on side panel
// cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sidePanelFormObjectTab).should("exist");
// cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sidePanelFormObjectTab).then($el => {
// expect($el.text().trim()).to.equal("Form Objects");
// })
//
// // Functions option is not existing on side panel
// cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sidePanelFunctionObjectTab).should("exist");
// cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sidePanelFunctionObjectTab).then($el => {
// expect($el.text().trim()).to.equal("Functions");
// })

cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .child-choice-name").should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .child-choice-name").click();

cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .expeditor-customoverlay.is-open coral-selectlist-item[value='EVENT_SCRIPTS']")
.click({force: true});

// select the component for which rule is to written i.e. Button here
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.EVENT_AND_COMPARISON_OPERATOR + " .choice-view-default").should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.EVENT_AND_COMPARISON_OPERATOR + " .choice-view-default").click();

// IS CLICKED option not existing in 'OPERATIONS' dropdown
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.IS_CLICKED).should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.IS_CLICKED).click();

// check and click on dropdown to view the actions available
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.BLOCK_STATEMENT + " .choice-view-default").should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.BLOCK_STATEMENT + " .choice-view-default").click();

// select HIDE action from dropdown
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.NAVIGATE_IN_PANEL).should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.NAVIGATE_IN_PANEL).click({force: true});

cy.getRuleEditorIframe().find(".PANEL_FOCUS_OPTION").should("exist");
cy.getRuleEditorIframe().find(".PANEL_FOCUS_OPTION").click();

cy.getRuleEditorIframe().find(".PANEL_FOCUS_OPTION coral-selectlist [value='PREVIOUS_ITEM']").click({force: true});

cy.getRuleEditorIframe().find(".terminal-view.PANEL.VARIABLE").should("be.visible");
cy.getRuleEditorIframe().find(".terminal-view.PANEL.VARIABLE").click();

cy.getRuleEditorIframe().find(".terminal-view.PANEL.VARIABLE coral-overlay.is-open .expression-selectlist coral-selectlist-item:first").click({force: true});

cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.saveRule).should("exist");
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.saveRule).click();

// check if rule is created
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.ruleSummary.CREATED_RULE).should("exist");
}
})
Loading

0 comments on commit 75e25e7

Please sign in to comment.