feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -5,10 +5,14 @@ declare(strict_types=1);
|
||||
use App\Models\Artwork;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
beforeEach(function () {
|
||||
$root = storage_path('framework/testing/artwork-downloads');
|
||||
config(['uploads.storage_root' => $root]);
|
||||
config([
|
||||
'uploads.storage_root' => $root,
|
||||
'uploads.local_originals_root' => $root,
|
||||
]);
|
||||
|
||||
if (File::exists($root)) {
|
||||
File::deleteDirectory($root);
|
||||
@@ -26,10 +30,10 @@ afterEach(function () {
|
||||
|
||||
function makeOriginalFile(string $hash, string $ext, string $content = 'test-image-content'): string
|
||||
{
|
||||
$root = rtrim((string) config('uploads.storage_root'), DIRECTORY_SEPARATOR);
|
||||
$root = rtrim((string) config('uploads.local_originals_root'), DIRECTORY_SEPARATOR);
|
||||
$firstDir = substr($hash, 0, 2);
|
||||
$secondDir = substr($hash, 2, 2);
|
||||
$dir = $root . DIRECTORY_SEPARATOR . 'original' . DIRECTORY_SEPARATOR . $firstDir . DIRECTORY_SEPARATOR . $secondDir;
|
||||
$dir = $root . DIRECTORY_SEPARATOR . $firstDir . DIRECTORY_SEPARATOR . $secondDir;
|
||||
|
||||
File::makeDirectory($dir, 0755, true, true);
|
||||
|
||||
@@ -131,3 +135,34 @@ it('logs guest download with null user_id', function () {
|
||||
'user_id' => null,
|
||||
]);
|
||||
});
|
||||
|
||||
it('increments artwork_stats downloads on the real download route', function () {
|
||||
$hash = 'f1e2d3c4b5';
|
||||
$ext = 'png';
|
||||
makeOriginalFile($hash, $ext);
|
||||
|
||||
$artwork = Artwork::factory()->create([
|
||||
'hash' => $hash,
|
||||
'file_ext' => $ext,
|
||||
]);
|
||||
|
||||
DB::table('artwork_stats')->insertOrIgnore([
|
||||
'artwork_id' => $artwork->id,
|
||||
'views' => 0,
|
||||
'views_24h' => 0,
|
||||
'views_7d' => 0,
|
||||
'downloads' => 0,
|
||||
'downloads_24h' => 0,
|
||||
'downloads_7d' => 0,
|
||||
'favorites' => 0,
|
||||
'rating_avg' => 0,
|
||||
'rating_count' => 0,
|
||||
]);
|
||||
|
||||
$this->get("/download/artwork/{$artwork->id}")->assertOk();
|
||||
$this->get("/download/artwork/{$artwork->id}")->assertOk();
|
||||
|
||||
expect(DB::table('artwork_stats')->where('artwork_id', $artwork->id)->value('downloads'))->toBe(2);
|
||||
expect(DB::table('artwork_stats')->where('artwork_id', $artwork->id)->value('downloads_24h'))->toBe(2);
|
||||
expect(DB::table('artwork_stats')->where('artwork_id', $artwork->id)->value('downloads_7d'))->toBe(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user