From cc70a6a41d28c2ab9cb3eefc67328c2dab3a9d4b Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 28 Oct 2026 01:44:27 -0600 Subject: [PATCH] test: cover Gutenberg support screen gate (GH#2060) --- tests/WP_Ultimo/General_Compat_Test.php | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/WP_Ultimo/General_Compat_Test.php b/tests/WP_Ultimo/General_Compat_Test.php index 0655e8b6d..a4ae9acf4 100644 --- a/tests/WP_Ultimo/General_Compat_Test.php +++ b/tests/WP_Ultimo/General_Compat_Test.php @@ -208,6 +208,48 @@ public function test_clear_divi_static_css_cache_does_not_follow_symlinks(): voi $this->assertDirectoryDoesNotExist($cache_dir); } + /** + * Screens and whether the Gutenberg support script should load on them. + * + * @return array + */ + public function gutenberg_screen_provider(): array { + + return [ + 'dashboard' => ['dashboard', false, false], + 'post editor' => ['post', true, true], + 'site editor' => ['site-editor', true, true], + 'widget editor' => ['widgets', true, true], + ]; + } + + /** + * Test the Gutenberg support script is gated to block editor screens. + * + * @dataProvider gutenberg_screen_provider + * + * @param string $screen_id Screen to simulate. + * @param bool $is_block_editor Whether the screen is a block editor. + * @param bool $expected Whether the script should be enqueued. + */ + public function test_gutenberg_support_script_gated_by_screen(string $screen_id, bool $is_block_editor, bool $expected): void { + + wp_dequeue_script('wu-gutenberg-support'); + wp_deregister_script('wu-gutenberg-support'); + + set_current_screen($screen_id); + + get_current_screen()->is_block_editor($is_block_editor); + + Gutenberg_Support::get_instance()->add_scripts(); + + $this->assertSame($expected, wp_script_is('wu-gutenberg-support', 'enqueued')); + + wp_dequeue_script('wu-gutenberg-support'); + wp_deregister_script('wu-gutenberg-support'); + set_current_screen('front'); + } + /** * Recursively remove a test directory. *