diff --git a/resources/boost/skills/saucebase-roadmap-development/SKILL.md b/resources/boost/skills/saucebase-roadmap-development/SKILL.md index dec165b..8c22acc 100644 --- a/resources/boost/skills/saucebase-roadmap-development/SKILL.md +++ b/resources/boost/skills/saucebase-roadmap-development/SKILL.md @@ -9,7 +9,7 @@ Paths are relative to `modules/roadmap/` unless they say otherwise. Commands run ## Overview -Public roadmap board with feature requests, upvotes, comments, team replies, and duplicate merging. Filament admin at `/admin` → Roadmap. +Public roadmap board with feature requests, upvotes, comments, team replies, and duplicate merging. Filament admin at `/admin` → Roadmap. `Modules\Roadmap\Filament\Widgets\RoadmapAttentionWidget` puts "Suggestions to review" (status Under Review) on the dashboard, sort 21, only while there are any. --- diff --git a/src/Filament/Widgets/RoadmapAttentionWidget.php b/src/Filament/Widgets/RoadmapAttentionWidget.php new file mode 100644 index 0000000..ab13797 --- /dev/null +++ b/src/Filament/Widgets/RoadmapAttentionWidget.php @@ -0,0 +1,45 @@ +user()?->can('manage roadmap') ?? false) && self::underReview() > 0; + } + + protected function getStats(): array + { + return [ + Stat::make(__('Suggestions to review'), self::underReview()) + ->description(__('Waiting for a status')) + ->descriptionIcon('heroicon-m-light-bulb') + ->color('warning') + ->url(RoadmapItemResource::getUrl('index')), + ]; + } + + private static function underReview(): int + { + return RoadmapItem::where('status', RoadmapStatus::UnderReview)->count(); + } +} diff --git a/tests/Feature/RoadmapAttentionWidgetTest.php b/tests/Feature/RoadmapAttentionWidgetTest.php new file mode 100644 index 0000000..eb5af99 --- /dev/null +++ b/tests/Feature/RoadmapAttentionWidgetTest.php @@ -0,0 +1,45 @@ +actingAs(User::factory()->create()->givePermissionTo('manage roadmap')); + } + + /** Attention band (20–29): roadmap is 21, after billing. */ + public function test_shown_only_with_suggestions_to_review(): void + { + $this->assertSame(21, RoadmapAttentionWidget::getSort()); + RoadmapItem::factory()->create(['status' => RoadmapStatus::Planned]); + $this->assertFalse(RoadmapAttentionWidget::canView()); + + RoadmapItem::factory()->count(2)->create(['status' => RoadmapStatus::UnderReview]); + $this->assertTrue(RoadmapAttentionWidget::canView()); + Livewire::test(RoadmapAttentionWidget::class)->assertSee(['Suggestions to review', '2']); + } + + public function test_needs_the_roadmap_permission(): void + { + RoadmapItem::factory()->create(['status' => RoadmapStatus::UnderReview]); + $this->actingAs(User::factory()->create()); + + $this->assertFalse(RoadmapAttentionWidget::canView()); + } +} diff --git a/tests/e2e/tests/roadmap.spec.ts b/tests/e2e/tests/roadmap.spec.ts index a7267e4..6da3b4b 100644 --- a/tests/e2e/tests/roadmap.spec.ts +++ b/tests/e2e/tests/roadmap.spec.ts @@ -178,18 +178,19 @@ test.describe('Roadmap', () => { await expect(panel.getByTestId(`vote-count-${item.id}`)).toHaveText( '1', ); - await expect(page.locator('[data-sonner-toast]')).toContainText( - 'Upvoted!', - ); + // Toasts stack (sign-in, then each vote): look a toast up by its text. + await expect( + page.locator('[data-sonner-toast]', { hasText: 'Upvoted!' }), + ).toBeVisible(); await expect(panel).toBeVisible(); await expect(page).toHaveURL(new RegExp(`/roadmap/${item.slug}$`)); const card = page.getByTestId(`roadmap-item-${item.id}`); await expect(card.getByTestId(`vote-count-${item.id}`)).toHaveText('1'); await panel.getByTestId(`vote-btn-${item.id}`).click(); - await expect(page.locator('[data-sonner-toast]').last()).toContainText( - 'Vote removed', - ); + await expect( + page.locator('[data-sonner-toast]', { hasText: 'Vote removed' }), + ).toBeVisible(); await expect(panel).toBeVisible(); await expect(page).toHaveURL(new RegExp(`/roadmap/${item.slug}$`)); await expect(panel.getByTestId(`vote-count-${item.id}`)).toHaveText(