Skip to content

Commit

Permalink
FORMS-13811 | Adding cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
Navneet Agarwal authored and ci-build committed Apr 12, 2024
1 parent fc07d24 commit ed90550
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?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:lastModified="{Date}2024-04-11T16:22:50.748+05:30"
cq:lastModifiedBy="admin"
cq:tags="[]"
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
jcr:description="HCaptcha"
jcr:primaryType="cq:PageContent"
jcr:title="HCAPTCHA"
sling:resourceType="forms-components-examples/components/page">
<root
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<responsivegrid
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<text_1740702241
cq:styleIds="[1644862132301]"
jcr:created="{Date}2019-02-15T19:05:53.032+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-02-15T19:09:39.787+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;h1>hCaptcha&lt;sub>v1&lt;/sub>&lt;/h1>"
textIsRich="true"/>
<text
cq:styleIds="[1544762734201]"
jcr:created="{Date}2018-12-06T19:11:23.947+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2020-07-15T13:25:39.729+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;p>hCaptcha in an Adaptive Form offers v2 checkbox and v2 invisible versions. The checkbox version allows users to solve a challenge when clicked to determine a bot or human. The invisible version presents frictionless experience and presents a challenge only for suspicious traffic. The hCaptcha can be created using the hCaptcha Core Component.&lt;p>"
textIsRich="true"/>
<teaser
cq:styleIds="[1550165685463]"
jcr:created="{Date}2019-02-14T16:41:54.952+01:00"
jcr:createdBy="admin"
jcr:description="&lt;p>GitHub&lt;/p>&#xd;&#xa;"
jcr:lastModified="{Date}2019-02-14T16:49:57.290+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Technical Documentation"
sling:resourceType="core-components-examples/components/teaser"
actionsEnabled="false"
descriptionFromPage="false"
fileReference="/content/dam/core-components-examples/library/github-logo.svg"
linkURL="https://github.com/adobe/aem-core-forms-components/tree/master/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/hCaptcha/v1/hCaptcha"
textIsRich="true"
titleFromPage="false"/>
<title_865328580
cq:styleIds="[1544759664489]"
jcr:created="{Date}2018-12-06T19:22:23.729+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-12-06T19:23:25.116+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Examples"
sling:resourceType="core/wcm/components/title/v2/title"
type="h2"/>
<title_290384408
cq:styleIds="[1544759676459]"
jcr:created="{Date}2018-12-06T19:22:48.620+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2019-05-22T11:01:40.926+03:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Standard"
sling:resourceType="core/wcm/components/title/v2/title"
type="h3"/>
<text_1337506761
jcr:created="{Date}2018-12-06T19:23:41.968+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2024-04-11T16:22:50.736+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/text/v2/text"
text="&lt;p>hCaptcha configured.&lt;/p>&#xd;&#xa;"
textIsRich="true"/>
<demo
jcr:created="{Date}2018-12-07T12:55:03.496+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-12-07T12:55:03.496+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo">
<component
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo/component">
<guideContainer
fd:version="2.1"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container"
fieldType="form">
<container
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/demo/component">
<hcaptcha_demo
jcr:created="{Date}2019-03-06T14:11:01.819+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2024-04-11T16:21:55.163+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="HCAPTCHA"
sling:resourceType="forms-core-components-it/form/hcaptcha"
cloudServicePath="passive"
description="&lt;p>This is a long description.&lt;/p>"
enabled="{Boolean}true"
fieldType="captcha"
hideTitle="false"
name="hcaptcha_demo1712830044523"
readOnly="{Boolean}false"
size="normal"
textIsRich="true"
unboundFormElement="{Boolean}false"
visible="{Boolean}true"/>
</container>
</guideContainer>
</component>
<info
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/tabs">
<properties
cq:panelTitle="Properties"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/properties"
reference="../../component/guideContainer/container"/>
<markup
cq:panelTitle="Markup"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/markup"
reference="../../component/guideContainer/container"/>
<json
cq:panelTitle="JSON"
jcr:primaryType="nt:unstructured"
sling:resourceType="core-components-examples/components/demo/json"
reference="../../component/guideContainer/container"/>
</info>
</demo>
</responsivegrid>
</root>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?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"
sling:resourceType="sling:Folder"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?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"
sling:resourceType="sling:Folder"/>
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"/>
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"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:lastModified="{Date}2024-04-11T20:29:59.973+05:30"
cq:lastModifiedBy="admin"
jcr:lastModified="{Date}2024-04-11T20:29:59.952+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="cq:PageContent"
jcr:title="alwaysChallenge"
sling:resourceType="fd/af/cloudservices/hcaptcha/page"
clientJsUrl="https://js.hcaptcha.com/1/api.js"
name="alwayschallenge"
secretKey="\{491d063e8bc644fba2402d0ef8a148d168d8396aa37c6bc1ccdd514ff609c3646ede61971c44e44efc4d48e413673de2a6120362fcfcae609ade80882fe893ad}"
serverValidationUrl="https://api.hcaptcha.com/siteverify"
siteKey="10000000-ffff-ffff-ffff-000000000001"/>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="sling:Folder"
lcFolder="{Long}0"
type="lcFolder"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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-04-11T20:32:50.407+05:30"
jcr:primaryType="dam:AssetContent"
sling:resourceType="fd/fm/af/render"
guide="1"
type="guide">
<metadata
cq:conf="/conf/core-components-it"
fd:version="2.1"
jcr:language="en"
jcr:primaryType="nt:unstructured"
xmp:CreatorTool="AEM Forms AF Wizard"
allowedRenderFormat="HTML"
author="admin"
availableInMobileApp="{Boolean}false"
dorTemplateChanged="Boolean"
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,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="sling:Folder"
hidden="true"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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:conf="/conf/core-components-it"
cq:deviceGroups="[/etc/mobile/groups/responsive]"
cq:lastModified="{Date}2024-04-11T20:32:50.409+05:30"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="basic"
sling:configRef="/conf/forms/core-components-it/samples/hcaptcha/basic/"
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"
schemaType="none"
thankYouOption="page"
themeRef="/libs/fd/af/themes/canvas"
title="basic">
<hcaptcha
jcr:created="{Date}2024-04-11T20:21:09.833+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2024-04-11T20:32:50.399+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="HCAPTCHA"
sling:resourceType="forms-core-components-it/form/hcaptcha"
cloudServicePath="alwayschallenge"
enabled="{Boolean}true"
fieldType="captcha"
hideTitle="false"
name="hcaptcha1712847069931"
readOnly="{Boolean}false"
required="{Boolean}true"
size="normal"
textIsRich="true"
unboundFormElement="{Boolean}false"
visible="{Boolean}true"/>
</guideContainer>
</jcr:content>
</jcr:root>
113 changes: 113 additions & 0 deletions ui.tests/test-module/specs/hcaptcha/hcaptcha.authoring.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright 2024 Adobe Systems Incorporated
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const sitesSelectors = require('../../libs/commons/sitesSelectors'),
afConstants = require('../../libs/commons/formsConstants');

/**
* Testing hCaptcha with Forms and Sites Editor
*/
describe('Page - Authoring', function () {

const formhcaptcha = "/apps/forms-core-components-it/form/hcaptcha";

// we can use these values to log in

const dropHCaptchaInContainer = function () {
const dataPath = "/content/forms/af/core-components-it/blank/jcr:content/guideContainer/*",
responsiveGridDropZoneSelector = sitesSelectors.overlays.overlay.component + "[data-path='" + dataPath + "']";
cy.selectLayer("Edit");
cy.insertComponent(responsiveGridDropZoneSelector, "Adaptive Form hCaptcha", formhcaptcha);
cy.get('body').click(0, 0);
}

const dropHCaptchaInSites = function () {
const dataPath = "/content/core-components-examples/library/adaptive-form/hcaptcha/jcr:content/root/responsivegrid/demo/component/guideContainer/*",
responsiveGridDropZoneSelector = sitesSelectors.overlays.overlay.component + "[data-path='" + dataPath + "']";
cy.selectLayer("Edit");
cy.insertComponent(responsiveGridDropZoneSelector, "Adaptive Form hCaptcha", formhcaptcha);
cy.get('body').click(0, 0);
}

const testHCaptchaBehaviour = function (hCaptchaEditPathSelector, hCaptchaDrop, isSites) {
if (isSites) {
dropHCaptchaInSites();
} else {
dropHCaptchaInContainer();
}
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + hCaptchaEditPathSelector);
cy.invokeEditableAction("[data-action='CONFIGURE']"); // this line is causing frame busting which is causing cypress to fail
// Check If Dialog Options Are Visible
cy.get("[name='./cloudServicePath']")
.should("exist");
cy.get("[name='./size']")
.should("exist");
cy.get("[name='./name']")
.should("exist");
cy.get("[name='./visible']")
.should("exist");
cy.get("coral-checkbox[name='./enabled']")
.should("exist");

// Checking some dynamic behaviours
cy.get('.cq-dialog-cancel').click();
cy.deleteComponentByPath(hCaptchaDrop);
}

context('Open Forms Editor', function() {
const pagePath = "/content/forms/af/core-components-it/blank",
hCaptchaEditPath = pagePath + afConstants.FORM_EDITOR_FORM_CONTAINER_SUFFIX + "/hcaptcha",
hCaptchaEditPathSelector = "[data-path='" + hCaptchaEditPath + "']",
hCaptchaDrop = pagePath + afConstants.FORM_EDITOR_FORM_CONTAINER_SUFFIX + "/" + formhcaptcha.split("/").pop();
beforeEach(function () {
// this is done since cypress session results in 403 sometimes
cy.openAuthoring(pagePath);
});

it('insert hCaptcha in form container', function () {
dropHCaptchaInContainer();
cy.deleteComponentByPath(hCaptchaDrop);
});

it ('open edit dialog of hCaptcha',{ retries: 3 }, function(){
cy.cleanTest(hCaptchaDrop).then(function(){
testHCaptchaBehaviour(hCaptchaEditPathSelector, hCaptchaDrop);
});
})
})

context('Open Sites Editor', function () {
const pagePath = "/content/core-components-examples/library/adaptive-form/hcaptcha",
hCaptchaEditPath = pagePath + afConstants.RESPONSIVE_GRID_DEMO_SUFFIX + "/guideContainer/hcaptcha",
hCaptchaEditPathSelector = "[data-path='" + hCaptchaEditPath + "']",
hCaptchaDrop = pagePath + afConstants.RESPONSIVE_GRID_DEMO_SUFFIX + '/guideContainer/' + formhcaptcha.split("/").pop();

beforeEach(function () {
// this is done since cypress session results in 403 sometimes
cy.openAuthoring(pagePath);
});

it('insert aem forms hCaptcha', function () {
dropHCaptchaInSites();
cy.deleteComponentByPath(hCaptchaDrop);
});

it('open edit dialog of aem forms hCaptcha', function() {
testHCaptchaBehaviour(hCaptchaEditPathSelector, hCaptchaDrop, true);
});
});

});

0 comments on commit ed90550

Please sign in to comment.