Merge pull request 'Fix main sorting test expectations and ticket key matching' (#93) from koda/fix-main-sorting-tests into main
linter / quality (push) Successful in 1m25s
tests / ci (8.4) (push) Successful in 1m37s

Reviewed-on: OpenSource/KanbanGit#93
Reviewed-by: Twyco <twyco@icloud.com>
This commit was merged in pull request #93.
This commit is contained in:
2026-06-03 09:29:55 +00:00
3 changed files with 16 additions and 11 deletions
@@ -11,9 +11,9 @@ class TicketKeyReferenceMatcherTest extends TestCase
use RefreshDatabase; use RefreshDatabase;
/** /**
* Ensure a reference must start with the exact ticket key. * Ensure a reference matches when it contains the ticket key, regardless of case.
*/ */
public function test_matcher_accepts_exact_ticket_key_prefixes(): void public function test_matcher_accepts_references_containing_the_ticket_key_case_insensitively(): void
{ {
$matcher = app(TicketKeyReferenceMatcher::class); $matcher = app(TicketKeyReferenceMatcher::class);
@@ -21,17 +21,19 @@ class TicketKeyReferenceMatcherTest extends TestCase
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1/fix-oauth')); $this->assertTrue($matcher->matches('CORE-1', 'CORE-1/fix-oauth'));
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1_hotfix')); $this->assertTrue($matcher->matches('CORE-1', 'CORE-1_hotfix'));
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1')); $this->assertTrue($matcher->matches('CORE-1', 'CORE-1'));
$this->assertTrue($matcher->matches('CORE-1', 'core-1-login-form'));
$this->assertTrue($matcher->matches('CORE-1', 'CORE-10-login-form'));
$this->assertTrue($matcher->matches('CORE-1', 'MY-CORE-1-login-form'));
} }
/** /**
* Ensure similar ticket keys are not treated as matches. * Ensure references without the ticket key are not treated as matches.
*/ */
public function test_matcher_rejects_other_ticket_prefixes(): void public function test_matcher_rejects_references_without_the_ticket_key(): void
{ {
$matcher = app(TicketKeyReferenceMatcher::class); $matcher = app(TicketKeyReferenceMatcher::class);
$this->assertFalse($matcher->matches('CORE-1', 'CORE-10-login-form')); $this->assertFalse($matcher->matches('CORE-1', 'CORE-2-login-form'));
$this->assertFalse($matcher->matches('CORE-1', 'MY-CORE-1-login-form')); $this->assertFalse($matcher->matches('CORE-1', 'feature/auth-cleanup'));
$this->assertFalse($matcher->matches('CORE-1', 'core-1-login-form'));
} }
} }
+2 -2
View File
@@ -54,7 +54,7 @@ class BoardColumnTest extends TestCase
} }
/** /**
* Ensure board columns expose tickets ordered by descending sequence number. * Ensure board columns expose tickets ordered by ascending sequence number.
*/ */
public function test_board_column_tickets_are_returned_in_sequence_order(): void public function test_board_column_tickets_are_returned_in_sequence_order(): void
{ {
@@ -98,7 +98,7 @@ class BoardColumnTest extends TestCase
]); ]);
$this->assertSame( $this->assertSame(
['CORE-2', 'CORE-1'], ['CORE-1', 'CORE-2'],
$boardColumn->fresh()->tickets->pluck('ticket_key')->all(), $boardColumn->fresh()->tickets->pluck('ticket_key')->all(),
); );
} }
@@ -338,18 +338,21 @@ class ProjectTicketControllerTest extends TestCase
->component('projects/Ticket') ->component('projects/Ticket')
->where('suggestedBranchName', 'core-1-branch-detail-test') ->where('suggestedBranchName', 'core-1-branch-detail-test')
->where('repositoryBranches.0.repository_connection.repository_full_name', 'core-team/kanbangit') ->where('repositoryBranches.0.repository_connection.repository_full_name', 'core-team/kanbangit')
->has('repositoryBranches.0.branches', 2) ->has('repositoryBranches.0.branches', 3)
->where('repositoryBranches.0.branches.0.name', 'CORE-1-login-form') ->where('repositoryBranches.0.branches.0.name', 'CORE-1-login-form')
->where('repositoryBranches.0.branches.1.name', 'CORE-1/fix-oauth') ->where('repositoryBranches.0.branches.1.name', 'CORE-1/fix-oauth')
->where('repositoryBranches.0.branches.2.name', 'CORE-10-should-not-match')
->where('repositoryBranches.1.repository_connection.repository_full_name', 'other-team/mobile') ->where('repositoryBranches.1.repository_connection.repository_full_name', 'other-team/mobile')
->where('repositoryBranches.1.repository_connection.has_personal_access', false) ->where('repositoryBranches.1.repository_connection.has_personal_access', false)
->where('repositoryBranches.1.branches', []) ->where('repositoryBranches.1.branches', [])
->has('repositoryPullRequests.0.pull_requests', 2) ->has('repositoryPullRequests.0.pull_requests', 3)
->where('repositoryPullRequests.0.pull_requests.0.number', '42') ->where('repositoryPullRequests.0.pull_requests.0.number', '42')
->where('repositoryPullRequests.0.pull_requests.0.title', 'Add login form') ->where('repositoryPullRequests.0.pull_requests.0.title', 'Add login form')
->where('repositoryPullRequests.0.pull_requests.0.status', 'open') ->where('repositoryPullRequests.0.pull_requests.0.status', 'open')
->where('repositoryPullRequests.0.pull_requests.1.number', '43') ->where('repositoryPullRequests.0.pull_requests.1.number', '43')
->where('repositoryPullRequests.0.pull_requests.1.status', 'merged') ->where('repositoryPullRequests.0.pull_requests.1.status', 'merged')
->where('repositoryPullRequests.0.pull_requests.2.number', '99')
->where('repositoryPullRequests.0.pull_requests.2.status', 'open')
->where('repositoryPullRequests.1.repository_connection.repository_full_name', 'other-team/mobile') ->where('repositoryPullRequests.1.repository_connection.repository_full_name', 'other-team/mobile')
->where('repositoryPullRequests.1.repository_connection.has_personal_access', false) ->where('repositoryPullRequests.1.repository_connection.has_personal_access', false)
->where('repositoryPullRequests.1.pull_requests', []), ->where('repositoryPullRequests.1.pull_requests', []),