Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions resources/views/livewire/customer/course.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class="h-2 rounded-full bg-emerald-500 transition-all"
</div>
@if ($isDraft)
<flux:badge variant="pill" color="amber" size="sm">Coming Soon</flux:badge>
@endif
@if ($lesson->duration_in_seconds)
@elseif ($lesson->duration_in_seconds)
<flux:text class="text-xs shrink-0">{{ gmdate('i:s', $lesson->duration_in_seconds) }}</flux:text>
@endif
</div>
Expand Down Expand Up @@ -299,8 +298,7 @@ class="cursor-help text-zinc-400 dark:text-zinc-500"
</div>
@if ($isUnreleased)
<flux:badge variant="pill" color="amber" size="sm">Coming Soon</flux:badge>
@endif
@if ($lesson->duration_in_seconds)
@elseif ($lesson->duration_in_seconds)
<flux:text class="shrink-0 text-xs">{{ gmdate('i:s', $lesson->duration_in_seconds) }}</flux:text>
@endif
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class="flex items-center gap-3 px-4 py-2 text-sm transition-colors {{ $isCurrent
<span class="min-w-0 flex-1 truncate {{ $isCurrent ? 'font-medium' : '' }} {{ $isLessonComplete ? 'line-through' : '' }}" title="{{ $outlineLesson->title }}">{{ $outlineLesson->title }}</span>
@if ($isDraft)
<flux:badge variant="pill" color="amber" size="sm">Coming Soon</flux:badge>
@endif
@if ($outlineLesson->duration_in_seconds)
@elseif ($outlineLesson->duration_in_seconds)
<span class="shrink-0 text-xs text-zinc-400 dark:text-zinc-500">{{ gmdate('i:s', $outlineLesson->duration_in_seconds) }}</span>
@endif
</a>
Expand Down
95 changes: 94 additions & 1 deletion tests/Feature/CourseContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,70 @@ public function unreleased_lessons_are_not_shown_as_locked(): void
}

/**
* The markup for a single lesson row in the pre-purchase outline.
* An unreleased lesson may already have a duration set, but it shouldn't be
* shown until the lesson is out — the Coming Soon badge takes its place.
*/
#[Test]
public function owners_do_not_see_the_duration_of_unreleased_lessons(): void
{
$user = User::factory()->create();
$product = Product::where('slug', 'nativephp-masterclass')->first();
ProductLicense::factory()->create([
'user_id' => $user->id,
'product_id' => $product->id,
]);

$course = Course::factory()->published()->create();
$module = CourseModule::factory()->published()->create(['course_id' => $course->id]);
CourseLesson::factory()->published()->create([
'course_module_id' => $module->id,
'title' => 'Released Lesson',
'duration_in_seconds' => 125,
'sort_order' => 1,
]);
CourseLesson::factory()->create([
'course_module_id' => $module->id,
'title' => 'Unreleased Lesson',
'duration_in_seconds' => 278,
'sort_order' => 2,
]);

Livewire::actingAs($user)
->test(Index::class)
->assertSeeInOrder(['Released Lesson', '02:05'])
->assertSeeInOrder(['Unreleased Lesson', 'Coming Soon'])
->assertDontSee('04:38');
}

#[Test]
public function the_curriculum_outline_does_not_show_the_duration_of_unreleased_lessons(): void
{
$user = User::factory()->create();

$course = Course::factory()->published()->create();
$module = CourseModule::factory()->published()->create(['course_id' => $course->id]);
$released = CourseLesson::factory()->published()->create([
'course_module_id' => $module->id,
'duration_in_seconds' => 125,
'sort_order' => 1,
]);
$unreleased = CourseLesson::factory()->create([
'course_module_id' => $module->id,
'duration_in_seconds' => 278,
'sort_order' => 2,
]);

$html = Livewire::actingAs($user)->test(Index::class)->html();

$unreleasedRow = $this->outlineRowFor($html, $unreleased->id);

$this->assertStringContainsString('02:05', $this->outlineRowFor($html, $released->id));
$this->assertStringContainsString('Coming Soon', $unreleasedRow);
$this->assertStringNotContainsString('04:38', $unreleasedRow);
}

/**
* The markup for a single lesson row in a course outline.
*/
private function outlineRowFor(string $html, int $lessonId): string
{
Expand Down Expand Up @@ -1095,6 +1158,36 @@ public function draft_lessons_are_clickable_in_the_outline_for_admins(): void
->assertSee(route('customer.course.lesson', $draftLesson), false);
}

#[Test]
public function the_lesson_sidebar_does_not_show_the_duration_of_draft_lessons_to_admins(): void
{
config(['filament.users' => ['admin@test.com']]);
$admin = User::factory()->create(['email' => 'admin@test.com']);

$course = Course::factory()->published()->create();
$module = CourseModule::factory()->published()->create(['course_id' => $course->id]);
$currentLesson = CourseLesson::factory()->published()->create([
'course_module_id' => $module->id,
'duration_in_seconds' => 125,
'sort_order' => 1,
]);
$draftLesson = CourseLesson::factory()->create([
'course_module_id' => $module->id,
'duration_in_seconds' => 278,
'sort_order' => 2,
]);

$html = Livewire::actingAs($admin)
->test(LessonShow::class, ['lesson' => $currentLesson])
->html();

$draftRow = $this->outlineRowFor($html, $draftLesson->id);

$this->assertStringContainsString('02:05', $this->outlineRowFor($html, $currentLesson->id));
$this->assertStringContainsString('Coming Soon', $draftRow);
$this->assertStringNotContainsString('04:38', $draftRow);
}

#[Test]
public function draft_video_lessons_do_not_hide_the_coming_soon_banner_for_non_admins(): void
{
Expand Down