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

FORMS-13811 | Adding rendition for hCaptcha #1174

Merged
merged 20 commits into from May 3, 2024
Merged

FORMS-13811 | Adding rendition for hCaptcha #1174

merged 20 commits into from May 3, 2024

Conversation

navneet-ag
Copy link
Contributor

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

@github-actions github-actions bot force-pushed the captcha/hcaptcha branch 3 times, most recently from 863f7fb to 39f0ce7 Compare April 10, 2024 13:52
* Defines the form {@code Captcha} Sling Model used for the {@code /apps/core/fd/components/form/hcaptcha/v1/hcaptcha}
* component.
*
* @since com.adobe.cq.forms.core.components.models.form 2.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please bump the minor version, since you have created a new interface. also update the docs

bundles/af-core/pom.xml Outdated Show resolved Hide resolved
Copy link
Collaborator

@rismehta rismehta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test case for this code. Also, create a sample in core component on how one could create a custom captcha. You can check the existing code where we have test cases for custom components.

Copy link
Collaborator

@rismehta rismehta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check comments

* @since com.adobe.cq.forms.core.components.models.form 5.4.0
*/
@ConsumerType
public interface HCaptcha extends Captcha {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not need this interface if its not adding any new method over the base interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a marker interface to be consumed by HCaptchaImpl.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the impl just implement Captcha?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consumed by sightly, if we use HCaptchaImpl implemented Captcha then it would have not picked up the correct impl.

(function() {

"use strict";
class HCaptcha extends FormView.FormFieldBase {
Copy link
Collaborator

@nit23uec nit23uec Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are already inheriting from recaptcha RT, is there any reason to have dedicated clientlibs for hcaptcha? we could have even reused the bem block for all captcha providers (thinking about our guidance to customers in future to implement another captcha provider as a separate component).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a discussion long back with @sakshi-arora1, and it was a conscious decision to keep separate captcha components in AFv2. @sakshi-arora1 can comment more about the same.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The components should be different (in terms of inserting them). I'm just wondering whether we need to duplicate the code in each captcha component and what would be our recommendation for a custom captcha comp in future for customers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we can have a captcha utils in place which can be reused by multiple captcha components ?

~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
<sly data-sly-use.renderer="${'hcaptcha.js'}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, since we are already inheriting recaptcha, any reason to redefine this sightly again? is it just for bem selectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just for the bem selectors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a styling use case for captcha?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the error message, which appears if user tries to submit without filling the captcha

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Personally I'd have preferred to keep bem selector same for both recaptcha and hcaptcha or any other captcha provider that may be integrated in future. And that would also have enabled anyone implementing a custom captcha component by just inherting an existing captcha component (for client libs and sightly). Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this approach, we should release a v2 version of Recaptcha core component with a generic bem model. As the current bem model is specific to recaptcha (https://github.com/adobe/aem-core-forms-components/blob/master/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/recaptcha/v1/recaptcha/clientlibs/site/css/recaptchaview.css#L9)

And for custom captcha, apart from client libs and sightly; cq:dialog might also need to be overridden for the custom captcha.

Copy link
Collaborator

@rismehta rismehta Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Personally I'd have preferred to keep bem selector same for both recaptcha and hcaptcha or any other captcha provider that may be integrated in future. And that would also have enabled anyone implementing a custom captcha component by just inherting an existing captcha component (for client libs and sightly). Wdyt?

From a technical perspective, maintaining unique BEM selectors for different captcha providers such as reCAPTCHA and hCaptcha helps ensure that the styling and behaviors of these components are distinctly manageable. This can be particularly useful in cases where the captchas might have differing visual or functional requirements that could conflict if merged under a single BEM namespace.

Furthermore, using distinct BEM selectors can avoid potential clashes in CSS and JavaScript (some customers don't use recommended best practices, and use BEM selectors in JS), which might occur if the same class names are applied across different libraries or functionalities. This separation ensures that updates or changes to one captcha implementation do not inadvertently affect the styling or functionality of another.

If we receive feedback indicating a need for a more unified approach, we should reconsider our strategy. For now, maintaining separate selectors provides us with greater control and minimizes risk of cross-component interference.

@navneet-ag navneet-ag self-assigned this Apr 19, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 82.60870% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 80.89%. Comparing base (c227001) to head (b1dbce5).

Files Patch % Lines
...mponents/internal/models/v1/form/HCaptchaImpl.java 82.60% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #1174      +/-   ##
============================================
+ Coverage     80.87%   80.89%   +0.01%     
- Complexity      786      791       +5     
============================================
  Files            91       92       +1     
  Lines          2123     2146      +23     
  Branches        289      292       +3     
============================================
+ Hits           1717     1736      +19     
- Misses          252      253       +1     
- Partials        154      157       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

1 similar comment
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 100 75

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 94 96 100 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 93 96 100 75

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 100 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

1 similar comment
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 94 96 100 75

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 100 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 100 75

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 93 96 100 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

1 similar comment
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@rismehta rismehta merged commit 4446d6b into dev May 3, 2024
10 checks passed
@rismehta rismehta deleted the captcha/hcaptcha branch May 3, 2024 06:08
github-actions bot pushed a commit that referenced this pull request May 3, 2024
* embedding forms-sdk api

* adding hcaptcha and recaptcha models

* :fix hcaptcha model SlingException

* :fix deleting recaptcha model

* FORMS-13811 | Adding rendition for hCaptcha

* FORMS-13811 | Renamed public API

* FORMS-13811 | Embedding hcaptcha js

* FORMS-13811 | Adding unit test for sling model

* FORMS-13811 | Adding cypress test

* FORMS-13811 | Adressing review comments

* Adding e2e test

* FORMS-13811 | fix import statements

* Update pom.xml

* Adding FT for running Tests

* FORMS-13811 | Removing java-8 build for master

* Adding FT in test

* FORMS-13811 | Tests should run only with latest addon

* FORMS-13811 | Tests should run only with latest addon

* increasing coverage

* addressing review comments

---------

Co-authored-by: Navneet Agarwal <navneeta@adobe.com>
github-actions bot pushed a commit that referenced this pull request May 7, 2024
* embedding forms-sdk api

* adding hcaptcha and recaptcha models

* :fix hcaptcha model SlingException

* :fix deleting recaptcha model

* FORMS-13811 | Adding rendition for hCaptcha

* FORMS-13811 | Renamed public API

* FORMS-13811 | Embedding hcaptcha js

* FORMS-13811 | Adding unit test for sling model

* FORMS-13811 | Adding cypress test

* FORMS-13811 | Adressing review comments

* Adding e2e test

* FORMS-13811 | fix import statements

* Update pom.xml

* Adding FT for running Tests

* FORMS-13811 | Removing java-8 build for master

* Adding FT in test

* FORMS-13811 | Tests should run only with latest addon

* FORMS-13811 | Tests should run only with latest addon

* increasing coverage

* addressing review comments

---------

Co-authored-by: Navneet Agarwal <navneeta@adobe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants