From 2f047f2f7e93da6580af5c06ae3d6a108832a433 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Tue, 2 Jun 2026 08:45:11 -0300 Subject: [PATCH] Fix workspace name-only update rejected by required brand fields The Workspace and Brand settings tabs both submit to the same updateSettings endpoint, but the Workspace tab sends only the name. UpdateWorkspaceRequest marked brand_font and image_style as required, so the name-only request failed validation silently (the form only renders the name error). Mark both brand fields as sometimes|required so a name-only update succeeds while the Brand tab still validates them. Closes #74 --- .../App/Workspace/UpdateWorkspaceRequest.php | 4 ++-- tests/Feature/WorkspaceControllerTest.php | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php b/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php index 3abeec7f..40514942 100644 --- a/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php +++ b/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php @@ -29,8 +29,8 @@ public function rules(): array 'brand_color' => $hex, 'background_color' => $hex, 'text_color' => $hex, - 'brand_font' => ['required', 'string', Rule::in(BrandFont::values())], - 'image_style' => ['required', 'string', Rule::in(ImageStyle::values())], + 'brand_font' => ['sometimes', 'required', 'string', Rule::in(BrandFont::values())], + 'image_style' => ['sometimes', 'required', 'string', Rule::in(ImageStyle::values())], 'content_language' => ['sometimes', 'string', 'in:en,pt-BR,es'], ]; } diff --git a/tests/Feature/WorkspaceControllerTest.php b/tests/Feature/WorkspaceControllerTest.php index 1922f0c5..aa0ed4f2 100644 --- a/tests/Feature/WorkspaceControllerTest.php +++ b/tests/Feature/WorkspaceControllerTest.php @@ -232,6 +232,27 @@ expect($this->workspace->refresh()->image_style->value)->toBe('minimalist'); }); +test('update workspace settings updates the name when only the name is submitted', function () { + $this->actingAs($this->user) + ->from(route('app.workspace.settings')) + ->put(route('app.workspace.settings.update'), [ + 'name' => 'Name Only Update', + ]) + ->assertRedirect(route('app.workspace.settings')) + ->assertSessionHasNoErrors(); + + expect($this->workspace->refresh()->name)->toBe('Name Only Update'); +}); + +test('update workspace settings still requires brand_font and image_style when submitted empty', function () { + $this->actingAs($this->user) + ->put(route('app.workspace.settings.update'), [ + 'name' => $this->workspace->name, + 'brand_font' => '', + 'image_style' => '', + ])->assertSessionHasErrors(['brand_font', 'image_style']); +}); + test('update workspace settings rejects unknown image_style values', function () { $this->actingAs($this->user) ->put(route('app.workspace.settings.update'), [