2026-03-29 22:59:17 +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-29 22:59:17 +00:00
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use App\Models\WorkspaceLabel;
|
|
|
|
|
|
|
|
|
|
function createLabelApiToken(array $overrides = []): array
|
|
|
|
|
{
|
2026-05-03 21:38:17 +00:00
|
|
|
return createApiTestToken($overrides);
|
2026-03-29 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test('list labels', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
WorkspaceLabel::factory()->count(3)->create([
|
|
|
|
|
'workspace_id' => $result['workspace']->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->getJson(
|
|
|
|
|
route('api.labels.index'),
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertJsonCount(3);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('create label', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->postJson(
|
|
|
|
|
route('api.labels.store'),
|
|
|
|
|
[
|
|
|
|
|
'name' => 'Marketing',
|
|
|
|
|
'color' => '#FF0000',
|
|
|
|
|
],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertCreated();
|
|
|
|
|
$response->assertJsonPath('name', 'Marketing');
|
|
|
|
|
$response->assertJsonPath('color', '#FF0000');
|
|
|
|
|
|
|
|
|
|
expect($result['workspace']->labels()->count())->toBe(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('create label validation errors', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->postJson(
|
|
|
|
|
route('api.labels.store'),
|
|
|
|
|
[],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertUnprocessable();
|
|
|
|
|
$response->assertJsonValidationErrors(['name', 'color']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('create label validates color format', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->postJson(
|
|
|
|
|
route('api.labels.store'),
|
|
|
|
|
[
|
|
|
|
|
'name' => 'Bad Color',
|
|
|
|
|
'color' => 'not-a-color',
|
|
|
|
|
],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertUnprocessable();
|
|
|
|
|
$response->assertJsonValidationErrors(['color']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$label = WorkspaceLabel::factory()->create([
|
|
|
|
|
'workspace_id' => $result['workspace']->id,
|
|
|
|
|
'name' => 'Old Name',
|
|
|
|
|
'color' => '#000000',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->putJson(
|
|
|
|
|
route('api.labels.update', $label),
|
|
|
|
|
[
|
|
|
|
|
'name' => 'Updated Name',
|
|
|
|
|
'color' => '#FFFFFF',
|
|
|
|
|
],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertJsonPath('name', 'Updated Name');
|
|
|
|
|
$response->assertJsonPath('color', '#FFFFFF');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('delete label', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$label = WorkspaceLabel::factory()->create([
|
|
|
|
|
'workspace_id' => $result['workspace']->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->deleteJson(
|
|
|
|
|
route('api.labels.destroy', $label),
|
|
|
|
|
[],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertNoContent();
|
|
|
|
|
|
|
|
|
|
expect(WorkspaceLabel::find($label->id))->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cannot access labels from another workspace', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create([
|
|
|
|
|
'workspace_id' => $otherWorkspace->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->putJson(
|
|
|
|
|
route('api.labels.update', $label),
|
|
|
|
|
[
|
|
|
|
|
'name' => 'Hacked Name',
|
|
|
|
|
'color' => '#FF0000',
|
|
|
|
|
],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
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('cannot update label from another workspace', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $otherWorkspace->id]);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.data_get($result, 'plain_token')])
|
|
|
|
|
->putJson(route('api.labels.update', $label), [
|
|
|
|
|
'name' => 'Hacked',
|
|
|
|
|
'color' => '#000000',
|
|
|
|
|
])
|
|
|
|
|
->assertNotFound();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label validation errors', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => data_get($result, 'workspace')->id]);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.data_get($result, 'plain_token')])
|
|
|
|
|
->putJson(route('api.labels.update', $label), [])
|
|
|
|
|
->assertUnprocessable();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update label validates color format', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => data_get($result, 'workspace')->id]);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.data_get($result, 'plain_token')])
|
|
|
|
|
->putJson(route('api.labels.update', $label), [
|
|
|
|
|
'name' => 'Test',
|
|
|
|
|
'color' => 'invalid',
|
|
|
|
|
])
|
|
|
|
|
->assertUnprocessable();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('list labels returns correct structure', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
WorkspaceLabel::factory()->create(['workspace_id' => data_get($result, 'workspace')->id]);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.data_get($result, 'plain_token')])
|
|
|
|
|
->getJson(route('api.labels.index'))
|
|
|
|
|
->assertOk()
|
|
|
|
|
->assertJsonStructure([
|
|
|
|
|
'*' => ['id', 'name', 'color', 'created_at', 'updated_at'],
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cannot delete label from another workspace', function () {
|
|
|
|
|
$result = createLabelApiToken();
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$label = WorkspaceLabel::factory()->create(['workspace_id' => $otherWorkspace->id]);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.data_get($result, 'plain_token')])
|
|
|
|
|
->deleteJson(route('api.labels.destroy', $label))
|
|
|
|
|
->assertNotFound();
|
|
|
|
|
});
|