Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

GitActionsControl.logic.test.ts

927 lines24.0 KB

1import type { GitStatusResult } from "@t3tools/contracts";
2import { assert, describe, it } from "vitest";
3import {
4 buildGitActionProgressStages,
5 buildMenuItems,
6 requiresDefaultBranchConfirmation,
7 resolveAutoFeatureBranchName,
8 resolveDefaultBranchActionDialogCopy,
9 resolveQuickAction,
10 summarizeGitResult,
11} from "./GitActionsControl.logic";
12​
13function status(overrides: Partial<GitStatusResult> = {}): GitStatusResult {
14 return {
15 branch: "feature/test",
16 hasWorkingTreeChanges: false,
17 workingTree: {
18 files: [],
19 insertions: 0,
20 deletions: 0,
21 },
22 hasUpstream: true,
23 aheadCount: 0,
24 behindCount: 0,
25 pr: null,
26 ...overrides,
27 };
29​
30describe("when: branch is clean and has an open PR", () => {
31 it("resolveQuickAction opens the existing PR", () => {
32 const quick = resolveQuickAction(
33 status({
34 pr: {
35 number: 10,
36 title: "Open PR",
37 url: "https://example.com/pr/10",
38 baseBranch: "main",
39 headBranch: "feature/test",
40 state: "open",
41 },
42 }),
43 false,
44 );
45 assert.deepInclude(quick, { kind: "open_pr", label: "Open PR", disabled: false });
46 });
47​
48 it("buildMenuItems disables commit/push and enables open PR", () => {
49 const items = buildMenuItems(
50 status({
51 pr: {
52 number: 11,
53 title: "Existing PR",
54 url: "https://example.com/pr/11",
55 baseBranch: "main",
56 headBranch: "feature/test",
57 state: "open",
58 },
59 }),
60 false,
61 );
62 assert.deepEqual(items, [
63 {
64 id: "commit",
65 label: "Commit",
66 disabled: true,
67 icon: "commit",
68 kind: "open_dialog",
69 dialogAction: "commit",
70 },
71 {
72 id: "push",
73 label: "Push",
74 disabled: true,
75 icon: "push",
76 kind: "open_dialog",
77 dialogAction: "push",
78 },
79 {
80 id: "pr",
81 label: "Open PR",
82 disabled: false,
83 icon: "pr",
84 kind: "open_pr",
85 },
86 ]);
87 });
88});
89​
90describe("when: actions are busy", () => {
91 it("resolveQuickAction returns running disabled state", () => {
92 const quick = resolveQuickAction(status(), true);
93 assert.deepInclude(quick, {
94 kind: "show_hint",
95 label: "Commit",
96 disabled: true,
97 hint: "Git action in progress.",
98 });
99 });
100​
101 it("buildMenuItems disables all actions", () => {
102 const items = buildMenuItems(status(), true);
103 assert.deepEqual(items, [
104 {
105 id: "commit",
106 label: "Commit",
107 disabled: true,
108 icon: "commit",
109 kind: "open_dialog",
110 dialogAction: "commit",
111 },
112 {
113 id: "push",
114 label: "Push",
115 disabled: true,
116 icon: "push",
117 kind: "open_dialog",
118 dialogAction: "push",
119 },
120 {
121 id: "pr",
122 label: "Create PR",
123 disabled: true,
124 icon: "pr",
125 kind: "open_dialog",
126 dialogAction: "create_pr",
127 },
128 ]);
129 });
130});
131​
132describe("when: git status is unavailable", () => {
133 it("resolveQuickAction returns unavailable disabled state", () => {
134 const quick = resolveQuickAction(null, false);
135 assert.deepInclude(quick, {
136 kind: "show_hint",
137 label: "Commit",
138 disabled: true,
139 hint: "Git status is unavailable.",
140 });
141 });
142​
143 it("buildMenuItems returns no menu items", () => {
144 const items = buildMenuItems(null, false);
145 assert.deepEqual(items, []);
146 });
147});
148​
149describe("when: branch is clean, ahead, and has an open PR", () => {
150 it("resolveQuickAction prefers push", () => {
151 const quick = resolveQuickAction(
152 status({
153 aheadCount: 3,
154 pr: {
155 number: 13,
156 title: "Open PR",
157 url: "https://example.com/pr/13",
158 baseBranch: "main",
159 headBranch: "feature/test",
160 state: "open",
161 },
162 }),
163 false,
164 );
165 assert.deepInclude(quick, { kind: "run_action", action: "commit_push", label: "Push" });
166 });
167​
168 it("buildMenuItems enables push and keeps open PR available", () => {
169 const items = buildMenuItems(
170 status({
171 aheadCount: 2,
172 pr: {
173 number: 12,
174 title: "Existing PR",
175 url: "https://example.com/pr/12",
176 baseBranch: "main",
177 headBranch: "feature/test",
178 state: "open",
179 },
180 }),
181 false,
182 );
183 assert.deepEqual(items, [
184 {
185 id: "commit",
186 label: "Commit",
187 disabled: true,
188 icon: "commit",
189 kind: "open_dialog",
190 dialogAction: "commit",
191 },
192 {
193 id: "push",
194 label: "Push",
195 disabled: false,
196 icon: "push",
197 kind: "open_dialog",
198 dialogAction: "push",
199 },
200 {
201 id: "pr",
202 label: "Open PR",
203 disabled: false,
204 icon: "pr",
205 kind: "open_pr",
206 },
207 ]);
208 });
209});
210​
211describe("when: branch is clean, ahead, and has no open PR", () => {
212 it("resolveQuickAction pushes and creates a PR", () => {
213 const quick = resolveQuickAction(status({ aheadCount: 2, pr: null }), false);
214 assert.deepInclude(quick, {
215 kind: "run_action",
216 action: "commit_push_pr",
217 label: "Push & create PR",
218 });
219 });
220​
221 it("buildMenuItems enables push and create PR, with commit disabled", () => {
222 const items = buildMenuItems(status({ aheadCount: 2, pr: null }), false);
223 assert.deepEqual(items, [
224 {
225 id: "commit",
226 label: "Commit",
227 disabled: true,
228 icon: "commit",
229 kind: "open_dialog",
230 dialogAction: "commit",
231 },
232 {
233 id: "push",
234 label: "Push",
235 disabled: false,
236 icon: "push",
237 kind: "open_dialog",
238 dialogAction: "push",
239 },
240 {
241 id: "pr",
242 label: "Create PR",
243 disabled: false,
244 icon: "pr",
245 kind: "open_dialog",
246 dialogAction: "create_pr",
247 },
248 ]);
249 });
250});
251​
252describe("when: branch is clean, up to date, and has no open PR", () => {
253 it("resolveQuickAction returns disabled no-action state", () => {
254 const quick = resolveQuickAction(
255 status({ aheadCount: 0, behindCount: 0, hasWorkingTreeChanges: false, pr: null }),
256 false,
257 );
258 assert.deepInclude(quick, { kind: "show_hint", label: "Commit", disabled: true });
259 });
260​
261 it("buildMenuItems disables commit, push, and create PR", () => {
262 const items = buildMenuItems(status({ aheadCount: 0, behindCount: 0, pr: null }), false);
263 assert.deepEqual(items, [
264 {
265 id: "commit",
266 label: "Commit",
267 disabled: true,
268 icon: "commit",
269 kind: "open_dialog",
270 dialogAction: "commit",
271 },
272 {
273 id: "push",
274 label: "Push",
275 disabled: true,
276 icon: "push",
277 kind: "open_dialog",
278 dialogAction: "push",
279 },
280 {
281 id: "pr",
282 label: "Create PR",
283 disabled: true,
284 icon: "pr",
285 kind: "open_dialog",
286 dialogAction: "create_pr",
287 },
288 ]);
289 });
290});
291​
292describe("when: branch is behind upstream", () => {
293 it("resolveQuickAction returns pull", () => {
294 const quick = resolveQuickAction(status({ behindCount: 2 }), false);
295 assert.deepInclude(quick, { kind: "run_pull", label: "Pull", disabled: false });
296 });
297​
298 it("buildMenuItems disables push and create PR", () => {
299 const items = buildMenuItems(status({ behindCount: 1, pr: null }), false);
300 assert.deepEqual(items, [
301 {
302 id: "commit",
303 label: "Commit",
304 disabled: true,
305 icon: "commit",
306 kind: "open_dialog",
307 dialogAction: "commit",
308 },
309 {
310 id: "push",
311 label: "Push",
312 disabled: true,
313 icon: "push",
314 kind: "open_dialog",
315 dialogAction: "push",
316 },
317 {
318 id: "pr",
319 label: "Create PR",
320 disabled: true,
321 icon: "pr",
322 kind: "open_dialog",
323 dialogAction: "create_pr",
324 },
325 ]);
326 });
327});
328​
329describe("when: branch has diverged from upstream", () => {
330 it("resolveQuickAction returns a disabled sync hint", () => {
331 const quick = resolveQuickAction(status({ aheadCount: 2, behindCount: 1 }), false);
332 assert.deepEqual(quick, {
333 label: "Sync branch",
334 disabled: true,
335 kind: "show_hint",
336 hint: "Branch has diverged from upstream. Rebase/merge first.",
337 });
338 });
339});
340​
341describe("when: working tree has local changes", () => {
342 it("resolveQuickAction returns commit, push, and create PR", () => {
343 const quick = resolveQuickAction(status({ hasWorkingTreeChanges: true }), false);
344 assert.deepInclude(quick, {
345 kind: "run_action",
346 action: "commit_push_pr",
347 label: "Commit, push & create PR",
348 });
349 });
350​
351 it("resolveQuickAction returns commit and push when open PR exists", () => {
352 const quick = resolveQuickAction(
353 status({
354 hasWorkingTreeChanges: true,
355 pr: {
356 number: 16,
357 title: "Existing PR",
358 url: "https://example.com/pr/16",
359 baseBranch: "main",
360 headBranch: "feature/test",
361 state: "open",
362 },
363 }),
364 false,
365 );
366 assert.deepInclude(quick, {
367 kind: "run_action",
368 action: "commit_push",
369 label: "Commit & push",
370 });
371 });
372​
373 it("buildMenuItems enables commit and disables push and PR", () => {
374 const items = buildMenuItems(status({ hasWorkingTreeChanges: true }), false);
375 assert.deepEqual(items, [
376 {
377 id: "commit",
378 label: "Commit",
379 disabled: false,
380 icon: "commit",
381 kind: "open_dialog",
382 dialogAction: "commit",
383 },
384 {
385 id: "push",
386 label: "Push",
387 disabled: true,
388 icon: "push",
389 kind: "open_dialog",
390 dialogAction: "push",
391 },
392 {
393 id: "pr",
394 label: "Create PR",
395 disabled: true,
396 icon: "pr",
397 kind: "open_dialog",
398 dialogAction: "create_pr",
399 },
400 ]);
401 });
402});
403​
404describe("when: on default branch without open PR", () => {
405 it("resolveQuickAction returns commit and push when local changes exist", () => {
406 const quick = resolveQuickAction(
407 status({ branch: "main", hasWorkingTreeChanges: true }),
408 false,
409 true,
410 );
411 assert.deepInclude(quick, {
412 kind: "run_action",
413 action: "commit_push",
414 label: "Commit & push",
415 disabled: false,
416 });
417 });
418​
419 it("resolveQuickAction returns push when branch is ahead", () => {
420 const quick = resolveQuickAction(
421 status({ branch: "main", aheadCount: 2, pr: null }),
422 false,
423 true,
424 );
425 assert.deepInclude(quick, {
426 kind: "run_action",
427 action: "commit_push",
428 label: "Push",
429 disabled: false,
430 });
431 });
432});
433​
434describe("when: working tree has local changes and branch is behind upstream", () => {
435 it("resolveQuickAction still prefers commit, push, and create PR", () => {
436 const quick = resolveQuickAction(
437 status({ hasWorkingTreeChanges: true, behindCount: 1 }),
438 false,
439 );
440 assert.deepInclude(quick, {
441 kind: "run_action",
442 action: "commit_push_pr",
443 label: "Commit, push & create PR",
444 });
445 });
446​
447 it("buildMenuItems enables commit and keeps push and PR disabled", () => {
448 const items = buildMenuItems(status({ hasWorkingTreeChanges: true, behindCount: 2 }), false);
449 assert.deepEqual(items, [
450 {
451 id: "commit",
452 label: "Commit",
453 disabled: false,
454 icon: "commit",
455 kind: "open_dialog",
456 dialogAction: "commit",
457 },
458 {
459 id: "push",
460 label: "Push",
461 disabled: true,
462 icon: "push",
463 kind: "open_dialog",
464 dialogAction: "push",
465 },
466 {
467 id: "pr",
468 label: "Create PR",
469 disabled: true,
470 icon: "pr",
471 kind: "open_dialog",
472 dialogAction: "create_pr",
473 },
474 ]);
475 });
476});
477​
478describe("when: HEAD is detached and there are no local changes", () => {
479 it("resolveQuickAction shows detached head hint", () => {
480 const quick = resolveQuickAction(
481 status({ branch: null, hasWorkingTreeChanges: false, hasUpstream: false }),
482 false,
483 );
484 assert.deepInclude(quick, { kind: "show_hint", label: "Commit", disabled: true });
485 });
486​
487 it("buildMenuItems keeps commit, push, and PR disabled", () => {
488 const items = buildMenuItems(status({ branch: null, hasWorkingTreeChanges: false }), false);
489 assert.deepEqual(items, [
490 {
491 id: "commit",
492 label: "Commit",
493 disabled: true,
494 icon: "commit",
495 kind: "open_dialog",
496 dialogAction: "commit",
497 },
498 {
499 id: "push",
500 label: "Push",
501 disabled: true,
502 icon: "push",
503 kind: "open_dialog",
504 dialogAction: "push",
505 },
506 {
507 id: "pr",
508 label: "Create PR",
509 disabled: true,
510 icon: "pr",
511 kind: "open_dialog",
512 dialogAction: "create_pr",
513 },
514 ]);
515 });
516});
517​
518describe("when: branch has no upstream configured", () => {
519 it("resolveQuickAction is disabled when clean, no upstream, and no local commits are ahead", () => {
520 const quick = resolveQuickAction(
521 status({ hasUpstream: false, pr: null, aheadCount: 0 }),
522 false,
523 );
524 assert.deepInclude(quick, {
525 kind: "show_hint",
526 label: "Push",
527 hint: "No local commits to push.",
528 disabled: true,
529 });
530 });
531​
532 it("resolveQuickAction opens PR when clean, no upstream, no local commits are ahead, and PR exists", () => {
533 const quick = resolveQuickAction(
534 status({
535 hasUpstream: false,
536 aheadCount: 0,
537 pr: {
538 number: 14,
539 title: "Existing PR",
540 url: "https://example.com/pr/14",
541 baseBranch: "main",
542 headBranch: "feature/test",
543 state: "open",
544 },
545 }),
546 false,
547 );
548 assert.deepInclude(quick, {
549 kind: "open_pr",
550 label: "Open PR",
551 disabled: false,
552 });
553 });
554​
555 it("resolveQuickAction runs push when clean, no upstream, and local commits are ahead", () => {
556 const quick = resolveQuickAction(
557 status({
558 hasUpstream: false,
559 aheadCount: 1,
560 pr: {
561 number: 15,
562 title: "Existing PR",
563 url: "https://example.com/pr/15",
564 baseBranch: "main",
565 headBranch: "feature/test",
566 state: "open",
567 },
568 }),
569 false,
570 );
571 assert.deepInclude(quick, {
572 kind: "run_action",
573 action: "commit_push",
574 label: "Push",
575 disabled: false,
576 });
577 });
578​
579 it("buildMenuItems disables push and create PR when no commits are ahead", () => {
580 const items = buildMenuItems(
581 status({ hasUpstream: false, pr: null, aheadCount: 0 }),
582 false,
583 );
584 assert.deepEqual(items, [
585 {
586 id: "commit",
587 label: "Commit",
588 disabled: true,
589 icon: "commit",
590 kind: "open_dialog",
591 dialogAction: "commit",
592 },
593 {
594 id: "push",
595 label: "Push",
596 disabled: true,
597 icon: "push",
598 kind: "open_dialog",
599 dialogAction: "push",
600 },
601 {
602 id: "pr",
603 label: "Create PR",
604 disabled: true,
605 icon: "pr",
606 kind: "open_dialog",
607 dialogAction: "create_pr",
608 },
609 ]);
610 });
611​
612 it("resolveQuickAction runs push and create PR when no upstream and commits are ahead", () => {
613 const quick = resolveQuickAction(
614 status({
615 hasUpstream: false,
616 aheadCount: 2,
617 pr: null,
618 }),
619 false,
620 );
621 assert.deepInclude(quick, {
622 kind: "run_action",
623 action: "commit_push_pr",
624 label: "Push & create PR",
625 disabled: false,
626 });
627 });
628​
629 it("buildMenuItems enables create PR when no upstream and commits are ahead", () => {
630 const items = buildMenuItems(
631 status({ hasUpstream: false, pr: null, aheadCount: 2 }),
632 false,
633 );
634 assert.deepEqual(items, [
635 {
636 id: "commit",
637 label: "Commit",
638 disabled: true,
639 icon: "commit",
640 kind: "open_dialog",
641 dialogAction: "commit",
642 },
643 {
644 id: "push",
645 label: "Push",
646 disabled: false,
647 icon: "push",
648 kind: "open_dialog",
649 dialogAction: "push",
650 },
651 {
652 id: "pr",
653 label: "Create PR",
654 disabled: false,
655 icon: "pr",
656 kind: "open_dialog",
657 dialogAction: "create_pr",
658 },
659 ]);
660 });
661​
662 it("resolveQuickAction is disabled on default branch when no upstream exists and no commits are ahead", () => {
663 const quick = resolveQuickAction(
664 status({
665 branch: "main",
666 hasUpstream: false,
667 aheadCount: 0,
668 pr: null,
669 }),
670 false,
671 true,
672 );
673 assert.deepInclude(quick, {
674 kind: "show_hint",
675 label: "Push",
676 hint: "No local commits to push.",
677 disabled: true,
678 });
679 });
680​
681 it("resolveQuickAction uses push-only on default branch when no upstream exists and commits are ahead", () => {
682 const quick = resolveQuickAction(
683 status({
684 branch: "main",
685 hasUpstream: false,
686 aheadCount: 1,
687 pr: null,
688 }),
689 false,
690 true,
691 );
692 assert.deepInclude(quick, {
693 kind: "run_action",
694 action: "commit_push",
695 label: "Push",
696 disabled: false,
697 });
698 });
699​
700 it("buildMenuItems still disables push and create PR when branch is behind", () => {
701 const items = buildMenuItems(
702 status({
703 hasUpstream: false,
704 behindCount: 1,
705 aheadCount: 0,
706 pr: null,
707 }),
708 false,
709 );
710 assert.deepEqual(items, [
711 {
712 id: "commit",
713 label: "Commit",
714 disabled: true,
715 icon: "commit",
716 kind: "open_dialog",
717 dialogAction: "commit",
718 },
719 {
720 id: "push",
721 label: "Push",
722 disabled: true,
723 icon: "push",
724 kind: "open_dialog",
725 dialogAction: "push",
726 },
727 {
728 id: "pr",
729 label: "Create PR",
730 disabled: true,
731 icon: "pr",
732 kind: "open_dialog",
733 dialogAction: "create_pr",
734 },
735 ]);
736 });
737});
738​
739describe("requiresDefaultBranchConfirmation", () => {
740 it("requires confirmation only for push actions on default branch", () => {
741 assert.isFalse(requiresDefaultBranchConfirmation("commit", true));
742 assert.isTrue(requiresDefaultBranchConfirmation("commit_push", true));
743 assert.isTrue(requiresDefaultBranchConfirmation("commit_push_pr", true));
744 assert.isFalse(requiresDefaultBranchConfirmation("commit_push", false));
745 });
746});
747​
748describe("resolveDefaultBranchActionDialogCopy", () => {
749 it("uses push-only copy when pushing without a commit", () => {
750 const copy = resolveDefaultBranchActionDialogCopy({
751 action: "commit_push",
752 branchName: "main",
753 includesCommit: false,
754 });
755​
756 assert.deepEqual(copy, {
757 title: "Push to default branch?",
758 description:
759 'This action will push local commits on "main". You can continue on this branch or create a feature branch and run the same action there.',
760 continueLabel: "Push to main",
761 });
762 });
763​
764 it("uses push-and-pr copy when creating a PR without a commit", () => {
765 const copy = resolveDefaultBranchActionDialogCopy({
766 action: "commit_push_pr",
767 branchName: "main",
768 includesCommit: false,
769 });
770​
771 assert.deepEqual(copy, {
772 title: "Push & create PR from default branch?",
773 description:
774 'This action will push local commits and create a PR on "main". You can continue on this branch or create a feature branch and run the same action there.',
775 continueLabel: "Push & create PR",
776 });
777 });
778​
779 it("keeps commit copy when the action includes a commit", () => {
780 const copy = resolveDefaultBranchActionDialogCopy({
781 action: "commit_push_pr",
782 branchName: "main",
783 includesCommit: true,
784 });
785​
786 assert.deepEqual(copy, {
787 title: "Commit, push & create PR from default branch?",
788 description:
789 'This action will commit, push, and create a PR on "main". You can continue on this branch or create a feature branch and run the same action there.',
790 continueLabel: "Commit, push & create PR",
791 });
792 });
793});
794​
795describe("buildGitActionProgressStages", () => {
796 it("shows only push progress when push-only is forced", () => {
797 const stages = buildGitActionProgressStages({
798 action: "commit_push",
799 hasCustomCommitMessage: false,
800 hasWorkingTreeChanges: true,
801 forcePushOnly: true,
802 pushTarget: "origin/feature/test",
803 });
804 assert.deepEqual(stages, ["Pushing to origin/feature/test..."]);
805 });
806​
807 it("includes commit stages for commit+push when working tree is dirty", () => {
808 const stages = buildGitActionProgressStages({
809 action: "commit_push",
810 hasCustomCommitMessage: false,
811 hasWorkingTreeChanges: true,
812 pushTarget: "origin/feature/test",
813 });
814 assert.deepEqual(stages, [
815 "Generating commit message...",
816 "Committing...",
817 "Pushing to origin/feature/test...",
818 ]);
819 });
820});
821​
822describe("summarizeGitResult", () => {
823 it("returns commit-focused toast for commit action", () => {
824 const result = summarizeGitResult({
825 action: "commit",
826 commit: {
827 status: "created",
828 commitSha: "0123456789abcdef",
829 subject: "feat: add optimistic UI for git action button",
830 },
831 push: { status: "skipped_not_requested" },
832 pr: { status: "skipped_not_requested" },
833 });
834​
835 assert.deepEqual(result, {
836 title: "Committed 0123456",
837 description: "feat: add optimistic UI for git action button",
838 });
839 });
840​
841 it("returns push-focused toast for push action", () => {
842 const result = summarizeGitResult({
843 action: "commit_push",
844 commit: {
845 status: "created",
846 commitSha: "abcdef0123456789",
847 subject: "fix: tighten quick action tooltip hover handling",
848 },
849 push: {
850 status: "pushed",
851 branch: "foo",
852 upstreamBranch: "origin/foo",
853 },
854 pr: { status: "skipped_not_requested" },
855 });
856​
857 assert.deepEqual(result, {
858 title: "Pushed abcdef0 to origin/foo",
859 description: "fix: tighten quick action tooltip hover handling",
860 });
861 });
862​
863 it("returns PR-focused toast for created PR action", () => {
864 const result = summarizeGitResult({
865 action: "commit_push_pr",
866 commit: {
867 status: "created",
868 commitSha: "89abcdef01234567",
869 subject: "feat: ship github shortcuts",
870 },
871 push: {
872 status: "pushed",
873 branch: "foo",
874 },
875 pr: {
876 status: "created",
877 number: 42,
878 title: "feat: ship github shortcuts and improve PR CTA in success toast",
879 },
880 });
881​
882 assert.deepEqual(result, {
883 title: "Created PR #42",
884 description: "feat: ship github shortcuts and improve PR CTA in success toast",
885 });
886 });
887​
888 it("truncates long description text", () => {
889 const result = summarizeGitResult({
890 action: "commit_push_pr",
891 commit: {
892 status: "created",
893 commitSha: "89abcdef01234567",
894 subject: "short subject",
895 },
896 push: { status: "pushed", branch: "foo" },
897 pr: {
898 status: "created",
899 number: 99,
900 title:
901 "feat: this title is intentionally extremely long so we can validate that toast descriptions are truncated with an ellipsis suffix",
902 },
903 });
904​
905 assert.deepEqual(result, {
906 title: "Created PR #99",
907 description: "feat: this title is intentionally extremely long so we can validate t...",
908 });
909 });
910});
911​
912describe("resolveAutoFeatureBranchName", () => {
913 const day = new Date("2026-03-01T12:00:00.000Z");
914​
915 it("returns the base auto feature branch name when available", () => {
916 const branch = resolveAutoFeatureBranchName(["main", "feature/other"], day);
917 assert.equal(branch, "feature/stacked-20260301");
918 });
919​
920 it("increments suffix when the base name already exists", () => {
921 const branch = resolveAutoFeatureBranchName(
922 ["main", "feature/stacked-20260301", "feature/stacked-20260301-2"],
923 day,
924 );
925 assert.equal(branch, "feature/stacked-20260301-3");
926 });
927});