Merge pull request 'fix: standardize JSON response format in TextWidgetController and update related tests' (#12) from fix/api-inconsistencies into dev

Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/12
This commit is contained in:
Jon Brookes 2026-01-15 19:04:22 +01:00
commit 0d688a0f82
2 changed files with 7 additions and 2 deletions

View file

@ -14,7 +14,9 @@ class TextWidgetController extends Controller
*/ */
public function index() public function index()
{ {
return TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw)); return response()->json([
'data' => TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw))
]);
} }
/** /**

View file

@ -14,7 +14,10 @@ test('can list text widgets', function () {
$response = $this->actingAs($user)->getJson('/api/text-widgets'); $response = $this->actingAs($user)->getJson('/api/text-widgets');
$response->assertOk() $response->assertOk()
->assertJsonCount(3); ->assertJson(fn ($json) =>
$json->has('data', 3)
->etc()
);
}); });
test('can create a text widget', function () { test('can create a text widget', function () {