Add Video Projects schema and workflow engine core (tasks #31, #32)

Foundational layer for the YouTube Content Creation System project,
built as a fully independent domain per the earlier decision (task
#47) — no foreign keys into the existing projects/tasks/ideas tables.

Schema: video_projects, workflow_steps, assets, ai_providers,
workflow_templates (named to avoid colliding with the existing
Post-templates `templates` table).

WorkflowEngine (app/Support/VideoWorkflow/) drives a project's step
sequence: start/startFromTemplate, currentStep, completeStep (with
optional approval gating), approveStep/rejectStep, failStep/retryStep,
skipStep. It only manages state transitions — actual step execution
(AI calls, rendering, etc.) is out of scope here (tasks #33+).

Also fixes four Publisher classes (WordPress/Reddit/Twitter/LinkedIn)
that were missing a `use App\Models\SocialAccount;` import after an
earlier interface change, which broke the entire test suite at
bootstrap; and PostFactory, which still set the now-removed
`social_account_id` column instead of the SocialAccount pivot.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
m105
2026-08-06 20:38:52 +03:00
co-authored by Claude Sonnet 5
parent efdec9eabd
commit 6ff7f78c9c
25 changed files with 1049 additions and 25 deletions
@@ -13,7 +13,8 @@ test('it supports reddit posts only', function () {
});
test('it rejects a post with no title', function () {
$post = Post::factory()->for(SocialAccount::factory()->state(['network' => 'reddit']), 'socialAccount')
$post = Post::factory()
->hasAttached(SocialAccount::factory()->state(['network' => 'reddit']), [], 'socialAccounts')
->create(['type' => 'reddit', 'title' => null, 'target' => 'test']);
$result = (new RedditPublisher)->publish($post);
@@ -24,7 +25,8 @@ test('it rejects a post with no title', function () {
});
test('it rejects a post with no target subreddit', function () {
$post = Post::factory()->for(SocialAccount::factory()->state(['network' => 'reddit']), 'socialAccount')
$post = Post::factory()
->hasAttached(SocialAccount::factory()->state(['network' => 'reddit']), [], 'socialAccounts')
->create(['type' => 'reddit', 'title' => 'Hi', 'target' => null]);
$result = (new RedditPublisher)->publish($post);
@@ -35,7 +37,7 @@ test('it rejects a post with no target subreddit', function () {
});
test('it rejects a post with no linked reddit account', function () {
$post = Post::factory()->create(['type' => 'reddit', 'title' => 'Hi', 'target' => 'test', 'social_account_id' => null]);
$post = Post::factory()->create(['type' => 'reddit', 'title' => 'Hi', 'target' => 'test']);
$result = (new RedditPublisher)->publish($post);
@@ -50,14 +52,10 @@ test('it publishes successfully via the sidecar', function () {
]);
$account = SocialAccount::factory()->create(['network' => 'reddit', 'username' => 'redditor']);
$post = Post::factory()->create([
'type' => 'reddit',
'title' => 'Hi',
'target' => 'test',
'social_account_id' => $account->id,
]);
$post = Post::factory()->create(['type' => 'reddit', 'title' => 'Hi', 'target' => 'test']);
$post->socialAccounts()->attach($account);
$result = (new RedditPublisher)->publish($post);
$result = (new RedditPublisher)->publish($post->fresh());
expect($result->success)->toBeTrue();
expect($result->url)->toBe('https://reddit.com/r/test/comments/abc123');
@@ -75,14 +73,10 @@ test('it treats a sidecar-reported failure as an attempted, failed publish', fun
]);
$account = SocialAccount::factory()->create(['network' => 'reddit']);
$post = Post::factory()->create([
'type' => 'reddit',
'title' => 'Hi',
'target' => 'test',
'social_account_id' => $account->id,
]);
$post = Post::factory()->create(['type' => 'reddit', 'title' => 'Hi', 'target' => 'test']);
$post->socialAccounts()->attach($account);
$result = (new RedditPublisher)->publish($post);
$result = (new RedditPublisher)->publish($post->fresh());
expect($result->success)->toBeFalse();
expect($result->attempted)->toBeTrue();
@@ -95,14 +89,10 @@ test('it fails gracefully when the sidecar output is unparseable', function () {
]);
$account = SocialAccount::factory()->create(['network' => 'reddit']);
$post = Post::factory()->create([
'type' => 'reddit',
'title' => 'Hi',
'target' => 'test',
'social_account_id' => $account->id,
]);
$post = Post::factory()->create(['type' => 'reddit', 'title' => 'Hi', 'target' => 'test']);
$post->socialAccounts()->attach($account);
$result = (new RedditPublisher)->publish($post);
$result = (new RedditPublisher)->publish($post->fresh());
expect($result->success)->toBeFalse();
expect($result->attempted)->toBeTrue();