diff --git a/src/Plugins/Tia/Graph.php b/src/Plugins/Tia/Graph.php index 207db7c7..53107c07 100644 --- a/src/Plugins/Tia/Graph.php +++ b/src/Plugins/Tia/Graph.php @@ -655,13 +655,7 @@ final class Graph if (isset($handledBlade[$rel])) { continue; } - if (! isset($this->fileIds[$rel])) { - if (! is_file($this->projectRoot.'/'.$rel)) { - continue; - } - - $watchedPaths[] = $rel; - } elseif ($this->isFrameworkBootPath($rel)) { + if (! isset($this->fileIds[$rel]) || $this->isFrameworkBootPath($rel)) { $watchedPaths[] = $rel; } } diff --git a/tests/Features/Tia/WatchFallbacks.php b/tests/Features/Tia/WatchFallbacks.php index aba4645e..4a9318b2 100644 --- a/tests/Features/Tia/WatchFallbacks.php +++ b/tests/Features/Tia/WatchFallbacks.php @@ -63,3 +63,31 @@ test('still runs every test without a baseline when defaults are disabled', func expect($result->exitCode)->toBe(0, $result->describe()) ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed'); })->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows(); + +test('runs dependent tests when a watched path is removed', function (array $gitArguments, array $arguments): void { + $project = Project::make('master'); + $project->write('schema/api.graphql', "type Query { status: String }\n"); + $project->write('tests/Pest.php', file_get_contents($project->path('tests/Pest.php')). + "\npest()->tia()->withoutDefaultWatchPatterns()->watch(['schema/*.graphql' => 'tests/Unit/GreeterTest.php']);\n"); + + $test = 'tests/Unit/GreeterTest.php'; + $project->write($test, str_replace( + "test('greets a person', function (): void {", + "test('greets a person', function (): void {\n expect('schema/api.graphql')->toBeFile();", + file_get_contents($project->path($test)), + )); + + $project->git()->commit('add a watched schema and its test'); + $project->seed('master'); + $project->git()->run($gitArguments); + $project->git()->commit('remove the watched path'); + + $result = $project->pest('--tia', '--filtered', ...$arguments); + + expect($result->exitCode)->toBe(1, $result->describe()) + ->and($result->affected())->toBe(2, $result->describe()) + ->and($result->output)->toContain('greets a person', 'schema/api.graphql'); +})->with([ + 'deleted' => [['rm', '--', 'schema/api.graphql']], + 'renamed' => [['mv', '--', 'schema/api.graphql', 'moved.graphql']], +])->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();