Save workspace changes
This commit is contained in:
@@ -99,6 +99,37 @@ it('derives mature artwork presentation from viewer preferences', function () {
|
||||
->and($shown['requires_interstitial'])->toBeTrue();
|
||||
});
|
||||
|
||||
it('treats guests as hide-mode viewers when filtering catalog results', function () {
|
||||
$safeArtwork = Artwork::factory()->create([
|
||||
'title' => 'Guest Visible Safe Artwork',
|
||||
'is_mature' => false,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_SAFE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_CLEAR,
|
||||
]);
|
||||
|
||||
$matureArtwork = Artwork::factory()->create([
|
||||
'title' => 'Guest Hidden Mature Artwork',
|
||||
'is_mature' => true,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_MATURE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_DECLARED,
|
||||
]);
|
||||
|
||||
$maturity = app(ArtworkMaturityService::class);
|
||||
|
||||
$preferences = $maturity->viewerPreferences(null);
|
||||
$visibleIds = $maturity->applyViewerFilter(
|
||||
Artwork::query()->whereKey([$safeArtwork->id, $matureArtwork->id]),
|
||||
null,
|
||||
)->pluck('id')->all();
|
||||
$searchFilter = $maturity->appendSearchFilter('is_public = true', null);
|
||||
|
||||
expect($preferences['is_guest'])->toBeTrue()
|
||||
->and($preferences['visibility'])->toBe(ArtworkMaturityService::VIEW_HIDE)
|
||||
->and($visibleIds)->toContain($safeArtwork->id)
|
||||
->and($visibleIds)->not->toContain($matureArtwork->id)
|
||||
->and($searchFilter)->toContain('is_mature_effective = false');
|
||||
});
|
||||
|
||||
it('applies uploader mature declarations when publishing an existing artwork', function () {
|
||||
Queue::fake();
|
||||
|
||||
@@ -728,6 +759,79 @@ it('hides mature items from the daily uploads page for hide-mode viewers', funct
|
||||
->and($matureArtwork->exists)->toBeTrue();
|
||||
});
|
||||
|
||||
it('hides mature items from the daily uploads page for guests', function () {
|
||||
$safeArtwork = Artwork::factory()->create([
|
||||
'title' => 'Guest Daily Safe Artwork',
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'published_at' => now(),
|
||||
'is_mature' => false,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_SAFE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_CLEAR,
|
||||
]);
|
||||
|
||||
$matureArtwork = Artwork::factory()->create([
|
||||
'title' => 'Guest Daily Mature Artwork',
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'published_at' => now(),
|
||||
'is_mature' => true,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_MATURE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_DECLARED,
|
||||
]);
|
||||
|
||||
$this->get(route('uploads.daily'))
|
||||
->assertOk()
|
||||
->assertSee('Guest Daily Safe Artwork')
|
||||
->assertDontSee('Guest Daily Mature Artwork');
|
||||
|
||||
expect($safeArtwork->exists)->toBeTrue()
|
||||
->and($matureArtwork->exists)->toBeTrue();
|
||||
});
|
||||
|
||||
it('shows mature items on the daily uploads page for blur-mode viewers', function () {
|
||||
$viewer = User::factory()->create();
|
||||
|
||||
DB::table('user_profiles')->insert([
|
||||
'user_id' => $viewer->id,
|
||||
'mature_content_visibility' => 'blur',
|
||||
'mature_content_warning_enabled' => true,
|
||||
]);
|
||||
|
||||
$safeArtwork = Artwork::factory()->create([
|
||||
'title' => 'Blur Daily Safe Artwork',
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'published_at' => now(),
|
||||
'is_mature' => false,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_SAFE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_CLEAR,
|
||||
]);
|
||||
|
||||
$matureArtwork = Artwork::factory()->create([
|
||||
'title' => 'Blur Daily Mature Artwork',
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'published_at' => now(),
|
||||
'is_mature' => true,
|
||||
'maturity_level' => ArtworkMaturityService::LEVEL_MATURE,
|
||||
'maturity_status' => ArtworkMaturityService::STATUS_DECLARED,
|
||||
]);
|
||||
|
||||
$this->actingAs($viewer)
|
||||
->get(route('uploads.daily'))
|
||||
->assertOk()
|
||||
->assertSee('Blur Daily Safe Artwork')
|
||||
->assertSee('Blur Daily Mature Artwork');
|
||||
|
||||
expect($safeArtwork->exists)->toBeTrue()
|
||||
->and($matureArtwork->exists)->toBeTrue();
|
||||
});
|
||||
|
||||
it('filters collection artworks and cover fallbacks for hide-mode viewers', function () {
|
||||
$viewer = User::factory()->create();
|
||||
$owner = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user