diff --git a/resources/js/pages/taxonomies/Show.vue b/resources/js/pages/taxonomies/Show.vue
index fe06b007886..a6046715267 100644
--- a/resources/js/pages/taxonomies/Show.vue
+++ b/resources/js/pages/taxonomies/Show.vue
@@ -139,7 +139,7 @@ export default {
{{ term.slug }}
-
+
diff --git a/src/Http/Resources/CP/Taxonomies/ListedTerm.php b/src/Http/Resources/CP/Taxonomies/ListedTerm.php
index 1aa5e99c459..9065299626a 100644
--- a/src/Http/Resources/CP/Taxonomies/ListedTerm.php
+++ b/src/Http/Resources/CP/Taxonomies/ListedTerm.php
@@ -40,6 +40,7 @@ public function toArray($request)
'permalink' => $term->absoluteUrl(),
'edit_url' => $term->editUrl(),
+ 'has_template' => view()->exists($term->template()),
'taxonomy' => $term->taxonomy()->toArray(),
'viewable' => User::current()->can('view', $term),
'editable' => User::current()->can('edit', $term),
diff --git a/tests/Feature/Taxonomies/ViewTermsListingTest.php b/tests/Feature/Taxonomies/ViewTermsListingTest.php
index 48ab1e4873f..b2eb150923d 100644
--- a/tests/Feature/Taxonomies/ViewTermsListingTest.php
+++ b/tests/Feature/Taxonomies/ViewTermsListingTest.php
@@ -6,12 +6,13 @@
use Statamic\Facades\Taxonomy;
use Statamic\Facades\Term;
use Statamic\Facades\User;
+use Tests\FakesViews;
use Tests\PreventSavingStacheItemsToDisk;
use Tests\TestCase;
class ViewTermsListingTest extends TestCase
{
- use PreventSavingStacheItemsToDisk;
+ use FakesViews, PreventSavingStacheItemsToDisk;
#[Test]
public function it_does_not_eager_load_actions_in_listing()
@@ -28,4 +29,37 @@ public function it_does_not_eager_load_actions_in_listing()
->assertJsonCount(1, 'data')
->assertJsonMissingPath('data.0.actions');
}
+
+ #[Test]
+ public function it_returns_has_template_true_when_template_exists()
+ {
+ $this->withFakeViews();
+ $this->viewShouldReturnRaw('tags.show', '');
+
+ $user = tap(User::make()->makeSuper())->save();
+ $taxonomy = tap(Taxonomy::make('tags'))->save();
+ tap(Term::make()->taxonomy('tags')->inDefaultLocale()->slug('alfa')->data(['title' => 'alfa']))->save();
+
+ $this
+ ->actingAs($user)
+ ->getJson(cp_route('taxonomies.terms.index', $taxonomy->handle()))
+ ->assertSuccessful()
+ ->assertJsonPath('data.0.has_template', true);
+ }
+
+ #[Test]
+ public function it_returns_has_template_false_when_template_does_not_exist()
+ {
+ $this->withFakeViews();
+
+ $user = tap(User::make()->makeSuper())->save();
+ $taxonomy = tap(Taxonomy::make('tags'))->save();
+ tap(Term::make()->taxonomy('tags')->inDefaultLocale()->slug('alfa')->data(['title' => 'alfa']))->save();
+
+ $this
+ ->actingAs($user)
+ ->getJson(cp_route('taxonomies.terms.index', $taxonomy->handle()))
+ ->assertSuccessful()
+ ->assertJsonPath('data.0.has_template', false);
+ }
}