2026-01-18 18:56:51 +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-01-18 18:56:51 +00:00
|
|
|
use App\Enums\SocialAccount\Platform;
|
|
|
|
|
use App\Enums\SocialAccount\Status;
|
2026-03-31 03:40:18 +00:00
|
|
|
use App\Enums\UserWorkspace\Role;
|
2026-01-18 18:56:51 +00:00
|
|
|
use App\Models\SocialAccount;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use Illuminate\Support\Facades\Http;
|
2026-06-25 16:54:16 +00:00
|
|
|
use Inertia\Testing\AssertableInertia;
|
2026-01-18 18:56:51 +00:00
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
$this->user = User::factory()->create();
|
|
|
|
|
$this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
|
|
|
|
$this->user->update(['current_workspace_id' => $this->workspace->id]);
|
2026-04-15 01:22:04 +00:00
|
|
|
$this->workspace->members()->attach($this->user->id, ['role' => Role::Member->value]);
|
2026-01-18 18:56:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('bluesky connect page can be rendered', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.social.bluesky.connect'));
|
2026-01-18 18:56:51 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('user can connect bluesky account with valid credentials', function () {
|
|
|
|
|
Http::fake([
|
|
|
|
|
'https://bsky.social/xrpc/com.atproto.server.createSession' => Http::response([
|
|
|
|
|
'did' => 'did:plc:testuser123',
|
|
|
|
|
'handle' => 'testuser.bsky.social',
|
|
|
|
|
'accessJwt' => 'test-access-token',
|
|
|
|
|
'refreshJwt' => 'test-refresh-token',
|
|
|
|
|
], 200),
|
|
|
|
|
'https://bsky.social/xrpc/app.bsky.actor.getProfile*' => Http::response([
|
|
|
|
|
'did' => 'did:plc:testuser123',
|
|
|
|
|
'handle' => 'testuser.bsky.social',
|
|
|
|
|
'displayName' => 'Test User',
|
|
|
|
|
'avatar' => null,
|
|
|
|
|
], 200),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.social.bluesky.store'), [
|
2026-01-18 18:56:51 +00:00
|
|
|
'identifier' => 'testuser.bsky.social',
|
|
|
|
|
'password' => 'xxxx-xxxx-xxxx-xxxx',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
2026-06-25 16:54:16 +00:00
|
|
|
$response->assertInertia(fn (AssertableInertia $page) => $page->component('accounts/PopupCallback'));
|
|
|
|
|
$response->assertInertia(fn (AssertableInertia $page) => $page->where('success', true));
|
2026-01-18 18:56:51 +00:00
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('social_accounts', [
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'platform' => Platform::Bluesky->value,
|
|
|
|
|
'platform_user_id' => 'did:plc:testuser123',
|
|
|
|
|
'username' => 'testuser.bsky.social',
|
|
|
|
|
'status' => Status::Connected->value,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('user cannot connect bluesky with invalid credentials', function () {
|
|
|
|
|
Http::fake([
|
|
|
|
|
'https://bsky.social/xrpc/com.atproto.server.createSession' => Http::response([
|
|
|
|
|
'error' => 'AuthenticationRequired',
|
|
|
|
|
'message' => 'Invalid identifier or password',
|
|
|
|
|
], 401),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.social.bluesky.store'), [
|
2026-01-18 18:56:51 +00:00
|
|
|
'identifier' => 'testuser.bsky.social',
|
|
|
|
|
'password' => 'wrong-password',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
$response->assertSessionHasErrors('password');
|
|
|
|
|
|
|
|
|
|
$this->assertDatabaseMissing('social_accounts', [
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'platform' => Platform::Bluesky->value,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-22 12:26:31 +00:00
|
|
|
test('user can connect multiple bluesky accounts in self-hosted mode', function () {
|
|
|
|
|
config()->set('trypost.self_hosted', true);
|
|
|
|
|
|
2026-01-18 18:56:51 +00:00
|
|
|
SocialAccount::factory()->bluesky()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'platform_user_id' => 'did:plc:existing123',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Http::fake([
|
|
|
|
|
'https://bsky.social/xrpc/com.atproto.server.createSession' => Http::response([
|
|
|
|
|
'did' => 'did:plc:newuser456',
|
|
|
|
|
'handle' => 'newuser.bsky.social',
|
|
|
|
|
'accessJwt' => 'test-access-token',
|
|
|
|
|
'refreshJwt' => 'test-refresh-token',
|
|
|
|
|
], 200),
|
|
|
|
|
'https://bsky.social/xrpc/app.bsky.actor.getProfile*' => Http::response([
|
|
|
|
|
'did' => 'did:plc:newuser456',
|
|
|
|
|
'handle' => 'newuser.bsky.social',
|
|
|
|
|
'displayName' => 'New User',
|
|
|
|
|
], 200),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.social.bluesky.store'), [
|
2026-01-18 18:56:51 +00:00
|
|
|
'identifier' => 'newuser.bsky.social',
|
|
|
|
|
'password' => 'xxxx-xxxx-xxxx-xxxx',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
2026-06-25 16:54:16 +00:00
|
|
|
$response->assertInertia(fn (AssertableInertia $page) => $page->where('success', true));
|
2026-01-18 18:56:51 +00:00
|
|
|
|
2026-04-14 22:48:35 +00:00
|
|
|
expect($this->workspace->socialAccounts()->where('platform', Platform::Bluesky)->count())->toBe(2);
|
2026-01-18 18:56:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('bluesky connection validates required fields', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.social.bluesky.store'), [
|
2026-01-18 18:56:51 +00:00
|
|
|
'identifier' => '',
|
|
|
|
|
'password' => '',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors(['identifier', 'password']);
|
|
|
|
|
});
|