Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom function test cases #1206

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b5f4c72
added tests for customFunctionsEdgeDelivery
Apr 24, 2024
c28d102
changed edge delivery config for test cases
Apr 24, 2024
3c8a133
FORMS-13753 Fixing regression related to dataRef parameter (#1155)
rismehta Apr 2, 2024
55a0bcf
disable exposing view layer for customization (#1156)
barshat7 Apr 2, 2024
8530b50
FORMS-13484: Update the help link for Embed (v2) (#1154)
s1mahanty Apr 3, 2024
dfe32c5
Invalid event customization (#1157)
rismehta Apr 3, 2024
a1a8555
CQ-4348557 adding another div to stop footer getting resized (#1122)
im-shiv Apr 3, 2024
eca9cc9
FORMS-13810: Add the field to allow custom message for format in date…
s1mahanty Apr 4, 2024
2b89ab0
FORMS-13829 Drop Down View not getting updated, even if model is upda…
sakshi-arora1 Apr 4, 2024
5d1e1a4
fixed issue for Persian language (#1162)
devgurjar Apr 4, 2024
2532f2d
Added Aria Invalid attribute (#1149)
pavi41 Apr 9, 2024
4ba0e6d
FORMS-13871 text shouldn't show checkbox for rich text title (#1173)
im-shiv Apr 10, 2024
f059101
datepicker readonly does not work when edit or display format set (#1…
barshat7 Apr 10, 2024
77544d7
FORMS-12667 Update type property on replacing checkboxgroup to radio …
dmaurya929 Apr 10, 2024
7a3862d
FORMS-13760 Date picker display value not working during prefill (#1180)
rismehta Apr 10, 2024
ad32b54
Move core component to 0.13.0 spec version (#1181)
rismehta Apr 11, 2024
3f2eb05
datepicker timezone issue on view layer fixed (#1168)
barshat7 Apr 11, 2024
556a100
Updating spec version to 0.13.0 (#1186)
rismehta Apr 13, 2024
82a2a68
Added condition on description and error message in aria-describedby
Apr 16, 2024
12d0324
FORMS-12203: Added localization changes and test cases (#1152)
shivangimittal791 Apr 17, 2024
a3565a8
FORMS-13851 Support for language in date picker and number input (#1169)
rismehta Apr 18, 2024
3d5e173
FORMS-12822 : format should not be visible when no pattern is selecte…
AnurudraS Apr 22, 2024
7e90adb
FORMS-14013 - Fixing default value check in dropdown (#1199)
TalmizAhmed Apr 23, 2024
ef0453b
Revert "FORMS-14013 - Fixing default value check in dropdown (#1199)"
rismehta Apr 23, 2024
7841e47
FORMS-13209 - Added support for form submission handlers and correcte…
arunattri26 Apr 23, 2024
c707a57
FORMS-13935 update examples for aemcomponents.dev (#1204)
barshat7 Apr 29, 2024
2db297c
FORMS-14013 - Testcase added - Fixing Dropdown that had a selected va…
TalmizAhmed Apr 29, 2024
bc2bea4
Forms 11746 allow attaching same file (#1201)
rajatofficial Apr 29, 2024
64e76c1
Read-only is not working in file-attachment (#1200)
pavi41 Apr 30, 2024
d528c58
Readonly & Disable were not working in TNC component (#1211)
pavi41 May 2, 2024
88807eb
FORMS-14018 - Fix for dropdown not working when enumNames are not pro…
TalmizAhmed May 2, 2024
1947221
Moving to 15860 image (#1212)
rismehta May 2, 2024
b1aa879
FORMS-13811 | Adding rendition for hCaptcha (#1174)
navneet-ag May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 0 additions & 22 deletions .circleci/config.yml
Expand Up @@ -175,21 +175,6 @@ jobs:
conf: .circleci/codecov.yml
flags: unittests

build-java-8:
executor: forms_executor_java8
working_directory: /home/circleci/build
steps:
- checkout
- *restore_cache
- run:
name: Update permissions
command: sudo chown -R circleci /usr/local/lib/node_modules
- run:
name: Build
command: node .circleci/ci/build.js
- store_artifacts:
path: test-results/junit

cypress-chrome-cloudready-with-addon:
executor: test_executor_cloudready
environment:
Expand Down Expand Up @@ -431,31 +416,24 @@ workflows:
filters:
tags:
only: /.*/
- build-java-8:
filters:
tags:
only: /.*/
- cypress-chrome-cloudready-with-addon:
filters:
tags:
only: /.*/
requires:
- build-java-11
- build-java-8
- cypress-chrome-cloudready-with-latest-addon:
filters:
tags:
only: /.*/
requires:
- build-java-11
- build-java-8
- cypress-chrome-cloudready-with-latest-addon-without-ft:
filters:
tags:
only: /.*/
requires:
- build-java-11
- build-java-8
- jsdocs-deploy:
requires:
- build-java-11
Expand Down
2 changes: 1 addition & 1 deletion .circleci/docker-compose.yml
Expand Up @@ -6,7 +6,7 @@ services:
entrypoint: tail -f /dev/null # Keeps the container running

circleci-aem-cloudready:
image: docker-adobe-cif-release.dr-uw2.adobeitc.com/circleci-aem-cloudready:7f6c9fff9b-openjdk11
image: docker-adobe-cif-release.dr-uw2.adobeitc.com/circleci-aem-cloudready:15860-1-openjdk11
depends_on:
- circleci-qp
# Add any additional configurations or environment variables if needed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spec-validate-pr.yml
Expand Up @@ -29,7 +29,7 @@ jobs:

# Check if any commit message contains a specific keyword or pattern (e.g., "RTC")
if echo "$commit_messages" | grep -q 'RTC' && echo "$changed_files" | grep -E 'resources/schema/.*\.json$'; then
echo "Commit message contains 'RTC' keyword, and specification files have changed. Build passed. Please check if your changes are working in visual rule editor"
echo "Commit message contains 'RTC' keyword, and specification files have changed. Build passed. Please check if your changes are working in visual rule editor. Update spec version in form container dialog"
else
echo "Either commit message doesn't contain 'RTC' keyword or specification files haven't changed. Build failed. Please check if your changes are working in visual rule editor"
exit 1
Expand Down
Expand Up @@ -71,6 +71,9 @@ private FormConstants() {
/** The resource type for check box group v1 */
public static final String RT_FD_FORM_CHECKBOX_GROUP_V1 = RT_FD_FORM_PREFIX + "checkboxgroup/v1/checkboxgroup";

/** The resource type for reCaptcha v1 */
public static final String RT_FD_FORM_HCAPTCHA_V1 = RT_FD_FORM_PREFIX + "hcaptcha/v1/hcaptcha";

/** The resource type for reCaptcha v1 */
public static final String RT_FD_FORM_RECAPTCHA_V1 = RT_FD_FORM_PREFIX + "recaptcha/v1/recaptcha";

Expand Down
@@ -0,0 +1,125 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2024 Adobe
~
~ 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.inject.Inject;
import javax.inject.Named;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.aemds.guide.model.HCaptchaConfiguration;
import com.adobe.aemds.guide.service.CloudConfigurationProvider;
import com.adobe.aemds.guide.service.GuideException;
import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.HCaptcha;
import com.adobe.cq.forms.core.components.util.AbstractCaptchaImpl;
import com.fasterxml.jackson.annotation.JsonIgnore;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { HCaptcha.class,
ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_HCAPTCHA_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class HCaptchaImpl extends AbstractCaptchaImpl implements HCaptcha {

private static final Logger LOGGER = LoggerFactory.getLogger(HCaptchaImpl.class);

@Inject
private ResourceResolver resourceResolver;

private Resource resource;

@Reference
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private HCaptchaConfiguration hCaptchaConfiguration;

@OSGiService
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private CloudConfigurationProvider cloudConfigurationProvider;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@JsonIgnore
@Named("cloudServicePath")
protected String cloudServicePath;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@JsonIgnore
@Named("size")
protected String size;

private static final String SITE_KEY = "siteKey";
private static final String URI = "uri";
private static final String SIZE = "size";
private static final String THEME = "theme";
private static final String TYPE = "type";

@Override
public String getCloudServicePath() {
return cloudServicePath;
}

@Override
public String getProvider() {
return "hcaptcha";
}

@Override
public Map<String, Object> getCaptchaProperties() throws GuideException {

Map<String, Object> customCaptchaProperties = new LinkedHashMap<>();
String siteKey = null, uri = null;
resource = resourceResolver.getResource(this.getPath());
if (cloudConfigurationProvider == null) {
LOGGER.info("[AF] [Captcha] [HCAPTCHA] Error while fetching cloud configuration, upgrade to latest release to use hCaptcha.");
}
try {
if (resource != null && cloudConfigurationProvider != null) {
hCaptchaConfiguration = cloudConfigurationProvider.getHCaptchaCloudConfiguration(resource);
if (hCaptchaConfiguration != null) {
siteKey = hCaptchaConfiguration.getSiteKey();
uri = hCaptchaConfiguration.getClientSideJsUrl();
}
}
} catch (GuideException e) {
LOGGER.error("[AF] [Captcha] [HCAPTCHA] Error while fetching cloud configuration, upgrade to latest release to use hCaptcha.");
}
customCaptchaProperties.put(SITE_KEY, siteKey);
customCaptchaProperties.put(URI, uri);
customCaptchaProperties.put(SIZE, this.size);
customCaptchaProperties.put(THEME, "light");
customCaptchaProperties.put(TYPE, "image");

return customCaptchaProperties;

}

}
Expand Up @@ -85,6 +85,7 @@ public class FormMetaDataDataSourceServlet extends AbstractDataSourceServlet {
public enum FormMetaDataType {
SUBMIT_ACTION("submitAction"),
PREFILL_ACTION("prefillServiceProvider"),
LANG("lang"),
FORMATTERS("formatters");

private String value;
Expand Down Expand Up @@ -147,6 +148,29 @@ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHtt
request.setAttribute(DataSource.class.getName(), actionTypeDataSource);
}

/**
* Checks if the type is related to formatters policy and the entry's key starts with the allowedformat.
*
* @param type The type of form meta data.
* @param entry The entry in the form meta data map.
* @return True if the type is related to formatters policy and the entry's key starts with the allowedformat, otherwise false.
*/
private Boolean isFormattersPolicy(FormMetaDataType type, Map.Entry<String, Object> entry) {
return type.equals(FormMetaDataType.FORMATTERS) && entry.getKey().startsWith(ALLOWED_FORMAT);
}

/**
* Checks if the type is related to language policy and the entry's key starts with the value of language metadata.
*
* @param type The type of form meta data.
* @param entry The entry in the form meta data map.
* @return True if the type is related to language policy and the entry's key starts with the value of language metadata, otherwise
* false.
*/
private Boolean isLangPolicy(FormMetaDataType type, Map.Entry<String, Object> entry) {
return type.equals(FormMetaDataType.LANG) && entry.getKey().startsWith(FormMetaDataType.LANG.getValue());
}

private List<Resource> getDataSourceResources(HttpServletRequest request, ResourceResolver resourceResolver, FormMetaDataType type,
String dataModel) {
List<Resource> resources = new ArrayList<>();
Expand All @@ -155,22 +179,25 @@ private List<Resource> getDataSourceResources(HttpServletRequest request, Resour
Iterator<FormsManager.ComponentDescription> metaDataList = null;
switch (type) {
case FORMATTERS:
case LANG:
ContentPolicy policy = ComponentUtils.getPolicy((String) request.getAttribute(Value.CONTENTPATH_ATTRIBUTE),
resourceResolver);
resources.add(getResourceForDropdownDisplay(resourceResolver, "Select", ""));
if (policy != null) {
ValueMap props = policy.getProperties();
if (props != null) {
for (Map.Entry<String, Object> entry : props.entrySet()) {
if (entry.getKey().startsWith(ALLOWED_FORMAT)) {
if (isFormattersPolicy(type, entry) || isLangPolicy(type, entry)) {
String[] arr = entry.getValue().toString().split("=", 2);
resources.add(getResourceForDropdownDisplay(resourceResolver, arr[0], arr[1]));
}
}
}
Map<String, String> allowedCustomFormattersMap = this.getAllowedCustomFormatters(policy, resourceResolver);
for (Map.Entry<String, String> entry : allowedCustomFormattersMap.entrySet()) {
resources.add(getResourceForDropdownDisplay(resourceResolver, entry.getKey(), entry.getValue()));
if (type.equals(FormMetaDataType.FORMATTERS)) {
Map<String, String> allowedCustomFormattersMap = this.getAllowedCustomFormatters(policy, resourceResolver);
for (Map.Entry<String, String> entry : allowedCustomFormattersMap.entrySet()) {
resources.add(getResourceForDropdownDisplay(resourceResolver, entry.getKey(), entry.getValue()));
}
}
}
resources.add(getResourceForDropdownDisplay(resourceResolver, "Custom", "custom"));
Expand Down
Expand Up @@ -35,6 +35,13 @@
public interface Base extends FormComponent {
public final String DATE_FORMATTER = "yyyy-MM-dd";

/**
* Constant representing the default language used, typically "en-US".
*
* @since com.adobe.cq.forms.core.components.models.form 5.3.1
*/
public final String DEFAULT_LANGUAGE = "en-US";

/**
* Returns label of the form field
*
Expand Down Expand Up @@ -136,4 +143,16 @@ default String getTooltip() {
default boolean isTooltipVisible() {
return false;
}

/**
* Returns the language to use for formatting the field.
*
* @return returns the language to use for formatting the field.
* @since com.adobe.cq.forms.core.components.models.form 5.3.1
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@Nullable
default String getLang() {
return DEFAULT_LANGUAGE;
}
}
Expand Up @@ -23,8 +23,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* Defines the form {@code Captcha} Sling Model used for the {@code /apps/core/fd/components/form/recaptcha/v1/recaptcha}
* component.
* Defines a base interface to be extended by all the different types of captcha.
*
* @since com.adobe.cq.forms.core.components.models.form 2.0.0
*/
Expand Down
Expand Up @@ -64,7 +64,7 @@ public interface FormContainer extends Container {
*/
String PN_CLIENT_LIB_REF = GuideConstants.CLIENT_LIB_REF;

String DEFAULT_FORMS_SPEC_VERSION = "0.12.5";
String DEFAULT_FORMS_SPEC_VERSION = "0.13.0";

/**
* Returns form metadata {@link FormMetaData}
Expand Down Expand Up @@ -294,7 +294,7 @@ default String getDataUrl() {
* @since com.adobe.cq.forms.core.components.models.form 4.0.0
*/
default String getLang() {
return "en-US";
return Base.DEFAULT_LANGUAGE;
}

/**
Expand Down
@@ -0,0 +1,27 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2024 Adobe
~
~ 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.models.form;

import org.osgi.annotation.versioning.ConsumerType;

/**
* Defines the form {@code HCaptcha} Sling Model used for the {@code /apps/core/fd/components/form/hcaptcha/v1/hcaptcha}
* component.
*
* @since com.adobe.cq.forms.core.components.models.form 5.4.0
*/
@ConsumerType
public interface HCaptcha extends Captcha {}
Expand Up @@ -34,7 +34,7 @@
* version, is bound to this proxy component resource type.
* </p>
*/
@Version("5.3.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650
@Version("5.4.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650
package com.adobe.cq.forms.core.components.models.form;

import org.osgi.annotation.versioning.Version;
Expand Up @@ -117,6 +117,9 @@ public abstract class AbstractBaseImpl extends AbstractFormComponentImpl impleme
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
protected Integer maxItems;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
protected String lang;

/** End **/

@SlingObject
Expand Down Expand Up @@ -155,6 +158,11 @@ public boolean isTooltipVisible() {
return tooltipVisible;
}

@Override
public String getLang() {
return lang;
}

@JsonIgnore
public @NotNull Map<String, Object> getCustomLayoutProperties() {
Map<String, Object> customLayoutProperties = super.getCustomLayoutProperties();
Expand Down