Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

1.3 KB
Raw Blame
<?php

declare(strict_types=1);

use App\Enums\Post\Origin;
use App\Models\AnalyticsPublication;
use App\Models\Post;

test('a post defaults to the trypost origin', function () {
    $post = Post::factory()->create();

    expect($post->fresh()->origin)->toBe(Origin::TryPost)
        ->and(Origin::DEFAULT)->toBe(Origin::TryPost);
});

test('the origin scopes separate imported posts from trypost posts', function () {
    $tryPost = Post::factory()->create();
    $imported = Post::factory()->imported()->create();

    expect(Post::query()->createdInTryPost()->pluck('id')->all())->toBe([$tryPost->id])
        ->and(Post::query()->imported()->pluck('id')->all())->toBe([$imported->id])
        ->and($imported->fresh()->user_id)->toBeNull();
});

test('a permalink longer than 255 characters is stored whole', function () {
    $url = 'https://www.facebook.com/permalink.php?story_fbid='.str_repeat('9', 600);
    $post = Post::factory()->facebook()->published()->create(['platform_url' => $url]);

    expect($post->fresh()->platform_url)->toBe($url);
});

test('a publication records when its imported post was dismissed', function () {
    $publication = AnalyticsPublication::factory()->create(['post_dismissed_at' => now()]);

    expect($publication->fresh()->post_dismissed_at)->not->toBeNull();
});