Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

test(list): exercise real wide-char branch names in width test (#3511)

Worktrunk Botcda508019598
diff --git a/tests/integration_tests/spacing_edge_cases.rs b/tests/integration_tests/spacing_edge_cases.rs
index 0f11a3c96..70080d4ef 100644
--- a/tests/integration_tests/spacing_edge_cases.rs
+++ b/tests/integration_tests/spacing_edge_cases.rs
@@ -48,11 +48,15 @@ fn test_long_branch_names_longer_than_header(mut repo: TestRepo) {
#[rstest]
fn test_unicode_branch_names_width_calculation(mut repo: TestRepo) {
- // Create worktrees with unicode characters that have different visual widths
- // Note: Git may have restrictions on branch names, so use valid characters
- repo.add_worktree("cafe");
- repo.add_worktree("naive");
- repo.add_worktree("resume");
+ // Wide (CJK) branch names whose display width differs from both their byte
+ // length and their char count — the list renderer pads columns by
+ // `unicode_width` display cells, so a byte- or char-count layout would
+ // misalign the Branch and Path columns for these. `日本語` is 3 chars /
+ // 9 bytes / 6 display cells; `中文` is 2 chars / 6 bytes / 4 cells. ASCII
+ // names (byte == char == cell) never exercise that path.
+ repo.add_worktree("日本語");
+ repo.add_worktree("中文");
+ repo.add_worktree("café");
snapshot_list("unicode_branch_names", &repo);
}
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
index 37aae944f..05235cdc2 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
@@ -35,6 +35,7 @@ info:
WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_PARENT_SHELL: ""
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
@@ -46,12 +47,12 @@ exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ main…± Remote⇅ Path Commit Age Message
@ main ^| | . 05a4a45d 16h Initial commit
-+ cafe _ ../repo.cafe 05a4a45d 16h Initial commit
++ café _ ../repo.café 05a4a45d 16h Initial commit
+ feature-a ↑ ↑1 +1 ../repo.feature-a 1b87d473 16h Add feature-a file
+ feature-b ↑ ↑1 +1 ../repo.feature-b f62940fc 16h Add feature-b file
+ feature-c ↑ ↑1 +1 ../repo.feature-c 345c7c93 16h Add feature-c file
-+ naive _ ../repo.naive 05a4a45d 16h Initial commit
-+ resume _ ../repo.resume 05a4a45d 16h Initial commit
++ 中文 _ ../repo.中文 05a4a45d 16h Initial commit
++ 日本語 _ ../repo.日本語 05a4a45d 16h Initial commit
----- stderr -----