2026-01-18 23:33:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-03-31 03:40:18 +00:00
|
|
|
use App\Enums\UserWorkspace\Role;
|
2026-01-18 23:33:45 +00:00
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use App\Models\WorkspaceLabel;
|
|
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2026-04-17 02:05:51 +00:00
|
|
|
$this->user = User::factory()->create([]);
|
2026-01-18 23:33:45 +00:00
|
|
|
$this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
2026-04-15 01:22:04 +00:00
|
|
|
$this->workspace->members()->attach($this->user->id, ['role' => Role::Member->value]);
|
2026-01-18 23:33:45 +00:00
|
|
|
$this->user->update(['current_workspace_id' => $this->workspace->id]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Index tests
|
|
|
|
|
test('labels index requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('labels index shows labels for workspace', function () {
|
|
|
|
|
WorkspaceLabel::factory()->count(3)->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('labels/Index', false)
|
|
|
|
|
->has('workspace')
|
2026-03-31 00:18:07 +00:00
|
|
|
->has('labels.data', 3)
|
2026-01-18 23:33:45 +00:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('labels index redirects if no workspace', function () {
|
|
|
|
|
$this->user->update(['current_workspace_id' => null]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.workspaces.create'));
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Store tests
|
|
|
|
|
test('store label requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->post(route('app.labels.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Test Label',
|
|
|
|
|
'color' => '#FF5733',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store label creates label', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.labels.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'New Label',
|
|
|
|
|
'color' => '#FF5733',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('workspace_labels', [
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'name' => 'New Label',
|
|
|
|
|
'color' => '#FF5733',
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store label validates required fields', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.labels.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => '',
|
|
|
|
|
'color' => '',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors(['name', 'color']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store label validates color format', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.labels.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Valid Name',
|
|
|
|
|
'color' => 'invalid-color',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('color');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Update tests
|
|
|
|
|
test('update label requires authentication', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->put(route('app.labels.update', $label), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Updated Label',
|
|
|
|
|
'color' => '#00FF00',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label updates the label', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.labels.update', $label), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Updated Label',
|
|
|
|
|
'color' => '#00FF00',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$label->refresh();
|
|
|
|
|
expect($label->name)->toBe('Updated Label');
|
|
|
|
|
expect($label->color)->toBe('#00FF00');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label returns 404 for other workspace label', function () {
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $otherWorkspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.labels.update', $label), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Updated Label',
|
|
|
|
|
'color' => '#00FF00',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Destroy tests
|
|
|
|
|
test('destroy label requires authentication', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->delete(route('app.labels.destroy', $label));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('destroy label deletes the label', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->delete(route('app.labels.destroy', $label));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.labels.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
expect(WorkspaceLabel::find($label->id))->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('destroy label returns 404 for other workspace label', function () {
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $otherWorkspace->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->delete(route('app.labels.destroy', $label));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
2026-03-31 00:18:07 +00:00
|
|
|
|
|
|
|
|
test('labels index filters by search query', function () {
|
|
|
|
|
WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'Important']);
|
|
|
|
|
WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'Urgent']);
|
|
|
|
|
WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'Review']);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.labels.index', ['search' => 'import']));
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->has('labels.data', 1)
|
|
|
|
|
->has('filters')
|
|
|
|
|
->where('filters.search', 'import')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('labels index returns all when no search query', function () {
|
|
|
|
|
WorkspaceLabel::factory()->count(3)->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.labels.index'));
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->has('labels.data', 3)
|
|
|
|
|
->where('filters.search', '')
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-31 03:40:18 +00:00
|
|
|
|
|
|
|
|
// Member authorization tests
|
|
|
|
|
test('member can create label', function () {
|
2026-04-17 02:05:51 +00:00
|
|
|
$member = User::factory()->create(['account_id' => $this->workspace->account_id]);
|
2026-03-31 03:40:18 +00:00
|
|
|
$this->workspace->members()->attach($member->id, ['role' => Role::Member->value]);
|
|
|
|
|
$member->update(['current_workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($member)->post(route('app.labels.store'), [
|
|
|
|
|
'name' => 'Test Label',
|
|
|
|
|
'color' => '#FF0000',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
expect($this->workspace->labels()->count())->toBe(1);
|
|
|
|
|
});
|
feat: social account toggle action, API, MCP + full test coverage
- Extract ToggleSocialAccount action from SocialController
- Add API endpoints: GET /social-accounts, PUT /social-accounts/{id}/toggle
- Add MCP tools: ListSocialAccountsTool, ToggleSocialAccountTool
- Fix all MCP tools: findOrFail → find + Response::error for graceful errors
- Fix MCP tools using $request->validated() without validate() call
- Fix return types to Response|ResponseFactory for error paths
- Add SocialAccountResource is_active/status fields (no tokens exposed)
- Add 43 MCP tests covering all 18 tools (CRUD, validation, cross-workspace)
- Add API response structure tests for posts, hashtags, labels, workspace
- Add API validation tests for post create/update, api-key expiry, label color
- Add API cross-workspace delete tests for hashtags and labels
- Add app validation tests for hashtag/label update, invite fields, password
- Add auth required tests for notifications, profile delete, api-keys index
- Add media reorder validation tests
2026-03-31 04:42:39 +00:00
|
|
|
|
|
|
|
|
test('update label validates required fields', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)->put(route('app.labels.update', $label), []);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors(['name', 'color']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label validates color format', function () {
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)->put(route('app.labels.update', $label), [
|
|
|
|
|
'name' => 'Test',
|
|
|
|
|
'color' => 'invalid',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('color');
|
|
|
|
|
});
|