Skip to content

Commit

Permalink
feat(TestStatus): show test started message
Browse files Browse the repository at this point in the history
  • Loading branch information
domtra committed Dec 14, 2023
1 parent fc59280 commit 6b374ad
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions components/admin-notification/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
$template = dirname( __FILE__ ) . '/views/admin-notification-test-disabled.php';
break;

case 'test_started':
$template = dirname( __FILE__ ) . '/views/admin-notification-test-started.php';
break;

case 'unlock_more_tests':
$template = dirname( __FILE__ ) . '/views/admin-notification-unlock-more-tests.php';
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="vrts-notice notice notice-success" data-view="<?php echo esc_attr( $data['view'] ); ?>">
<?php wp_nonce_field( 'vrts_admin_notice_nonce' ); ?>
<h3><?php esc_html_e( 'Testing has started', 'visual-regression-tests' ); ?></h3>
<p>
<?php esc_html_e( 'If the testing detects any visual differences, we will notify you via e-mail alerts.', 'visual-regression-tests' ); ?>
</p>
</div>
2 changes: 1 addition & 1 deletion components/tests-page/views/tests-page-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<li>
<form method="post" id="form-run-manual-tests">
<?php wp_nonce_field( 'submit_run_manual_tests', '_wpnonce' ); ?>
<input type="submit" name="submit_run_manual_tests" value="<?php esc_attr_e( 'Run Tests', 'visual-regression-tests' ); ?>"
<input type="submit" name="submit_run_manual_tests" value="<?php esc_attr_e( 'Run All Tests', 'visual-regression-tests' ); ?>"
class="page-title-action button-secondary"
id="<?php echo ( ! $data['is_connected'] || ! $data['running_tests_count'] ) ? 'run-manual-tests-disabled' : 'run-manual-tests'; ?>"
<?php echo ( ! $data['is_connected'] || ! $data['running_tests_count'] ) ? ' disabled' : ''; ?>
Expand Down
13 changes: 13 additions & 0 deletions includes/features/class-tests-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ public function init_notifications() {
add_action( 'admin_notices', [ $this, 'render_notification_test_disabled' ] );
}

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It should be ok here.
$test_started = isset( $_GET['run-manual-test'] );
if ( $test_started ) {
add_action( 'admin_notices', [ $this, 'render_notification_test_started' ] );
}

$remaining_tests = Subscription::get_remaining_tests();
if ( '1' === $remaining_tests ) {
add_action( 'admin_notices', [ $this, 'render_notification_unlock_more_tests' ] );
Expand Down Expand Up @@ -474,6 +480,13 @@ public function render_notification_test_disabled() {
]);
}

/**
* Render test_started Notification.
*/
public function render_notification_test_started() {
Admin_Notices::render_notification( 'test_started', false, []);
}

/**
* Render unlock_more_tests Notification.
*/
Expand Down

0 comments on commit 6b374ad

Please sign in to comment.