From 85d24777b5feac4abcb35faea215955ce8a93133 Mon Sep 17 00:00:00 2001 From: cyppe Date: Sat, 31 Oct 2026 15:46:43 +0100 Subject: [PATCH] fix(tia): let JS modules no Inertia page imports fall back to the watch patterns (#1936) --- src/Plugins/Tia/Graph.php | 2 -- tests/Features/Tia/SelectionPaths.php | 21 +++++++++++++++++++ .../Tia/overlays/js-watch/tests/Pest.php | 8 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/Fixtures/Tia/overlays/js-watch/tests/Pest.php diff --git a/src/Plugins/Tia/Graph.php b/src/Plugins/Tia/Graph.php index 38e0918a..cbf74210 100644 --- a/src/Plugins/Tia/Graph.php +++ b/src/Plugins/Tia/Graph.php @@ -355,8 +355,6 @@ final class Graph $pages = $freshMap[$rel] ?? []; if ($pages === []) { - $sharedFilesResolved[$rel] = true; - continue; } diff --git a/tests/Features/Tia/SelectionPaths.php b/tests/Features/Tia/SelectionPaths.php index 6957b034..4d58d090 100644 --- a/tests/Features/Tia/SelectionPaths.php +++ b/tests/Features/Tia/SelectionPaths.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Pest\Plugins\Tia\JsModuleGraph; use Tests\Fixtures\Tia\Project; afterEach(function (): void { @@ -216,3 +217,23 @@ test('a changed frontend runtime file selects every Inertia test', function (): expect($result->affected())->toBe(2, $result->describe()) ->and($result->replayed())->toBe(4, $result->describe()); })->skipOnWindows(); + +test('a changed JS module that no Inertia page imports falls back to the watch patterns', function (): void { + $project = Project::make('master', 'js-watch'); + $project->write('vite.config.js', "export default {}\n"); + $project->write('resources/js/widget.js', "export const widget = 1\n"); + $project->git()->commit('add a Vite app without Inertia pages'); + + $project->seed('master'); + + $fingerprint = new ReflectionMethod(JsModuleGraph::class, 'fingerprint')->invoke(null, $project->path()); + file_put_contents($project->graphDir().DIRECTORY_SEPARATOR.'js-module-graph.cache.json', json_encode(['fingerprint' => $fingerprint, 'graph' => []])); + + $project->write('resources/js/widget.js', "export const widget = 2\n"); + $project->snapshot(); + + $result = $project->pest('--tia'); + + expect($result->affected())->toBe(6, $result->describe()) + ->and($result->replayed())->toBe(0, $result->describe()); +})->skipOnWindows(); diff --git a/tests/Fixtures/Tia/overlays/js-watch/tests/Pest.php b/tests/Fixtures/Tia/overlays/js-watch/tests/Pest.php new file mode 100644 index 00000000..6d9fc6a1 --- /dev/null +++ b/tests/Fixtures/Tia/overlays/js-watch/tests/Pest.php @@ -0,0 +1,8 @@ +tia()->watch(['resources/js/**' => 'tests']);