new test files
This commit is contained in:
@@ -318,6 +318,116 @@ it('lets owners manage releases, contributors, milestones, and publishing throug
|
||||
->and(GroupReleaseMilestone::query()->where('group_release_id', $release->id)->count())->toBe(1);
|
||||
});
|
||||
|
||||
it('lets owners manage challenge outcomes and exposes them on public challenge pages', function () {
|
||||
$owner = User::factory()->create();
|
||||
$group = Group::factory()->for($owner, 'owner')->create([
|
||||
'visibility' => Group::VISIBILITY_PUBLIC,
|
||||
]);
|
||||
|
||||
app(GroupMembershipService::class)->ensureOwnerMembership($group);
|
||||
|
||||
$winner = Artwork::factory()->for($owner, 'user')->create([
|
||||
'group_id' => $group->id,
|
||||
'uploaded_by_user_id' => $owner->id,
|
||||
'primary_author_user_id' => $owner->id,
|
||||
'artwork_status' => 'published',
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
$finalist = Artwork::factory()->for($owner, 'user')->create([
|
||||
'group_id' => $group->id,
|
||||
'uploaded_by_user_id' => $owner->id,
|
||||
'primary_author_user_id' => $owner->id,
|
||||
'artwork_status' => 'published',
|
||||
'visibility' => Artwork::VISIBILITY_PUBLIC,
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$this->actingAs($owner)
|
||||
->post(route('studio.groups.challenges.store', ['group' => $group]), [
|
||||
'title' => 'Pixel Week Results',
|
||||
'summary' => 'Challenge summary',
|
||||
'description' => 'Challenge description',
|
||||
'visibility' => GroupChallenge::VISIBILITY_PUBLIC,
|
||||
'participation_scope' => GroupChallenge::PARTICIPATION_PUBLIC,
|
||||
'status' => GroupChallenge::STATUS_ACTIVE,
|
||||
'start_at' => now()->subDay()->toDateTimeString(),
|
||||
'end_at' => now()->addDay()->toDateTimeString(),
|
||||
'judging_mode' => 'curated',
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$challenge = GroupChallenge::query()->where('group_id', $group->id)->latest('id')->firstOrFail();
|
||||
|
||||
$this->actingAs($owner)
|
||||
->post(route('studio.groups.challenges.attach-artwork', ['group' => $group, 'challenge' => $challenge]), [
|
||||
'artwork_id' => $winner->id,
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$this->actingAs($owner)
|
||||
->post(route('studio.groups.challenges.attach-artwork', ['group' => $group, 'challenge' => $challenge]), [
|
||||
'artwork_id' => $finalist->id,
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$this->actingAs($owner)
|
||||
->patch(route('studio.groups.challenges.update', ['group' => $group, 'challenge' => $challenge]), [
|
||||
'title' => 'Pixel Week Results',
|
||||
'summary' => 'Challenge summary',
|
||||
'description' => 'Challenge description',
|
||||
'visibility' => GroupChallenge::VISIBILITY_PUBLIC,
|
||||
'participation_scope' => GroupChallenge::PARTICIPATION_PUBLIC,
|
||||
'status' => GroupChallenge::STATUS_ACTIVE,
|
||||
'start_at' => now()->subDay()->toDateTimeString(),
|
||||
'end_at' => now()->addDay()->toDateTimeString(),
|
||||
'judging_mode' => 'curated',
|
||||
'outcomes' => [
|
||||
[
|
||||
'artwork_id' => $winner->id,
|
||||
'outcome_type' => 'winner',
|
||||
'position' => 1,
|
||||
'sort_order' => 0,
|
||||
'title_override' => 'Grand Winner',
|
||||
'note' => 'Top overall result.',
|
||||
],
|
||||
[
|
||||
'artwork_id' => $finalist->id,
|
||||
'outcome_type' => 'finalist',
|
||||
'sort_order' => 1,
|
||||
'note' => 'Strong finalist showing.',
|
||||
],
|
||||
],
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$challenge->refresh();
|
||||
|
||||
expect($challenge->featured_artwork_id)->toBe($winner->id);
|
||||
|
||||
$this->assertDatabaseHas('group_challenge_outcomes', [
|
||||
'group_challenge_id' => $challenge->id,
|
||||
'artwork_id' => $winner->id,
|
||||
'outcome_type' => 'winner',
|
||||
]);
|
||||
$this->assertDatabaseHas('group_challenge_outcomes', [
|
||||
'group_challenge_id' => $challenge->id,
|
||||
'artwork_id' => $finalist->id,
|
||||
'outcome_type' => 'finalist',
|
||||
]);
|
||||
|
||||
$this->get(route('groups.challenges.show', ['group' => $group, 'challenge' => $challenge]))
|
||||
->assertOk()
|
||||
->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('Group/GroupChallengeShow')
|
||||
->where('challenge.outcome_sections.winner.items.0.title', $winner->title)
|
||||
->where('challenge.outcome_sections.finalist.items.0.title', $finalist->title));
|
||||
});
|
||||
|
||||
it('renders public release pages and the studio reputation dashboard with v4 payloads', function () {
|
||||
$viewer = User::factory()->create();
|
||||
$owner = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user