@@ -167,6 +167,48 @@ public function required_field_provider() {
167167 );
168168 }
169169
170+ /**
171+ * Test the delay field is available only when monitoring and Wait After Onload are active.
172+ *
173+ * @dataProvider delay_field_availability_provider
174+ *
175+ * @param string $enabled Enabled setting value.
176+ * @param string $wait_after_onload Wait After Onload setting value.
177+ * @param bool $expect_disabled Whether the delay field should be disabled.
178+ */
179+ public function test_delay_field_depends_on_wait_after_onload ( $ enabled , $ wait_after_onload , $ expect_disabled ) {
180+ $ this ->set_settings (
181+ array (
182+ 'enabled ' => $ enabled ,
183+ 'wait_after_onload ' => $ wait_after_onload ,
184+ 'delay_ms ' => 500 ,
185+ )
186+ );
187+
188+ $ page = new Page ();
189+
190+ ob_start ();
191+ $ page ->render_number_field ( array ( 'id ' => 'delay_ms ' ) );
192+ $ html = ob_get_clean ();
193+
194+ $ this ->assertStringContainsString ( 'aria-disabled=" ' . ( $ expect_disabled ? 'true ' : 'false ' ) . '" ' , $ html );
195+ $ this ->assertSame ( $ expect_disabled , false !== strpos ( $ html , 'disabled="disabled" ' ) );
196+ $ this ->assertSame ( $ expect_disabled , false !== strpos ( $ html , 'basicrum-disabled-setting-value ' ) );
197+ }
198+
199+ /**
200+ * Provide delay field availability states.
201+ *
202+ * @return array[] Test cases.
203+ */
204+ public function delay_field_availability_provider () {
205+ return array (
206+ 'monitoring disabled ' => array ( '0 ' , '1 ' , true ),
207+ 'wait after onload disabled ' => array ( '1 ' , '0 ' , true ),
208+ 'both settings enabled ' => array ( '1 ' , '1 ' , false ),
209+ );
210+ }
211+
170212 /**
171213 * Test the privacy section exposes query protection and real loading behaviors.
172214 */
@@ -299,6 +341,9 @@ public function test_enable_checkbox_remains_interactive_when_monitoring_is_off(
299341 * Test the conditional settings behavior is loaded on the Basicrum page.
300342 */
301343 public function test_settings_script_is_enqueued_on_basicrum_page () {
344+ $ script_version = BASICRUM_VERSION . '. ' . filemtime ( \Basicrum \WP \Helpers::get_asset_path ( 'js/admin/settings.js ' ) );
345+ $ style_version = BASICRUM_VERSION . '. ' . filemtime ( \Basicrum \WP \Helpers::get_asset_path ( 'css/admin/settings.css ' ) );
346+
302347 Functions \when ( 'plugins_url ' )->alias (
303348 function ( $ path ) {
304349 return 'https://example.com/wp-content/plugins/basicrum/ ' . $ path ;
@@ -310,7 +355,7 @@ function( $path ) {
310355 'basicrum-admin-settings ' ,
311356 'https://example.com/wp-content/plugins/basicrum/assets/js/admin/settings.js ' ,
312357 array (),
313- BASICRUM_VERSION ,
358+ $ script_version ,
314359 true
315360 );
316361 Functions \expect ( 'wp_enqueue_style ' )
@@ -319,7 +364,7 @@ function( $path ) {
319364 'basicrum-admin-settings-style ' ,
320365 'https://example.com/wp-content/plugins/basicrum/assets/css/admin/settings.css ' ,
321366 array (),
322- BASICRUM_VERSION
367+ $ style_version
323368 );
324369
325370 $ page = new Page ();
0 commit comments