@wordpress/e2e-tests 7.25.0 → 7.26.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/CHANGELOG.md +2 -0
- package/package.json +9 -9
- package/plugins/delete-installed-fonts.php +68 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.26.0",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -23,13 +23,13 @@
|
|
23
23
|
"node": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^10.
|
27
|
-
"@wordpress/interactivity": "^5.
|
28
|
-
"@wordpress/interactivity-router": "^1.
|
29
|
-
"@wordpress/jest-console": "^7.
|
30
|
-
"@wordpress/jest-puppeteer-axe": "^6.
|
31
|
-
"@wordpress/scripts": "^27.
|
32
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^10.26.0",
|
27
|
+
"@wordpress/interactivity": "^5.4.0",
|
28
|
+
"@wordpress/interactivity-router": "^1.5.0",
|
29
|
+
"@wordpress/jest-console": "^7.26.0",
|
30
|
+
"@wordpress/jest-puppeteer-axe": "^6.26.0",
|
31
|
+
"@wordpress/scripts": "^27.6.0",
|
32
|
+
"@wordpress/url": "^3.56.0",
|
33
33
|
"chalk": "^4.0.0",
|
34
34
|
"expect-puppeteer": "^4.4.0",
|
35
35
|
"filenamify": "^4.2.0",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ac2b13783c28f959770cf029a797a712f59e1958"
|
50
50
|
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Delete Installed Fonts
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-delete-installed-fonts
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Saves a randomly generated temporary font directory to use for e2e tests.
|
12
|
+
*/
|
13
|
+
function gutenberg_e2e_set_temp_font_dir() {
|
14
|
+
update_option( 'gutenberg_e2e_font_dir', '/e2e_fonts_' . wp_generate_uuid4() );
|
15
|
+
}
|
16
|
+
register_activation_hook( __FILE__, 'gutenberg_e2e_set_temp_font_dir' );
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Uses the randomly generated font directory for the duration of the font tests.
|
20
|
+
*/
|
21
|
+
function gutenberg_filter_e2e_font_dir( $font_dir ) {
|
22
|
+
$subdir = get_option( 'gutenberg_e2e_font_dir' );
|
23
|
+
|
24
|
+
$font_dir['path'] .= $subdir;
|
25
|
+
$font_dir['url'] .= $subdir;
|
26
|
+
$font_dir['basedir'] .= $subdir;
|
27
|
+
$font_dir['baseurl'] .= $subdir;
|
28
|
+
|
29
|
+
return $font_dir;
|
30
|
+
}
|
31
|
+
add_filter( 'font_dir', 'gutenberg_filter_e2e_font_dir' );
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Deletes all user installed fonts, associated font files, the fonts directory, and user global styles typography
|
35
|
+
* setings for the current theme so that we can test uploading/installing fonts in a clean environment.
|
36
|
+
*/
|
37
|
+
function gutenberg_delete_installed_fonts() {
|
38
|
+
$font_family_ids = new WP_Query(
|
39
|
+
array(
|
40
|
+
'post_type' => 'wp_font_family',
|
41
|
+
'posts_per_page' => -1,
|
42
|
+
'fields' => 'ids',
|
43
|
+
)
|
44
|
+
);
|
45
|
+
|
46
|
+
// Delete all font families, their child font faces, and associated font files.
|
47
|
+
foreach ( $font_family_ids->posts as $font_family_id ) {
|
48
|
+
wp_delete_post( $font_family_id, true );
|
49
|
+
}
|
50
|
+
|
51
|
+
// Delete the font directory, which should now be empty.
|
52
|
+
$font_path = wp_get_font_dir()['path'];
|
53
|
+
|
54
|
+
if ( is_dir( $font_path ) ) {
|
55
|
+
rmdir( $font_path );
|
56
|
+
}
|
57
|
+
|
58
|
+
// Delete any installed fonts from global styles.
|
59
|
+
$global_styles_post_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
|
60
|
+
$request = new WP_REST_Request( 'POST', '/wp/v2/global-styles/' . $global_styles_post_id );
|
61
|
+
$request->set_body_params( array( 'settings' => array( 'typography' => array( 'fontFamilies' => array() ) ) ) );
|
62
|
+
|
63
|
+
rest_do_request( $request );
|
64
|
+
}
|
65
|
+
|
66
|
+
// Clean up fonts on plugin activation and deactivation.
|
67
|
+
register_activation_hook( __FILE__, 'gutenberg_delete_installed_fonts' );
|
68
|
+
register_deactivation_hook( __FILE__, 'gutenberg_delete_installed_fonts' );
|