@@ -1850,6 +1850,50 @@ public function test_default_script_modules() {
18501850 );
18511851 }
18521852
1853+ /**
1854+ * Tests that every default script module points to a file that exists on
1855+ * disk, both with and without SCRIPT_DEBUG.
1856+ *
1857+ * Some files are only shipped minified (large inlined WASM or worker
1858+ * code with no debugging value). Those must be special-cased in
1859+ * wp_default_script_modules() so the non-minified URL is never used;
1860+ * otherwise the import map points to a non-existent file under
1861+ * SCRIPT_DEBUG. The exceptions below must mirror that special case.
1862+ *
1863+ * @ticket 65664
1864+ *
1865+ * @covers ::wp_default_script_modules
1866+ */
1867+ public function test_default_script_module_files_exist () {
1868+ $ assets_file = ABSPATH . WPINC . '/assets/script-modules-packages.php ' ;
1869+ if ( ! file_exists ( $ assets_file ) ) {
1870+ $ this ->markTestSkipped ( 'The script modules packages asset file is not available. ' );
1871+ }
1872+
1873+ $ assets = include $ assets_file ;
1874+ $ this ->assertNotEmpty ( $ assets , 'The script modules packages asset file should not be empty. ' );
1875+
1876+ foreach ( array_keys ( $ assets ) as $ file_name ) {
1877+ // Files only shipped minified; mirrors wp_default_script_modules().
1878+ if ( str_starts_with ( $ file_name , 'vips/ ' ) || 'video-conversion/worker.js ' === $ file_name ) {
1879+ $ file_name = str_replace ( '.js ' , '.min.js ' , $ file_name );
1880+ }
1881+
1882+ $ min_file_name = str_ends_with ( $ file_name , '.min.js ' )
1883+ ? $ file_name
1884+ : substr ( $ file_name , 0 , -3 ) . '.min.js ' ;
1885+
1886+ $ this ->assertFileExists (
1887+ ABSPATH . WPINC . "/js/dist/script-modules/ {$ file_name }" ,
1888+ "The script module file used with SCRIPT_DEBUG enabled should exist for ' {$ file_name }'. "
1889+ );
1890+ $ this ->assertFileExists (
1891+ ABSPATH . WPINC . "/js/dist/script-modules/ {$ min_file_name }" ,
1892+ "The minified script module file should exist for ' {$ file_name }'. "
1893+ );
1894+ }
1895+ }
1896+
18531897 /**
18541898 * Tests expected priority is used when a dependent is registered but not enqueued.
18551899 *
0 commit comments