Bladeren bron

test(api-v13): ExampleTest 改成真实的冒烟测试

它断言的是 route('home'),但本应用没有叫 home 的路由(首页是未命名的 /,
library 那个叫 library.home),所以从建库起就一直红着,是 Laravel 脚手架的样板。

改成两条真冒烟:/ 与 library.home 都能渲染。页面渲染依赖 Vite manifest,
CI 里 npm run build 排在 pest 之前(.github/workflows/tests.yml),本地没构建过
会抛 ViteException——那本身就是个有用的信号,注释里写明了。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
visuddhinanda 3 weken geleden
bovenliggende
commit
52c365c323
1 gewijzigde bestanden met toevoegingen van 17 en 4 verwijderingen
  1. 17 4
      api-v13/tests/Feature/ExampleTest.php

+ 17 - 4
api-v13/tests/Feature/ExampleTest.php

@@ -1,7 +1,20 @@
 <?php
 <?php
 
 
-test('returns a successful response', function () {
-    $response = $this->get(route('home'));
+/**
+ * 冒烟测试:应用能不能起来、首页能不能渲染。
+ *
+ * 原来这条断言的是 `route('home')`,那是 Laravel 脚手架的样板——本应用没有叫
+ * `home` 的路由(首页是未命名的 `/`,library 那个叫 `library.home`),所以它
+ * 从建库起就一直红着。
+ *
+ * 页面渲染依赖 Vite manifest,CI 里 `npm run build` 排在 `pest` 之前(见
+ * .github/workflows/tests.yml),本地没构建过的话这两条会报 ViteException——
+ * 那本身就是个有用的信号。
+ */
+test('the site index renders', function () {
+    $this->get('/')->assertOk();
+});
 
 
-    $response->assertOk();
-});
+test('the library home renders', function () {
+    $this->get(route('library.home'))->assertOk();
+});