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-01-18 23:33:45 +00:00
|
|
|
use App\Enums\Post\Status as PostStatus;
|
|
|
|
|
use App\Enums\PostPlatform\ContentType;
|
|
|
|
|
use App\Enums\SocialAccount\Platform;
|
|
|
|
|
use App\Enums\User\Setup;
|
2026-03-31 03:40:18 +00:00
|
|
|
use App\Enums\UserWorkspace\Role;
|
2026-01-18 23:33:45 +00:00
|
|
|
use App\Models\Post;
|
|
|
|
|
use App\Models\PostPlatform;
|
|
|
|
|
use App\Models\SocialAccount;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Workspace;
|
2026-01-26 18:18:35 +00:00
|
|
|
use App\Models\WorkspaceLabel;
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
use Illuminate\Support\Facades\Mail;
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
$this->user = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
$this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
2026-03-31 03:40:18 +00:00
|
|
|
$this->workspace->members()->attach($this->user->id, ['role' => Role::Owner->value]);
|
2026-01-18 23:33:45 +00:00
|
|
|
$this->user->update(['current_workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$this->socialAccount = SocialAccount::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'platform' => Platform::LinkedIn,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Index tests
|
|
|
|
|
test('posts index requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.posts.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('posts index shows posts for current workspace', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.posts.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('posts/Index', false)
|
|
|
|
|
->has('posts.data', 1)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('posts index redirects to create workspace 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.posts.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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Calendar tests
|
|
|
|
|
test('calendar requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.calendar'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('calendar shows posts for current week', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.calendar'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('posts/Calendar')
|
|
|
|
|
->has('workspace')
|
|
|
|
|
->has('posts')
|
|
|
|
|
->has('currentWeekStart')
|
|
|
|
|
->has('view')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('calendar supports month view', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.calendar', ['view' => 'month']));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->where('view', 'month')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-22 01:08:18 +00:00
|
|
|
// Store tests
|
|
|
|
|
test('store post requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->post(route('app.posts.store'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-22 01:08:18 +00:00
|
|
|
test('store post redirects to accounts if no social accounts connected', function () {
|
2026-01-18 23:33:45 +00:00
|
|
|
$this->socialAccount->delete();
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.posts.store'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.accounts'));
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
2026-01-22 01:08:18 +00:00
|
|
|
test('store post creates draft and redirects to edit', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.posts.store'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$post = Post::where('workspace_id', $this->workspace->id)->first();
|
|
|
|
|
expect($post)->not->toBeNull();
|
|
|
|
|
expect($post->status)->toBe(PostStatus::Draft);
|
|
|
|
|
expect($post->postPlatforms)->toHaveCount(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Edit tests
|
|
|
|
|
test('edit post requires authentication', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.posts.edit', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('edit post shows edit page', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.posts.edit', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('posts/Edit')
|
|
|
|
|
->has('post')
|
|
|
|
|
->has('socialAccounts')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('edit post returns 404 for post from different workspace', function () {
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $otherWorkspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.posts.edit', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-20 22:42:50 +00:00
|
|
|
test('edit post shows published posts in read-only mode', function () {
|
2026-01-18 23:33:45 +00:00
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Published,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.posts.edit', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
2026-01-20 22:42:50 +00:00
|
|
|
->component('posts/Edit')
|
2026-01-18 23:33:45 +00:00
|
|
|
->has('post')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Update tests
|
|
|
|
|
test('update post requires authentication', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->put(route('app.posts.update', $post), []);
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post saves changes', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
'content' => 'Original content',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-18 23:33:45 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Updated content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$postPlatform->refresh();
|
|
|
|
|
expect($postPlatform->content)->toBe('Updated content');
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
expect($postPlatform->content_type)->toBe(ContentType::LinkedInPost);
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post cannot update published posts', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Published,
|
|
|
|
|
]);
|
|
|
|
|
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
|
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
2026-01-18 23:33:45 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-26 19:01:14 +00:00
|
|
|
test('publish now updates scheduled_at to current time', function () {
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
Mail::fake();
|
2026-01-26 19:01:14 +00:00
|
|
|
$this->freezeTime();
|
|
|
|
|
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
'scheduled_at' => now()->addDays(7),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-26 19:01:14 +00:00
|
|
|
'status' => 'publishing',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-26 19:01:14 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$post->refresh();
|
|
|
|
|
expect($post->scheduled_at->toDateTimeString())->toBe(now()->toDateTimeString());
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-18 23:33:45 +00:00
|
|
|
// Destroy tests
|
|
|
|
|
test('destroy post requires authentication', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->delete(route('app.posts.destroy', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-01 18:04:13 +00:00
|
|
|
test('destroy post deletes the post and redirects to posts index', function () {
|
2026-01-18 23:33:45 +00:00
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-01-22 01:08:18 +00:00
|
|
|
$response = $this->actingAs($this->user)
|
2026-03-29 22:24:28 +00:00
|
|
|
->delete(route('app.posts.destroy', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-04-01 18:04:13 +00:00
|
|
|
$response->assertRedirect(route('app.posts.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
expect(Post::find($post->id))->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-01 18:04:13 +00:00
|
|
|
test('destroy post with redirect param redirects to calendar', function () {
|
2026-01-26 17:00:37 +00:00
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)
|
2026-04-01 18:04:13 +00:00
|
|
|
->delete(route('app.posts.destroy', $post).'?redirect=app.calendar');
|
2026-01-26 17:00:37 +00:00
|
|
|
|
2026-04-01 18:04:13 +00:00
|
|
|
$response->assertRedirect(route('app.calendar'));
|
2026-01-26 17:00:37 +00:00
|
|
|
expect(Post::find($post->id))->toBeNull();
|
2026-04-01 18:04:13 +00:00
|
|
|
});
|
2026-01-26 17:00:37 +00:00
|
|
|
|
|
|
|
|
test('destroy post with redirect param redirects to specified route', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($this->user)
|
2026-03-29 22:24:28 +00:00
|
|
|
->delete(route('app.posts.destroy', $post).'?redirect=app.posts.index');
|
2026-01-26 17:00:37 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.posts.index'));
|
2026-01-26 17:00:37 +00:00
|
|
|
expect(Post::find($post->id))->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-18 23:33:45 +00:00
|
|
|
test('destroy post returns 404 for post from different workspace', function () {
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $otherWorkspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->delete(route('app.posts.destroy', $post));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
2026-01-26 18:18:35 +00:00
|
|
|
|
|
|
|
|
// Label tests
|
|
|
|
|
test('edit post includes workspace labels', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$label = WorkspaceLabel::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'name' => 'Marketing',
|
|
|
|
|
'color' => '#FF0000',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.posts.edit', $post));
|
2026-01-26 18:18:35 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('posts/Edit')
|
|
|
|
|
->has('labels', 1)
|
|
|
|
|
->where('labels.0.name', 'Marketing')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post can attach labels', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$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.posts.update', $post), [
|
2026-01-26 18:18:35 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-26 18:18:35 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'label_ids' => [$label->id],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$post->refresh();
|
|
|
|
|
expect($post->labels)->toHaveCount(1);
|
|
|
|
|
expect($post->labels->first()->id)->toBe($label->id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post can detach labels', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$label = WorkspaceLabel::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$post->labels()->attach($label);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-26 18:18:35 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-26 18:18:35 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'label_ids' => [],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$post->refresh();
|
|
|
|
|
expect($post->labels)->toHaveCount(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post can sync multiple labels', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$label1 = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
$label2 = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
$label3 = WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
// Attach initial label
|
|
|
|
|
$post->labels()->attach($label1);
|
|
|
|
|
|
|
|
|
|
// Update with different labels
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-26 18:18:35 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-26 18:18:35 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'label_ids' => [$label2->id, $label3->id],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$post->refresh();
|
|
|
|
|
expect($post->labels)->toHaveCount(2);
|
|
|
|
|
expect($post->labels->pluck('id')->toArray())->toEqualCanonicalizing([$label2->id, $label3->id]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update post validates label_ids exist', function () {
|
|
|
|
|
$post = Post::factory()->create([
|
|
|
|
|
'workspace_id' => $this->workspace->id,
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
'status' => PostStatus::Draft,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$postPlatform = PostPlatform::factory()->create([
|
|
|
|
|
'post_id' => $post->id,
|
|
|
|
|
'social_account_id' => $this->socialAccount->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.posts.update', $post), [
|
2026-01-26 18:18:35 +00:00
|
|
|
'status' => 'draft',
|
fix: overhaul social publishing — validation, uploads, token refresh
- Fix UpdatePostRequest missing content_type, synced, meta fields
(content_type was silently dropped, causing Instagram Reels to post as Feed)
- Create API FormRequests (StorePostRequest, UpdatePostRequest) replacing inline validation
- Fix syntax errors in all publishers ($media->isVideo() missing variable)
- Fix Instagram Feed with single video calling publishSingleImage instead of publishReel
- Fix TikTok hardcoded SELF_ONLY privacy — now queries creator_info API
- Refactor YouTubePublisher to use google/apiclient SDK with chunked resumable upload
- Fix all publishers using file_get_contents for large videos (memory overflow)
— X, LinkedIn, LinkedInPage, Pinterest, Bluesky, Mastodon now use temp file + stream
- Fix Media::isVideo/isImage to use mime_type instead of extension
- Fix Threads not saving refresh_token (was null, now saves access_token)
- Add Instagram token refresh to publisher and ConnectionVerifier
- Fix PublishToSocialPlatform job: tries 3→1 (prevents duplicate uploads),
timeout 60→600s, added failed() method for cleanup
- Increase Horizon worker timeout 60→630s, Redis retry_after 90→660s
- Increase upload limit 500MB→1GB
- Add mastodon to getDefaultContentType in Edit.vue
2026-03-31 22:25:19 +00:00
|
|
|
'synced' => true,
|
2026-01-26 18:18:35 +00:00
|
|
|
'platforms' => [
|
|
|
|
|
[
|
|
|
|
|
'id' => $postPlatform->id,
|
|
|
|
|
'content' => 'Test content',
|
|
|
|
|
'content_type' => ContentType::LinkedInPost->value,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'label_ids' => ['non-existent-uuid'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('label_ids.0');
|
|
|
|
|
});
|
2026-03-31 03:40:18 +00:00
|
|
|
|
|
|
|
|
// Member authorization tests
|
|
|
|
|
test('member can view posts index', function () {
|
|
|
|
|
$member = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
$this->workspace->members()->attach($member->id, ['role' => Role::Member->value]);
|
|
|
|
|
$member->update(['current_workspace_id' => $this->workspace->id]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($member)->get(route('app.posts.index'));
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('member can create post', function () {
|
|
|
|
|
$member = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
$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.posts.store'));
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
});
|