@wordpress/e2e-tests 9.6.0 → 9.6.1-next.v.202603161435.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/plugins/connectors-capability-restriction.php +66 -0
- package/plugins/connectors-empty-state.php +19 -0
- package/plugins/connectors-test-provider.php +126 -0
- package/plugins/iframed-enqueue-block-assets/script.js +1 -1
- package/plugins/interactive-blocks/router-race-condition/block.json +15 -0
- package/plugins/interactive-blocks/router-race-condition/render.php +26 -0
- package/plugins/interactive-blocks/router-race-condition/view.asset.php +9 -0
- package/plugins/interactive-blocks/router-race-condition/view.js +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/e2e-tests",
|
|
3
|
-
"version": "9.6.0",
|
|
3
|
+
"version": "9.6.1-next.v.202603161435.0+ab4981c4f",
|
|
4
4
|
"description": "Test plugins and mu-plugins for E2E tests in WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"npm": ">=8.19.2"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@wordpress/interactivity": "^6.41.0",
|
|
28
|
-
"@wordpress/interactivity-router": "^2.41.0"
|
|
27
|
+
"@wordpress/interactivity": "^6.41.2-next.v.202603161435.0+ab4981c4f",
|
|
28
|
+
"@wordpress/interactivity-router": "^2.41.2-next.v.202603161435.0+ab4981c4f"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"jest": ">=29",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "748f4e4564fcc0e6ae90200d90bb993a3cef5828"
|
|
40
40
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: Gutenberg Test Connectors Capability Restriction
|
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
|
5
|
+
* Author: Gutenberg Team
|
|
6
|
+
*
|
|
7
|
+
* @package gutenberg-test-connectors-capability-restriction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
add_action(
|
|
11
|
+
'init',
|
|
12
|
+
static function () {
|
|
13
|
+
register_setting(
|
|
14
|
+
'general',
|
|
15
|
+
'gutenberg_test_cap_restriction',
|
|
16
|
+
array(
|
|
17
|
+
'type' => 'string',
|
|
18
|
+
'default' => '',
|
|
19
|
+
'show_in_rest' => true,
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
register_deactivation_hook(
|
|
26
|
+
__FILE__,
|
|
27
|
+
static function () {
|
|
28
|
+
delete_option( 'gutenberg_test_cap_restriction' );
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
add_filter(
|
|
33
|
+
'map_meta_cap',
|
|
34
|
+
static function ( $caps, $cap ) {
|
|
35
|
+
$restriction = get_option( 'gutenberg_test_cap_restriction', '' );
|
|
36
|
+
|
|
37
|
+
if ( empty( $restriction ) ) {
|
|
38
|
+
return $caps;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$blocked_caps = array();
|
|
42
|
+
|
|
43
|
+
switch ( $restriction ) {
|
|
44
|
+
case 'no_install':
|
|
45
|
+
$blocked_caps = array( 'install_plugins', 'upload_plugins' );
|
|
46
|
+
break;
|
|
47
|
+
case 'no_activate':
|
|
48
|
+
$blocked_caps = array( 'activate_plugins' );
|
|
49
|
+
break;
|
|
50
|
+
case 'no_install_activate':
|
|
51
|
+
$blocked_caps = array( 'install_plugins', 'upload_plugins', 'activate_plugins' );
|
|
52
|
+
break;
|
|
53
|
+
case 'disallow_file_mods':
|
|
54
|
+
$blocked_caps = array( 'install_plugins', 'upload_plugins', 'delete_plugins', 'update_plugins' );
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ( in_array( $cap, $blocked_caps, true ) ) {
|
|
59
|
+
return array( 'do_not_allow' );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return $caps;
|
|
63
|
+
},
|
|
64
|
+
10,
|
|
65
|
+
2
|
|
66
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: Gutenberg Test Connectors Empty State
|
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
|
5
|
+
* Author: Gutenberg Team
|
|
6
|
+
*
|
|
7
|
+
* Removes the default connector data so the Connectors page renders its empty state.
|
|
8
|
+
*
|
|
9
|
+
* @package gutenberg-test-connectors-empty-state
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Remove the Gutenberg filter that provides default connector data.
|
|
13
|
+
add_action(
|
|
14
|
+
'init',
|
|
15
|
+
static function () {
|
|
16
|
+
remove_filter( 'script_module_data_options-connectors-wp-admin', '_gutenberg_get_connector_script_module_data' );
|
|
17
|
+
},
|
|
18
|
+
PHP_INT_MAX
|
|
19
|
+
);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: Gutenberg Test Connectors Provider
|
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
|
5
|
+
* Author: Gutenberg Team
|
|
6
|
+
*
|
|
7
|
+
* Registers a naive AI provider with hardcoded API key validation
|
|
8
|
+
* for E2E testing of the Connectors page setup flow.
|
|
9
|
+
*
|
|
10
|
+
* The valid API key is: test-api-key-123
|
|
11
|
+
*
|
|
12
|
+
* @package gutenberg-test-connectors-provider
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
|
|
16
|
+
// phpcs:disable WordPress.Files.FileName
|
|
17
|
+
// phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
|
|
18
|
+
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
|
19
|
+
|
|
20
|
+
use WordPress\AiClient\AiClient;
|
|
21
|
+
use WordPress\AiClient\Providers\AbstractProvider;
|
|
22
|
+
use WordPress\AiClient\Providers\Contracts\ModelMetadataDirectoryInterface;
|
|
23
|
+
use WordPress\AiClient\Providers\Contracts\ProviderAvailabilityInterface;
|
|
24
|
+
use WordPress\AiClient\Providers\DTO\ProviderMetadata;
|
|
25
|
+
use WordPress\AiClient\Providers\Enums\ProviderTypeEnum;
|
|
26
|
+
use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface;
|
|
27
|
+
use WordPress\AiClient\Providers\Http\Contracts\WithRequestAuthenticationInterface;
|
|
28
|
+
use WordPress\AiClient\Providers\Http\DTO\ApiKeyRequestAuthentication;
|
|
29
|
+
use WordPress\AiClient\Providers\Http\Enums\RequestAuthenticationMethod;
|
|
30
|
+
use WordPress\AiClient\Providers\Models\Contracts\ModelInterface;
|
|
31
|
+
use WordPress\AiClient\Providers\Models\DTO\ModelMetadata;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Availability checker that validates against a hardcoded API key.
|
|
35
|
+
*/
|
|
36
|
+
class Gutenberg_Test_Provider_Availability implements ProviderAvailabilityInterface, WithRequestAuthenticationInterface {
|
|
37
|
+
|
|
38
|
+
const VALID_API_KEY = 'test-api-key-123';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @var RequestAuthenticationInterface|null
|
|
42
|
+
*/
|
|
43
|
+
private $authentication = null;
|
|
44
|
+
|
|
45
|
+
public function isConfigured(): bool {
|
|
46
|
+
if ( ! $this->authentication instanceof ApiKeyRequestAuthentication ) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return $this->authentication->getApiKey() === self::VALID_API_KEY;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public function setRequestAuthentication( RequestAuthenticationInterface $authentication ): void {
|
|
53
|
+
$this->authentication = $authentication;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public function getRequestAuthentication(): RequestAuthenticationInterface {
|
|
57
|
+
return $this->authentication;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Empty model metadata directory (no models needed for testing).
|
|
63
|
+
*/
|
|
64
|
+
class Gutenberg_Test_Provider_Model_Directory implements ModelMetadataDirectoryInterface {
|
|
65
|
+
|
|
66
|
+
public function listModelMetadata(): array {
|
|
67
|
+
return array();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public function hasModelMetadata( string $modelId ): bool {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public function getModelMetadata( string $modelId ): ModelMetadata {
|
|
75
|
+
throw new \WordPress\AiClient\Common\Exception\InvalidArgumentException(
|
|
76
|
+
sprintf( 'Model not found: %s', $modelId )
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Minimal AI provider for E2E testing.
|
|
83
|
+
*/
|
|
84
|
+
class Gutenberg_Test_Provider extends AbstractProvider {
|
|
85
|
+
|
|
86
|
+
protected static function createProviderMetadata(): ProviderMetadata {
|
|
87
|
+
return new ProviderMetadata(
|
|
88
|
+
'test_provider',
|
|
89
|
+
'Test Provider',
|
|
90
|
+
ProviderTypeEnum::from( ProviderTypeEnum::CLOUD ),
|
|
91
|
+
null,
|
|
92
|
+
RequestAuthenticationMethod::from( RequestAuthenticationMethod::API_KEY ),
|
|
93
|
+
'A test AI provider for E2E testing.'
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected static function createProviderAvailability(): ProviderAvailabilityInterface {
|
|
98
|
+
return new Gutenberg_Test_Provider_Availability();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected static function createModelMetadataDirectory(): ModelMetadataDirectoryInterface {
|
|
102
|
+
return new Gutenberg_Test_Provider_Model_Directory();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected static function createModel( ModelMetadata $modelMetadata, ProviderMetadata $providerMetadata ): ModelInterface {
|
|
106
|
+
throw new \WordPress\AiClient\Common\Exception\InvalidArgumentException( 'Test provider does not support models.' );
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Register the provider in the AiClient registry so it is auto-discovered by the WP_Connector_Registry.
|
|
111
|
+
add_action(
|
|
112
|
+
'init',
|
|
113
|
+
static function () {
|
|
114
|
+
if ( ! class_exists( '\WordPress\AiClient\AiClient' ) ) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
AiClient::defaultRegistry()->registerProvider( Gutenberg_Test_Provider::class );
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
register_deactivation_hook(
|
|
122
|
+
__FILE__,
|
|
123
|
+
static function () {
|
|
124
|
+
delete_option( 'connectors_ai_test_provider_api_key' );
|
|
125
|
+
}
|
|
126
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/router-race-condition",
|
|
5
|
+
"title": "E2E Interactivity tests - router race condition",
|
|
6
|
+
"category": "text",
|
|
7
|
+
"icon": "heart",
|
|
8
|
+
"description": "",
|
|
9
|
+
"supports": {
|
|
10
|
+
"interactivity": true
|
|
11
|
+
},
|
|
12
|
+
"textdomain": "e2e-interactivity",
|
|
13
|
+
"viewScriptModule": "file:./view.js",
|
|
14
|
+
"render": "file:./render.php"
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing the router hydration race condition.
|
|
4
|
+
*
|
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
|
6
|
+
*
|
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
8
|
+
*/
|
|
9
|
+
?>
|
|
10
|
+
<div
|
|
11
|
+
data-wp-interactive="router-race-condition"
|
|
12
|
+
data-wp-router-region="router-race-condition/buttons"
|
|
13
|
+
data-wp-context='{ "counter": 0 }'
|
|
14
|
+
>
|
|
15
|
+
<button
|
|
16
|
+
data-testid="context-counter"
|
|
17
|
+
data-wp-text="context.counter"
|
|
18
|
+
data-wp-on--click="actions.increment"
|
|
19
|
+
>0</button>
|
|
20
|
+
|
|
21
|
+
<button
|
|
22
|
+
data-testid="global-counter"
|
|
23
|
+
data-wp-text="state.counter"
|
|
24
|
+
data-wp-on--click="actions.incrementGlobal"
|
|
25
|
+
>0</button>
|
|
26
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
|
5
|
+
import '@wordpress/interactivity-router';
|
|
6
|
+
|
|
7
|
+
const { state } = store( 'router-race-condition', {
|
|
8
|
+
state: {
|
|
9
|
+
counter: 0,
|
|
10
|
+
},
|
|
11
|
+
actions: {
|
|
12
|
+
increment() {
|
|
13
|
+
const context = getContext();
|
|
14
|
+
context.counter += 1;
|
|
15
|
+
},
|
|
16
|
+
incrementGlobal() {
|
|
17
|
+
state.counter += 1;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} );
|