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

V4.6.0 #362

Merged
merged 62 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b658caa
Add uninstall code.
kagg-design Sep 15, 2024
e1745cd
Add uninstall code.
kagg-design Sep 15, 2024
6583559
WPCS.
kagg-design Sep 15, 2024
c76341d
Update packages.
kagg-design Sep 16, 2024
02be75f
ESLint.
kagg-design Sep 16, 2024
c2bff0d
Add uninstall.php tests.
kagg-design Sep 16, 2024
8139724
Do not use iframe in callback.
kagg-design Sep 23, 2024
8484fe7
Save and use rendered widgetId.
kagg-design Sep 23, 2024
a6e10f2
Do not use iframe in validate().
kagg-design Sep 23, 2024
1e35d3a
Do not use iframe in render/re-render.
kagg-design Sep 23, 2024
c5a2c08
Fix form element detection in getWidgetId.
kagg-design Sep 23, 2024
d30f40f
Do not use iframe in general.js.
kagg-design Sep 23, 2024
3fe5d30
Fix jest.
kagg-design Sep 23, 2024
c597eb5
Do not use iframe in hcaptcha-nf.js.
kagg-design Sep 23, 2024
0fa3ba9
Do not use iframe in admin-nf.js.
kagg-design Sep 23, 2024
43493ac
Fix ESLint.
kagg-design Sep 23, 2024
ee7ecf4
Update readme.txt.
kagg-design Sep 23, 2024
ac914e5
Fix ESLint.
kagg-design Sep 23, 2024
bdb1a74
Fix tests.
kagg-design Sep 24, 2024
74fde8b
CF7 live form in admin option.
kagg-design Sep 24, 2024
747653f
Migrations to 4.6.0.
kagg-design Sep 24, 2024
f91c53a
Migrations to 4.6.0.
kagg-design Sep 24, 2024
ec6277c
Update readme.txt.
kagg-design Sep 24, 2024
6da3fae
Update packages.
kagg-design Sep 25, 2024
bc45dc2
Fixed appearance of hCaptcha in Ninja Form admin
kagg-design Sep 29, 2024
b90b2d8
Remove debug code.
kagg-design Sep 29, 2024
a1f9b16
Fix not rendering of hCaptcha in Gravity Forms admin editor after add…
kagg-design Sep 29, 2024
032fe2b
Remove debug code.
kagg-design Sep 29, 2024
112f36f
Move the hCaptcha button before CAPTCHA in the GF admin editor.
kagg-design Sep 29, 2024
3df0098
Add hCaptcha button on GF settings page.
kagg-design Sep 29, 2024
378c483
Remove duplicated code in EA classes.
kagg-design Sep 29, 2024
62f71ae
Add hCaptcha button on GF settings page.
kagg-design Sep 29, 2024
04f1c5b
Code style in admin-elementor.pro.
kagg-design Oct 6, 2024
2ca3692
Fix not rendering of hCaptcha in Essential Addons admin editor.
kagg-design Oct 6, 2024
17a2f81
Fix tests upon introducing `h-captcha` custom HTML element.
kagg-design Oct 6, 2024
5f62a6c
Fix EA admin without Elementor Pro.
kagg-design Oct 6, 2024
18844a7
Cover EA 100%.
kagg-design Oct 6, 2024
1d4ee4d
Cover Pages 100%.
kagg-design Oct 6, 2024
2bb1ad1
Update readme.txt.
kagg-design Oct 6, 2024
27e9a52
Fix switching between Security Settings on Fluent Forms Global Settin…
kagg-design Oct 6, 2024
ecdfb84
Fix RTL for CF7.
kagg-design Oct 6, 2024
db15331
Fix RTL for CF7.
kagg-design Oct 6, 2024
0dc8af6
Fix RTL for CF7.
kagg-design Oct 7, 2024
b4d88bf
Fix RTL for CF7.
kagg-design Oct 7, 2024
468a1fd
Fix RTL in admin.
kagg-design Oct 7, 2024
678c025
Fix RTL in admin.
kagg-design Oct 7, 2024
fb4e480
The "protect form" tag was not widely used.
kagg-design Oct 7, 2024
2a4835c
Simple Membership Login.
kagg-design Oct 7, 2024
c79b158
Simple Membership Register.
kagg-design Oct 8, 2024
e212237
Simple Membership Lost Password.
kagg-design Oct 8, 2024
0941ecb
Update readme.txt.
kagg-design Oct 8, 2024
0ac7e33
WPCS.
kagg-design Oct 8, 2024
ce64b29
Fix unit tests.
kagg-design Oct 8, 2024
0ff5745
Forminator tests.
kagg-design Oct 8, 2024
5dbee88
Cover Forminator by tests 100%.
kagg-design Oct 9, 2024
b8fe1d4
Cover Forminator by tests 100%.
kagg-design Oct 9, 2024
e32f41a
Cover Formidable Forms by tests 100%.
kagg-design Oct 9, 2024
3b14fe5
Cover Formidable Forms by tests 100%.
kagg-design Oct 9, 2024
570d3a4
Cover Kadence Form by tests 100%.
kagg-design Oct 9, 2024
29d8536
Cover Kadence Form by tests 100%.
kagg-design Oct 9, 2024
b201859
Bump up version.
kagg-design Oct 9, 2024
15abdfa
Fix tests.
kagg-design Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .tests/js/hcaptcha/hcaptcha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe( 'HCaptcha', () => {
hCaptcha.foundForms.push( testForm );

expect( hCaptcha.getFoundFormById( 'test-id' ) ).toEqual( testForm );
expect( hCaptcha.getFoundFormById( 'non-existent-id' ) ).toBeUndefined();
expect( hCaptcha.getFoundFormById( 'non-existent-id' ) ).toBeNull();
} );

test( 'isSameOrDescendant', () => {
Expand All @@ -65,14 +65,14 @@ describe( 'HCaptcha', () => {
} );

test( 'bindEvents and reset', () => {
function generateUniqueId() {
return Math.random().toString( 36 ).substring( 2, 9 );
}

// Mock hcaptcha object
global.hcaptcha = {
render: jest.fn( ( hcaptchaElement ) => {
// Mock the rendering of the hCaptcha widget by adding a dataset attribute
const iframe = document.createElement( 'iframe' );
iframe.dataset.hcaptchaWidgetId = 'mock-widget-id';
iframe.dataset.hcaptchaResponse = '';
hcaptchaElement.appendChild( iframe );
render: jest.fn( () => {
return generateUniqueId();
} ),
execute: jest.fn(),
reset: jest.fn(),
Expand Down Expand Up @@ -132,7 +132,7 @@ describe( 'HCaptcha', () => {
hCaptcha.reset( form1 );

// Check if hcaptcha.reset was called with the correct widget id
expect( global.hcaptcha.reset ).toHaveBeenCalledWith( 'mock-widget-id' );
expect( global.hcaptcha.reset ).toHaveBeenCalled();

// Clean up DOM elements
document.body.removeChild( form1 );
Expand Down
57 changes: 30 additions & 27 deletions .tests/php/integration/CF7/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ public function tearDown(): void {
/**
* Test init_hooks().
*
* @param bool $mode_auto Mode auto.
* @param bool $mode_embed Mode embed.
* @param bool $mode_live Mode live.
* @param bool $is_admin Admin mode.
* @param bool $expected Hooks expected to be added.
*
* @dataProvider dp_test_init_hooks
*/
public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_admin, bool $expected ): void {
$cf7_status = array_filter( [ $mode_auto ? 'form' : '', $mode_embed ? 'embed' : '' ] );
public function test_init_hooks( bool $mode_embed, bool $mode_live, bool $is_admin ): void {
$cf7_status = array_filter( [ $mode_embed ? 'embed' : '', $mode_live ? 'live' : '' ] );
$cf7_screen = 'toplevel_page_wpcf7';

if ( $is_admin ) {
Expand All @@ -76,15 +75,22 @@ public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_adm

$subject = new Admin();

if ( $is_admin && $cf7_status ) {
if ( $is_admin ) {
set_current_screen( $cf7_screen );
}

if ( $expected ) {
if ( $mode_embed && $is_admin ) {
self::assertSame(
54,
has_action( 'wpcf7_admin_init', [ $subject, 'add_tag_generator_hcaptcha' ] )
);
} else {
self::assertFalse(
has_action( 'wpcf7_admin_init', [ $subject, 'add_tag_generator_hcaptcha' ] )
);
}

if ( $mode_live && $is_admin ) {
self::assertSame(
10,
has_action( 'current_screen', [ $subject, 'current_screen' ] )
Expand All @@ -106,9 +112,6 @@ public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_adm
has_action( 'admin_enqueue_scripts', [ $subject, 'enqueue_admin_scripts_after_cf7' ] )
);
} else {
self::assertFalse(
has_action( 'wpcf7_admin_init', [ $subject, 'add_tag_generator_hcaptcha' ] )
);
self::assertFalse(
has_action( 'current_screen', [ $subject, 'current_screen' ] )
);
Expand All @@ -125,6 +128,24 @@ public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_adm
}
}

/**
* Data provider for test_init_hooks().
*
* @return array
*/
public function dp_test_init_hooks(): array {
return [
[ false, false, false ],
[ false, false, true ],
[ false, true, false ],
[ false, true, true ],
[ true, false, false ],
[ true, false, true ],
[ true, true, false ],
[ true, true, true ],
];
}

/**
* Test init_hooks() when not on CF7 admin page.
*
Expand Down Expand Up @@ -152,24 +173,6 @@ public function test_init_hooks_NOT_on_cf7_admin_page(): void {
);
}

/**
* Data provider for test_init_hooks().
*
* @return array
*/
public function dp_test_init_hooks(): array {
return [
[ false, false, false, false ],
[ false, false, true, false ],
[ false, true, false, false ],
[ false, true, true, true ],
[ true, false, false, false ],
[ true, false, true, true ],
[ true, true, false, false ],
[ true, true, true, true ],
];
}

/**
* Test current_screen().
*
Expand Down
79 changes: 79 additions & 0 deletions .tests/php/integration/EssentialAddons/BaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* BaseTest class file.
*
* @package HCaptcha\Tests
*/

// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpUndefinedNamespaceInspection */
/** @noinspection PhpUndefinedClassInspection */
// phpcs:enable Generic.Commenting.DocComment.MissingShort

namespace HCaptcha\Tests\Integration\EssentialAddons;

use HCaptcha\EssentialAddons\Base;
use HCaptcha\Tests\Integration\HCaptchaWPTestCase;
use Mockery;
use Patchwork\Exceptions\NonNullToVoid;
use tad\FunctionMocker\FunctionMocker;

/**
* Class BaseTest
*
* @group essential-addons
* @group essential-addons-login
*/
class BaseTest extends HCaptchaWPTestCase {

/**
* Tear down the test.
*
* @return void
*/
public function tearDown(): void {
unset( $_GET['elementor-preview'] );

parent::tearDown();
}

/**
* Test enqueue_scripts().
*
* @return void
*/
public function test_enqueue_scripts(): void {
$subject = Mockery::mock( Base::class );

$subject->makePartial();

$subject->enqueue_scripts();

self::assertFalse( wp_script_is( 'admin-essential-addons' ) );

$_GET['elementor-preview'] = '4242';

$subject->enqueue_scripts();

self::assertTrue( wp_script_is( 'admin-essential-addons' ) );
}

/**
* Test print_hcaptcha_scripts().
*
* @return void
*/
public function test_print_hcaptcha_scripts(): void {
$subject = Mockery::mock( Base::class );

$subject->makePartial();

self::assertFalse( $subject->print_hcaptcha_scripts( false ) );
self::assertTrue( $subject->print_hcaptcha_scripts( true ) );

$_GET['elementor-preview'] = '4242';

self::assertTrue( $subject->print_hcaptcha_scripts( false ) );
self::assertTrue( $subject->print_hcaptcha_scripts( true ) );
}
}
3 changes: 3 additions & 0 deletions .tests/php/integration/EssentialAddons/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function test_init_hooks(): void {
has_action( 'eael/login-register/before-login-footer', [ $subject, 'add_login_hcaptcha' ] )
);
self::assertSame( 10, has_action( 'eael/login-register/before-login', [ $subject, 'verify' ] ) );

self::assertSame( 10, has_action( 'wp_enqueue_scripts', [ $subject, 'enqueue_scripts' ] ) );
self::assertSame( 10, has_action( 'hcap_print_hcaptcha_scripts', [ $subject, 'print_hcaptcha_scripts' ] ) );
}

/**
Expand Down
3 changes: 3 additions & 0 deletions .tests/php/integration/EssentialAddons/RegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function test_init_hooks(): void {
self::assertSame( 10, has_action( 'eael/login-register/before-register', [ $subject, 'verify' ] ) );

self::assertSame( 10, has_action( 'wp_head', [ $subject, 'print_inline_styles' ] ) );

self::assertSame( 10, has_action( 'wp_enqueue_scripts', [ $subject, 'enqueue_scripts' ] ) );
self::assertSame( 10, has_action( 'hcap_print_hcaptcha_scripts', [ $subject, 'print_hcaptcha_scripts' ] ) );
}

/**
Expand Down
Loading