From cc30198fbfeae0bd2173dbfd57e2d23dda071d49 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 14 May 2026 15:25:57 -0400 Subject: [PATCH] Implement test delta in new tests page The legacy `viewTest.php` page supports an `onlydelta` query parameter which shows only the tests for which the status changed between the previous and current builds. That functionality is used to implement the positive superscripts on the builds page. This PR brings the same functionality to the new build tests page, paving the way for the imminent deletion of the legacy page. --- app/Http/Controllers/BuildController.php | 16 +- .../js/angular/views/partials/build.html | 10 +- .../js/vue/components/BuildTestsPage.vue | 210 +++++++++++++----- tests/Browser/Pages/BuildTestsPageTest.php | 138 ++++++++++++ 4 files changed, 305 insertions(+), 69 deletions(-) diff --git a/app/Http/Controllers/BuildController.php b/app/Http/Controllers/BuildController.php index ef4a523355..60bb1977bc 100644 --- a/app/Http/Controllers/BuildController.php +++ b/app/Http/Controllers/BuildController.php @@ -121,7 +121,7 @@ public function update(int $build_id): View ]); } - public function tests(int $build_id): View + public function tests(Request $request, int $build_id): View { $this->setBuildById($build_id); @@ -129,14 +129,24 @@ public function tests(int $build_id): View $eloquent_project = Project::findOrFail((int) $this->project->Id); - return $this->vue('build-tests-page', 'Tests', [ + $params = [ 'build-id' => $this->build->Id, 'show-test-time-status' => (bool) $eloquent_project->showtesttime, 'project-name' => $eloquent_project->name, 'build-time' => Carbon::parse($this->build->StartTime)->toIso8601String(), 'initial-filters' => $filters, 'pinned-measurements' => $eloquent_project->pinnedTestMeasurements()->orderBy('position')->pluck('name')->toArray(), - ]); + ]; + + if ($request->has('onlydelta')) { + $params['only-delta'] = true; + $previousBuildId = $this->build->GetPreviousBuildId(); + if ($previousBuildId > 0) { + $params['previous-build-id'] = $previousBuildId; + } + } + + return $this->vue('build-tests-page', 'Tests', $params); } public function coverage(int $build_id): View diff --git a/resources/js/angular/views/partials/build.html b/resources/js/angular/views/partials/build.html index 66cba572df..6b4d202463 100644 --- a/resources/js/angular/views/partials/build.html +++ b/resources/js/angular/views/partials/build.html @@ -335,7 +335,7 @@ {{::build.test.notrun}} - + +{{::build.test.nnotrundiffp}} -{{::build.test.nnotrundiffn}} @@ -348,7 +348,7 @@ {{::build.test.fail}} - + +{{::build.test.nfaildiffp}} @@ -363,7 +363,7 @@ {{::build.test.pass}} - + +{{::build.test.npassdiffp}} @@ -382,7 +382,7 @@ {{::build.test.timestatus}} - + +{{::build.test.ntimediffp}} @@ -392,7 +392,7 @@ {{::build.test.time}} - + +{{::build.test.ntimediffp}} diff --git a/resources/js/vue/components/BuildTestsPage.vue b/resources/js/vue/components/BuildTestsPage.vue index 5eba0cbeff..bfb18c8b9a 100644 --- a/resources/js/vue/components/BuildTestsPage.vue +++ b/resources/js/vue/components/BuildTestsPage.vue @@ -13,8 +13,15 @@ :execute-query-link="executeQueryLink" @change-filters="filters => changedFilters = filters" /> - + +
+ No tests with changed state for this build. +
id}/tests?onlydelta") + ->waitFor('@tests-table') + ->assertDontSeeIn('@tests-table', $current_test_failed_again->testname) + ->assertSeeIn('@tests-table', $current_test_newly_failed->testname) + ->assertSeeIn('@tests-table', $current_test_entirely_new_failed->testname) + ->assertSeeIn('@tests-table', $current_test_fixed->testname) + ->assertDontSeeIn('@tests-table', $current_test_stayed_passed->testname) + ; + }); + } + + public function testOnlyDeltaNoResults(): void + { + /** @var Build $previous_build */ + $previous_build = $this->project->builds()->create([ + 'siteid' => $this->site->id, + 'name' => 'test-build', + 'uuid' => Str::uuid()->toString(), + 'starttime' => '2025-01-01 10:00:00', + 'type' => 'Experimental', + ]); + + /** @var Test $previous_test_failed */ + $previous_test_failed = $previous_build->tests()->create([ + 'testname' => 'failed-before', + 'status' => 'failed', + 'outputid' => $this->testOutput->id, + ]); + + /** @var Build $current_build */ + $current_build = $this->project->builds()->create([ + 'siteid' => $this->site->id, + 'name' => 'test-build', + 'uuid' => Str::uuid()->toString(), + 'starttime' => '2025-01-01 11:00:00', + 'type' => 'Experimental', + ]); + + /** @var Test $current_test_failed_again */ + $current_test_failed_again = $current_build->tests()->create([ + 'testname' => 'failed-before', + 'status' => 'failed', + 'outputid' => $this->testOutput->id, + ]); + + $this->browse(function (Browser $browser) use ($current_build): void { + $browser->visit("/builds/{$current_build->id}/tests?onlydelta") + ->waitForText('No tests with changed state for this build.') + ->assertSee('No tests with changed state for this build.') + ->assertMissing('@tests-table') + ; + }); + } }