Skip to content

Commit

Permalink
Merge pull request #65 from bleech/harun/TestRuns
Browse files Browse the repository at this point in the history
Harun/test runs
  • Loading branch information
harunbleech authored Jun 12, 2024
2 parents 1c9045f + 15c39c0 commit ece5bd9
Show file tree
Hide file tree
Showing 22 changed files with 458 additions and 116 deletions.
4 changes: 2 additions & 2 deletions assets/admin.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "@wordpress/base-styles/colors.native"; // stylelint-disable-line scss/at-import-partial-extension

.vrts_list_table_page {
.vrts-list-table-page {

.vrts-testing-status {
display: flex;
Expand All @@ -17,7 +17,7 @@
}

&--waiting {
color: $alert-yellow;
color: #F97B06;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}

&--waiting {
color: $alert-yellow;
color: #F97B06;
}

&--running {
Expand Down
2 changes: 1 addition & 1 deletion components/alerts-page/_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $breakpoint-mobile-horizontal: $break-mobile;
$breakpoint-tablet: $break-medium; /* adminbar goes big */
$navigation-item-border-height: 3px;

.vrts_list_table_page {
.vrts-list-table-page {

.alert-status {
display: block;
Expand Down
2 changes: 1 addition & 1 deletion components/alerts-page/views/alerts-page-list.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="wrap vrts_list_table_page">
<div class="wrap vrts-list-table-page">
<h1 class="wp-heading-inline">
<?php esc_html_e( 'Alerts', 'visual-regression-tests' ); ?>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion components/metabox-classic-editor/_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}

&--waiting {
color: $alert-yellow;
color: #F97B06;
}

&--running {
Expand Down
127 changes: 102 additions & 25 deletions components/test-runs-page/_style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
@import "@wordpress/base-styles/colors.native"; // stylelint-disable-line scss/at-import-partial-extension
@import "@wordpress/base-styles/breakpoints";

.vrts-list-table-page {
.vrts-test-run-trigger {
display: inline-block;
border-radius: 32px;
padding: 4px 10px;
font-size: 13px;
background: rgba(192, 192, 192, 0.15);
color: $gray-80;

&--api {
background: rgba(224, 84, 6, 0.15);
color: #AE4204;
}

&--scheduled {
background: rgba(106, 26, 185, 0.1);
color: #591B98;
}

&--manual {
background: rgba(5, 116, 206, 0.1);
color: #045495;

}

&--updates {
background: rgba(200, 11, 147, 0.1);
color: #A51D7F;
}
}

.vrts-test-run-trigger-notes {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

.vrts-test-runs-page {
.tablenav.top {
clear: none;
Expand All @@ -20,7 +58,7 @@
}

&--scheduled {
color: $alert-yellow;
color: #F97B06;
}

&--has-alerts {
Expand All @@ -36,46 +74,85 @@
color: $blue-50;
}

[data-vrts-test-run-status="running"] .row-title {
color: #F97B06;
}

.row-actions {
position: static;
display: flex;
flex-wrap: wrap;
gap: 4px;

.tests {
color: $gray-80;
}
}

.vrts-test-run-trigger {
display: inline-block;
border-radius: 32px;
padding: 4px 10px;
font-size: 13px;
.details {
visibility: hidden;

&--api {
background: rgba(224, 84, 6, 0.15);
color: #AE4204;
&::before {
content: " | ";
}
}
}

&--scheduled {
background: rgba(106, 26, 185, 0.1);
color: #591B98;
tr:hover {
.row-actions {
.details {
visibility: visible;
}
}
}
}

&--manual {
background: rgba(5, 116, 206, 0.1);
color: #045495;
.vrts-test-runs-list-queue-table {
margin-top: 10px;
margin-bottom: 20px;

thead,
tfoot {
display: none;
}

.subsubsub:has(+ &) {
float: none;
}
}

.vrts-test-run-details {
display: none;

[data-vrts-test-run-details="visible"] & {
display: block;
}

.vrts-test-run-details-section {
margin: 15px 0;

&:first-child {
margin-top: 25px;
}

&--core,
&--plugin {
background: rgba(200, 11, 147, 0.1);
color: #A51D7F;
&-title {
color: $alert-red;
font-weight: 600;
border-bottom: 1px solid $gray-5;
padding-bottom: 10px;
margin-bottom: 10px;
}

&--passed {
.vrts-test-run-details-section-title {
color: $alert-green;
}
}

ul {
margin: 0;
}
}

.vrts-test-run-trigger-notes {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.button {
margin-bottom: 4px;
}
}
10 changes: 1 addition & 9 deletions components/test-runs-page/index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php

?>

<div class="wrap vrts_list_table_page vrts-test-runs-page">
<div class="wrap vrts-list-table-page vrts-test-runs-page">
<h1 class="wp-heading-inline">
<?php esc_html_e( 'Runs', 'visual-regression-tests' ); ?>
</h1>
Expand All @@ -14,10 +10,6 @@
$list_table->prepare_items();
$list_table->views();
$list_table->display();

if ( $list_table->has_items() ) {
$list_table->inline_edit();
}
?>

<form method="post">
Expand Down
14 changes: 14 additions & 0 deletions components/test-runs-page/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
document
.querySelectorAll( '.vrts-show-test-run-details' )
.forEach( ( element ) => {
element.addEventListener( 'click', ( e ) => {
e.preventDefault();
const $row = element.closest( 'tr' );
const isHidden = $row.getAttribute( 'data-vrts-test-run-details' ) === 'hidden';
$row.setAttribute(
'data-vrts-test-run-details',
isHidden ? 'visible' : 'hidden'
);
console.log( 'Show test run details' );
} );
} );
2 changes: 1 addition & 1 deletion components/tests-page/_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
}

.vrts_list_table_page {
.vrts-list-table-page {

.quick-edit-row-test {

Expand Down
2 changes: 1 addition & 1 deletion components/tests-page/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ window.wp = window.wp || {};
};

$( function () {
if ( $( '.vrts_list_table_page' ).length ) {
if ( $( '.vrts-list-table-page' ).length ) {
inlineEditTest.init();
}
} );
Expand Down
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 @@ -6,7 +6,7 @@

?>

<div class="wrap vrts_list_table_page">
<div class="wrap vrts-list-table-page">
<h1 class="wp-heading-inline">
<?php esc_html_e( 'Tests', 'visual-regression-tests' ); ?>
</h1>
Expand Down
11 changes: 11 additions & 0 deletions includes/features/class-cron-jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public function fetch_test_updates( $test_id, $try_number = 1 ) {
}
}

/**
* Fetch test run updates.
*
* @param int $test_run_id Test run id.
* @param int $try_number Try number.
*/
public function fetch_test_run_updates( $test_run_id, $try_number = 1 ) {
$test_run = Test_Run::get_item( $test_run_id );
if ( empty( $test_run ) || empty( $test_run->finished_at ) ) {
Expand All @@ -96,6 +102,11 @@ public static function schedule_initial_fetch_test_updates( $test_id ) {
wp_schedule_single_event( time(), 'vrts_fetch_test_updates', [ $test_id, 1 ] );
}

/**
* Schedule initial fetch test run updates.
*
* @param int $test_run_id Test run id.
*/
public static function schedule_initial_fetch_test_run_updates( $test_run_id ) {
wp_schedule_single_event( time(), 'vrts_fetch_test_run_updates', [ $test_run_id, 1 ] );
}
Expand Down
1 change: 1 addition & 0 deletions includes/features/class-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ private static function get_rest_url() {
* Run manual tests.
*
* @param string[] $service_test_ids the service test ids.
* @param array $options the options.
*/
public static function run_manual_tests( $service_test_ids, $options = [] ) {
$service_project_id = get_option( 'vrts_project_id' );
Expand Down
52 changes: 30 additions & 22 deletions includes/features/class-settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,31 @@ public function add_settings() {
'title' => 'Test Configuration',
]);

vrts()->settings()->add_setting([
'type' => 'checkbox',
'id' => 'vrts_automatic_comparison',
'title' => esc_html__( 'Daily', 'visual-regression-tests' ),
'label' => esc_html__( 'Run daily scheduled tests.', 'visual-regression-tests' ),
'section' => 'vrts-settings-section-test-configuration',
'sanitize_callback' => [ Sanitization::class, 'sanitize_checkbox' ],
'show_in_rest' => true,
'value_type' => 'boolean',
'default' => 1,
]);
if ( '1' === $has_subscription ) {
vrts()->settings()->add_setting([
'type' => 'checkbox',
'id' => 'vrts_automatic_comparison',
'title' => esc_html__( 'Daily', 'visual-regression-tests' ),
'label' => esc_html__( 'Run daily scheduled tests.', 'visual-regression-tests' ),
'section' => 'vrts-settings-section-test-configuration',
'sanitize_callback' => [ Sanitization::class, 'sanitize_checkbox' ],
'show_in_rest' => true,
'value_type' => 'boolean',
'default' => 1,
]);

vrts()->settings()->add_setting([
'type' => 'checkbox',
'id' => 'vrts_updates_comparison',
'title' => esc_html__( 'Post-Updates', 'visual-regression-tests' ),
'label' => esc_html__( 'Run tests automatically after WordPress has been updated to a new version.', 'visual-regression-tests' ),
'section' => 'vrts-settings-section-test-configuration',
'sanitize_callback' => [ Sanitization::class, 'sanitize_checkbox' ],
'show_in_rest' => true,
'value_type' => 'boolean',
'default' => 1,
]);
vrts()->settings()->add_setting([
'type' => 'checkbox',
'id' => 'vrts_updates_comparison',
'title' => esc_html__( 'Post Updates', 'visual-regression-tests' ),
'label' => esc_html__( 'Run tests automatically after WordPress has been updated to a new version.', 'visual-regression-tests' ),
'section' => 'vrts-settings-section-test-configuration',
'sanitize_callback' => [ Sanitization::class, 'sanitize_checkbox' ],
'show_in_rest' => true,
'value_type' => 'boolean',
'default' => 1,
]);
}//end if

vrts()->settings()->add_setting([
'type' => 'text',
Expand Down Expand Up @@ -243,6 +245,12 @@ public function do_before_add_license_key( $new, $old ) {
return $old;
}

/**
* Update automatic comparison settings for project in service
*
* @param string $old Old value.
* @param string $new New value.
*/
public function do_after_update_vrts_automatic_comparison( $old, $new ) {
if ( $old !== $new ) {
$service_project_id = get_option( 'vrts_project_id' );
Expand Down
Loading

0 comments on commit ece5bd9

Please sign in to comment.