From 6f8d4708adc8c0450bd533b781767f57ec5aa092 Mon Sep 17 00:00:00 2001 From: roble Date: Sun, 15 Nov 2026 19:48:30 +0000 Subject: [PATCH 1/7] test: the author sees a visible, labelled status on their suggestion Co-Authored-By: Claude Opus 5.5 --- tests/e2e/tests/roadmap.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/e2e/tests/roadmap.spec.ts b/tests/e2e/tests/roadmap.spec.ts index fa5b1bb..bdeba5e 100644 --- a/tests/e2e/tests/roadmap.spec.ts +++ b/tests/e2e/tests/roadmap.spec.ts @@ -308,9 +308,10 @@ test.describe('Roadmap', () => { await page.getByTestId('filter-mine').click(); const mine = page.getByTestId('roadmap-mine'); await expect(mine).toContainText('Export to CSV'); - await expect( - mine.locator('[data-testid^="item-status-"]'), - ).toHaveAttribute('data-state', 'under_review'); + const status = mine.locator('[data-testid^="item-status-"]'); + await expect(status).toBeVisible(); + await expect(status).toHaveAttribute('data-state', 'under_review'); + await expect(status).toHaveText(/\S/); await page.getByTestId('filter-mine-back').click(); await expect(page.getByTestId('roadmap-board')).toBeVisible(); From 65974b8753f97d0ffbdeafa6227bee69fcf3820d Mon Sep 17 00:00:00 2001 From: roble Date: Mon, 16 Nov 2026 11:37:50 +0000 Subject: [PATCH 2/7] chore: alias dev as 3.x-dev, so it never falls behind a minor release Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0c952d5..f2ae326 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ ] }, "branch-alias": { - "dev-dev": "3.6.x-dev" + "dev-dev": "3.x-dev" } }, "autoload": { From 23a919ace1110a5c86651e8da5e1cf5710d9d05c Mon Sep 17 00:00:00 2001 From: roble Date: Mon, 16 Nov 2026 12:29:53 +0000 Subject: [PATCH 3/7] feat: the demo seeder declares its accounts (#[DemoAccount]) The installer and modules:seed name the featured ones; a test checks the seeder creates every account it declares. Co-Authored-By: Claude Opus 5.5 --- database/seeders/ShowcaseRoadmapDatabaseSeeder.php | 2 ++ tests/Feature/ShowcaseStaffTest.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/database/seeders/ShowcaseRoadmapDatabaseSeeder.php b/database/seeders/ShowcaseRoadmapDatabaseSeeder.php index 6dea187..4364a72 100644 --- a/database/seeders/ShowcaseRoadmapDatabaseSeeder.php +++ b/database/seeders/ShowcaseRoadmapDatabaseSeeder.php @@ -7,8 +7,10 @@ use Modules\Roadmap\Enums\RoadmapStatus; use Modules\Roadmap\Enums\RoadmapType; use Modules\Roadmap\Models\RoadmapItem; +use Saucebase\Core\Attributes\DemoAccount; use Spatie\Permission\Models\Role; +#[DemoAccount('roadmap@saucebase.dev', 'staff: the roadmap admin')] class ShowcaseRoadmapDatabaseSeeder extends Seeder { public function run(): void diff --git a/tests/Feature/ShowcaseStaffTest.php b/tests/Feature/ShowcaseStaffTest.php index e61c105..0a51541 100644 --- a/tests/Feature/ShowcaseStaffTest.php +++ b/tests/Feature/ShowcaseStaffTest.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Hash; use Modules\Roadmap\Database\Seeders\DatabaseSeeder; use Modules\Roadmap\Database\Seeders\ShowcaseRoadmapDatabaseSeeder; +use Saucebase\Core\Testing\AssertsDemoAccounts; use Tests\TestCase; /** @@ -15,6 +16,7 @@ */ class ShowcaseStaffTest extends TestCase { + use AssertsDemoAccounts; use RefreshDatabase; public function test_the_demo_adds_a_staff_account_for_this_module_only(): void @@ -35,4 +37,10 @@ public function test_demo_accounts_use_the_configured_demo_password(): void $this->assertTrue(Hash::check('not-the-old-default', User::where('email', 'roadmap@saucebase.dev')->value('password'))); } + + /** The accounts the seeder declares (#[DemoAccount]) are the ones it creates. */ + public function test_every_declared_demo_account_is_created(): void + { + $this->assertDemoAccountsSeeded(ShowcaseRoadmapDatabaseSeeder::class); + } } From a9db43e70bda6339278ed2fbf3a1ec471bc44c3b Mon Sep 17 00:00:00 2001 From: roble Date: Wed, 18 Nov 2026 11:52:53 +0000 Subject: [PATCH 4/7] fix: the item page clears a site header of any height The full-page item container used py-16, which left the Back to roadmap link under a template's taller fixed header. py-28 matches the blog's article page, the other site page without a hero. Co-Authored-By: Claude Opus 5.5 --- resources/js/react/pages/Show.tsx | 2 +- resources/js/vue/pages/Show.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/react/pages/Show.tsx b/resources/js/react/pages/Show.tsx index d05c6df..6cec1b7 100644 --- a/resources/js/react/pages/Show.tsx +++ b/resources/js/react/pages/Show.tsx @@ -43,7 +43,7 @@ export default function Show({ canonical={item.url} type="article" > -
+
-
+
Date: Fri, 20 Nov 2026 09:06:26 +0000 Subject: [PATCH 5/7] fix: a merged item redirects to its target and tells its followers - The duplicate's address 301-redirects to the item it was merged into. - Its voters and author get one queued "merged" mail after commit; a merge no longer sends the "Closed" status mail. - Merges go only into public items (the mail names the target); the admin picker lists those only. The mail's action label is fixed text. Co-Authored-By: Claude Opus 5.5 --- .../saucebase-roadmap-development/SKILL.md | 4 ++ src/Actions/MergeItem.php | 15 +++- .../Roadmap/Tables/RoadmapItemsTable.php | 2 + src/Http/Controllers/RoadmapController.php | 8 ++- src/Models/RoadmapItem.php | 3 +- .../RoadmapItemMergedNotification.php | 54 ++++++++++++++ tests/Feature/RoadmapMergeTest.php | 71 +++++++++++++++++++ 7 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 src/Notifications/RoadmapItemMergedNotification.php diff --git a/resources/boost/skills/saucebase-roadmap-development/SKILL.md b/resources/boost/skills/saucebase-roadmap-development/SKILL.md index 8aa5e25..6e5b7d6 100644 --- a/resources/boost/skills/saucebase-roadmap-development/SKILL.md +++ b/resources/boost/skills/saucebase-roadmap-development/SKILL.md @@ -65,6 +65,10 @@ Moderation hides rather than deletes: `hidden_at` plus a private `hidden_reason` `Actions\MergeItem` moves votes and comments to the target, drops votes from anyone who had voted on both (the unique index would reject them), then sets `merged_into_id` and closes the source. `comments()->reorder()` matters: the relation is ordered, and an ordered `UPDATE` is not portable. +- **The source's address redirects** (301, as a merge cannot be undone) to the target: `RoadmapController::show()`, before the visibility check, so shared links and "My feedback" still reach the conversation. The target's own rules apply there. +- **Only into a public item:** voters follow their votes and the mail names the target. `MergeItem` throws otherwise, and the admin picker lists public items only. +- **Its subscribers hear where it went:** `RoadmapItemMergedNotification` to the source's voters and author, read before the votes move, sent after commit. A merge sends no `StatusChanged` mail: closing the source is not a rejection (the `updated` hook skips a status change that comes with `merged_into_id`). + ### Notifications Go To Everyone Waiting `StatusChanged` dispatches after commit, so a rolled-back merge mails nobody, and the mail itself is queued. A status change notifies `subscribers()`: the submitter plus everyone who voted. Voting is how you subscribe. diff --git a/src/Actions/MergeItem.php b/src/Actions/MergeItem.php index ed65946..c4904cd 100644 --- a/src/Actions/MergeItem.php +++ b/src/Actions/MergeItem.php @@ -3,14 +3,17 @@ namespace Modules\Roadmap\Actions; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Notification; use InvalidArgumentException; use Modules\Roadmap\Enums\RoadmapStatus; use Modules\Roadmap\Models\RoadmapItem; +use Modules\Roadmap\Notifications\RoadmapItemMergedNotification; /** * Fold a duplicate into another item: its votes and comments move across, and it is * closed. A vote from someone who voted on both is dropped, as the unique index would - * reject it. + * reject it. Its voters and author are told where it went, once the merge commits; its + * address redirects there (RoadmapController::show()). */ class MergeItem { @@ -20,6 +23,14 @@ public function handle(RoadmapItem $duplicate, RoadmapItem $target): void throw new InvalidArgumentException('An item cannot be merged into itself.'); } + // Voters follow their votes and the mail names the target, so it must be one they can see. + if (! $target->isPublic()) { + throw new InvalidArgumentException('An item can only be merged into a public one.'); + } + + // Read before the votes move: afterwards the duplicate has no voters. + $subscribers = $duplicate->subscribers(); + DB::transaction(function () use ($duplicate, $target): void { $duplicate->votes()->whereIn('user_id', $target->votes()->pluck('user_id'))->delete(); $duplicate->votes()->update(['roadmap_item_id' => $target->getKey()]); @@ -31,5 +42,7 @@ public function handle(RoadmapItem $duplicate, RoadmapItem $target): void 'status' => RoadmapStatus::Closed, ]); }); + + Notification::send($subscribers, (new RoadmapItemMergedNotification($duplicate, $target))->afterCommit()); } } diff --git a/src/Filament/Resources/Roadmap/Tables/RoadmapItemsTable.php b/src/Filament/Resources/Roadmap/Tables/RoadmapItemsTable.php index eefda72..5e99508 100644 --- a/src/Filament/Resources/Roadmap/Tables/RoadmapItemsTable.php +++ b/src/Filament/Resources/Roadmap/Tables/RoadmapItemsTable.php @@ -90,6 +90,8 @@ private static function mergeAction(): Action ->getSearchResultsUsing(fn (RoadmapItem $record, string $search) => RoadmapItem::query() ->whereKeyNot($record->getKey()) ->whereNull('merged_into_id') + // Only what visitors can see: MergeItem refuses anything else. + ->whereIn('status', RoadmapStatus::publicStatuses()) ->where('title', 'like', "%{$search}%") ->orderBy('title') ->limit(50) diff --git a/src/Http/Controllers/RoadmapController.php b/src/Http/Controllers/RoadmapController.php index fbfb9fc..787f62e 100644 --- a/src/Http/Controllers/RoadmapController.php +++ b/src/Http/Controllers/RoadmapController.php @@ -67,8 +67,14 @@ public function index(Request $request, RoadmapSettings $settings): Response * package would otherwise treat any ordinary link as "open me over the * previous page", and a shared link has to stay a real page. */ - public function show(RoadmapItem $item, RoadmapSettings $settings): Response|Modal + public function show(RoadmapItem $item, RoadmapSettings $settings): Response|Modal|RedirectResponse { + // Merged away: its votes and comments live on the target now, whose own rules apply. + // Permanent, as a merge cannot be undone. + if ($item->mergedInto !== null) { + return redirect($item->mergedInto->url(), 301); + } + // 404 and not 403: a refusal would confirm that a hidden item exists. abort_unless(Gate::allows('view', $item), 404); diff --git a/src/Models/RoadmapItem.php b/src/Models/RoadmapItem.php index 6d00f93..8bf137e 100644 --- a/src/Models/RoadmapItem.php +++ b/src/Models/RoadmapItem.php @@ -54,7 +54,8 @@ protected static function booted(): void }); static::updated(function (RoadmapItem $item): void { - if ($item->wasChanged('status')) { + // A merge closes the duplicate, but it isn't a rejection: MergeItem sends its own mail. + if ($item->wasChanged('status') && ! $item->wasChanged('merged_into_id')) { StatusChanged::dispatch($item); } }); diff --git a/src/Notifications/RoadmapItemMergedNotification.php b/src/Notifications/RoadmapItemMergedNotification.php new file mode 100644 index 0000000..66ded70 --- /dev/null +++ b/src/Notifications/RoadmapItemMergedNotification.php @@ -0,0 +1,54 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage) + ->subject(__('A roadmap item you follow was merged')) + ->greeting(__('Hello :name,', ['name' => $notifiable->name])) + ->line(__('**":duplicate"** was merged into **":target"**, which asks for the same thing. Your vote and the comments now count there.', [ + 'duplicate' => Markdown::escape($this->duplicate->title), + 'target' => Markdown::escape($this->target->title), + ])) + // A fixed label: Laravel repeats it, unescaped, in the mail's fallback line. + ->action(__('View the item'), $this->target->url()) + ->line(__('Thank you for your feedback!')); + } + + /** + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + 'roadmap_item_id' => $this->duplicate->id, + 'merged_into_id' => $this->target->id, + ]; + } +} diff --git a/tests/Feature/RoadmapMergeTest.php b/tests/Feature/RoadmapMergeTest.php index dca0a55..e6c99ec 100644 --- a/tests/Feature/RoadmapMergeTest.php +++ b/tests/Feature/RoadmapMergeTest.php @@ -7,6 +7,9 @@ use Modules\Roadmap\Actions\MergeItem; use Modules\Roadmap\Enums\RoadmapStatus; use Modules\Roadmap\Models\RoadmapItem; +use Modules\Roadmap\Notifications\RoadmapItemMergedNotification; +use Modules\Roadmap\Notifications\RoadmapItemStatusChangedNotification; +use Illuminate\Support\Facades\Notification; use Tests\TestCase; class RoadmapMergeTest extends TestCase @@ -61,4 +64,72 @@ public function test_a_user_who_voted_on_both_items_only_counts_once(): void $this->assertSame(1, $target->votes()->count()); } + + /** Voters follow their votes there, so the target must be one they can see. */ + public function test_an_item_is_only_merged_into_a_public_one(): void + { + $duplicate = RoadmapItem::factory()->planned()->create(); + $hidden = RoadmapItem::factory()->create(['status' => RoadmapStatus::UnderReview]); + + $this->expectException(\InvalidArgumentException::class); + + try { + app(MergeItem::class)->handle($duplicate, $hidden); + } finally { + $this->assertNull($duplicate->fresh()->merged_into_id); + } + } + + /** A link to the duplicate, shared or bookmarked, still reaches the conversation. */ + public function test_the_duplicates_address_leads_to_the_item_it_was_merged_into(): void + { + $duplicate = RoadmapItem::factory()->planned()->create(); + $target = RoadmapItem::factory()->planned()->create(); + + app(MergeItem::class)->handle($duplicate, $target); + + $this->get($duplicate->url())->assertStatus(301)->assertRedirect($target->url()); + } + + /** Their vote moved: voters and the author hear where, once, and nothing about "Closed". */ + public function test_voters_and_the_author_are_told_where_it_went(): void + { + Notification::fake(); + $author = User::factory()->create(); + $voter = User::factory()->create(); + $duplicate = RoadmapItem::factory()->planned()->create(['user_id' => $author->id]); + $target = RoadmapItem::factory()->planned()->create(); + $duplicate->votes()->create(['user_id' => $voter->id]); + + app(MergeItem::class)->handle($duplicate, $target); + + foreach ([$author, $voter] as $user) { + Notification::assertSentTo($user, RoadmapItemMergedNotification::class, fn ($n) => $n->target->is($target)); + } + Notification::assertNotSentTo([$author, $voter], RoadmapItemStatusChangedNotification::class); + } + + public function test_titles_cannot_smuggle_a_link_into_the_merged_email(): void + { + $user = User::factory()->create(); + $duplicate = RoadmapItem::factory()->planned()->create(['title' => 'Evil [one](https://evil.test)']); + $target = RoadmapItem::factory()->planned()->create(['title' => 'Evil [two](https://evil.test)']); + + $mail = (new RoadmapItemMergedNotification($duplicate, $target))->toMail($user); + + $this->assertStringNotContainsString('href="https://evil.test"', (string) $mail->render()); + } + + public function test_the_merged_email_names_both_items_and_links_to_the_target(): void + { + $user = User::factory()->create(['name' => 'Ada']); + $duplicate = RoadmapItem::factory()->planned()->create(['title' => 'Dark mode']); + $target = RoadmapItem::factory()->planned()->create(['title' => 'Themes']); + + $mail = (new RoadmapItemMergedNotification($duplicate, $target))->toMail($user); + + $this->assertStringContainsString('Dark mode', implode(' ', $mail->introLines)); + $this->assertStringContainsString('Themes', implode(' ', $mail->introLines)); + $this->assertSame($target->url(), $mail->actionUrl); + } } From 6bfe6845487532fbeb99c3ea61be3d9adcbce331 Mon Sep 17 00:00:00 2001 From: roble Date: Fri, 20 Nov 2026 21:16:38 +0000 Subject: [PATCH 6/7] chore: require core ^3.1 for the demo account attribute Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3014219..a2d8655 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "version": "v3.5.2", "require": { - "saucebase/core": "^3.0" + "saucebase/core": "^3.1" }, "authors": [ { From dae944efbf41f8d977bbdafc1e5658f4b7580249 Mon Sep 17 00:00:00 2001 From: roble Date: Fri, 20 Nov 2026 21:16:39 +0000 Subject: [PATCH 7/7] fix: an item is merged once, however many times the merge is asked Co-Authored-By: Claude Opus 5.5 --- .../saucebase-roadmap-development/SKILL.md | 1 + src/Actions/MergeItem.php | 17 +++++++++++++---- tests/Feature/RoadmapMergeTest.php | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/resources/boost/skills/saucebase-roadmap-development/SKILL.md b/resources/boost/skills/saucebase-roadmap-development/SKILL.md index 6e5b7d6..b052bf6 100644 --- a/resources/boost/skills/saucebase-roadmap-development/SKILL.md +++ b/resources/boost/skills/saucebase-roadmap-development/SKILL.md @@ -67,6 +67,7 @@ Moderation hides rather than deletes: `hidden_at` plus a private `hidden_reason` - **The source's address redirects** (301, as a merge cannot be undone) to the target: `RoadmapController::show()`, before the visibility check, so shared links and "My feedback" still reach the conversation. The target's own rules apply there. - **Only into a public item:** voters follow their votes and the mail names the target. `MergeItem` throws otherwise, and the admin picker lists public items only. +- **Once only:** the source is locked and read again inside the transaction; a double click or a second admin finds it merged and changes and sends nothing. - **Its subscribers hear where it went:** `RoadmapItemMergedNotification` to the source's voters and author, read before the votes move, sent after commit. A merge sends no `StatusChanged` mail: closing the source is not a rejection (the `updated` hook skips a status change that comes with `merged_into_id`). ### Notifications Go To Everyone Waiting diff --git a/src/Actions/MergeItem.php b/src/Actions/MergeItem.php index c4904cd..3e59a48 100644 --- a/src/Actions/MergeItem.php +++ b/src/Actions/MergeItem.php @@ -28,10 +28,15 @@ public function handle(RoadmapItem $duplicate, RoadmapItem $target): void throw new InvalidArgumentException('An item can only be merged into a public one.'); } - // Read before the votes move: afterwards the duplicate has no voters. - $subscribers = $duplicate->subscribers(); + $subscribers = DB::transaction(function () use ($duplicate, $target) { + // Locked and read again: a double click, or two admins at once, merges it once. + if (RoadmapItem::lockForUpdate()->find($duplicate->getKey())?->merged_into_id !== null) { + return null; + } + + // Read before the votes move: afterwards the duplicate has no voters. + $subscribers = $duplicate->subscribers(); - DB::transaction(function () use ($duplicate, $target): void { $duplicate->votes()->whereIn('user_id', $target->votes()->pluck('user_id'))->delete(); $duplicate->votes()->update(['roadmap_item_id' => $target->getKey()]); // The relation is ordered, and an ordered UPDATE is not portable. @@ -41,8 +46,12 @@ public function handle(RoadmapItem $duplicate, RoadmapItem $target): void 'merged_into_id' => $target->getKey(), 'status' => RoadmapStatus::Closed, ]); + + return $subscribers; }); - Notification::send($subscribers, (new RoadmapItemMergedNotification($duplicate, $target))->afterCommit()); + if ($subscribers !== null) { + Notification::send($subscribers, (new RoadmapItemMergedNotification($duplicate, $target))->afterCommit()); + } } } diff --git a/tests/Feature/RoadmapMergeTest.php b/tests/Feature/RoadmapMergeTest.php index e6c99ec..7c4451a 100644 --- a/tests/Feature/RoadmapMergeTest.php +++ b/tests/Feature/RoadmapMergeTest.php @@ -4,12 +4,12 @@ use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Notification; use Modules\Roadmap\Actions\MergeItem; use Modules\Roadmap\Enums\RoadmapStatus; use Modules\Roadmap\Models\RoadmapItem; use Modules\Roadmap\Notifications\RoadmapItemMergedNotification; use Modules\Roadmap\Notifications\RoadmapItemStatusChangedNotification; -use Illuminate\Support\Facades\Notification; use Tests\TestCase; class RoadmapMergeTest extends TestCase @@ -92,6 +92,21 @@ public function test_the_duplicates_address_leads_to_the_item_it_was_merged_into } /** Their vote moved: voters and the author hear where, once, and nothing about "Closed". */ + /** A double click, or two admins at once: the second merge finds it merged and tells no one again. */ + public function test_a_second_merge_of_the_same_item_changes_nothing(): void + { + Notification::fake(); + $author = User::factory()->create(); + $duplicate = RoadmapItem::factory()->planned()->create(['user_id' => $author->id]); + $target = RoadmapItem::factory()->planned()->create(); + $stale = RoadmapItem::find($duplicate->id); + + app(MergeItem::class)->handle($duplicate, $target); + app(MergeItem::class)->handle($stale, $target); + + Notification::assertSentToTimes($author, RoadmapItemMergedNotification::class, 1); + } + public function test_voters_and_the_author_are_told_where_it_went(): void { Notification::fake();