@@ -3,8 +3,7 @@ import { expect, test } from "@playwright/test";
33test . describe ( "Test H6: Duplicate Shortcut - Within Group" , ( ) => {
44 test . beforeEach ( async ( { page } ) => {
55 await page . goto ( "/" ) ;
6- // Wait for mock data to load
7- await page . waitForTimeout ( 500 ) ;
6+ await page . waitForLoadState ( "networkidle" ) ;
87 } ) ;
98
109 test ( "should show validation error when entering duplicate shortcut within group" , async ( {
@@ -30,26 +29,37 @@ test.describe("Test H6: Duplicate Shortcut - Within Group", () => {
3029 await page . getByRole ( "button" , { name : "Save" } ) . click ( ) ;
3130
3231 // Verify validation error is shown for duplicate shortcut
33- // Or dialog should remain open if validation blocks save
34- const duplicateErrorVisible = await page
35- . getByText ( / d u p l i c a t e | a l r e a d y i n u s e | s h o r t c u t .* l / i)
36- . isVisible ( )
37- . catch ( ( ) => false ) ;
38-
39- // If no error shown, dialog should have closed (validation may not exist for within-group)
40- const dialogStillOpen = await dialog . isVisible ( ) ;
41-
42- // Document the behavior
43- if ( ! duplicateErrorVisible && ! dialogStillOpen ) {
44- // Validation doesn't block - this might be expected behavior
45- // (shortcuts within a group might be allowed to be the same)
46- console . log (
47- "Note: Duplicate shortcuts within group are allowed (dialog closed without error)"
48- ) ;
49- }
50-
51- // At minimum, verify the dialog behavior is consistent
52- expect ( duplicateErrorVisible || ! dialogStillOpen ) . toBe ( true ) ;
32+ await expect ( page . getByText ( / d u p l i c a t e s h o r t c u t s f o u n d i n g r o u p / i) ) . toBeVisible ( ) ;
33+
34+ // Dialog should remain open (validation blocks save)
35+ await expect ( dialog ) . toBeVisible ( ) ;
36+ } ) ;
37+
38+ test ( "should show validation error for case-insensitive duplicate shortcuts" , async ( {
39+ page,
40+ } ) => {
41+ // Open Git group edit dialog
42+ await page . getByRole ( "button" , { name : / E d i t c o m m a n d .* G i t / } ) . click ( ) ;
43+ const dialog = page . getByRole ( "dialog" , { name : "Edit Command" } ) ;
44+ await expect ( dialog ) . toBeVisible ( ) ;
45+
46+ // Get shortcut inputs within group
47+ const shortcutInputs = dialog . getByRole ( "textbox" , {
48+ name : "Shortcut (optional)" ,
49+ } ) ;
50+
51+ // Change Push shortcut to "L" (uppercase, same as Pull's "l")
52+ await shortcutInputs . nth ( 1 ) . clear ( ) ;
53+ await shortcutInputs . nth ( 1 ) . fill ( "L" ) ;
54+
55+ // Click Save
56+ await page . getByRole ( "button" , { name : "Save" } ) . click ( ) ;
57+
58+ // Verify validation error is shown (case-insensitive check)
59+ await expect ( page . getByText ( / d u p l i c a t e s h o r t c u t s f o u n d i n g r o u p / i) ) . toBeVisible ( ) ;
60+
61+ // Dialog should remain open
62+ await expect ( dialog ) . toBeVisible ( ) ;
5363 } ) ;
5464
5565 test ( "should have different shortcuts for child commands in Git group" , async ( {
@@ -69,4 +79,34 @@ test.describe("Test H6: Duplicate Shortcut - Within Group", () => {
6979 await expect ( pushShortcut ) . toBeVisible ( ) ;
7080 await expect ( checkStatusShortcut ) . toBeVisible ( ) ;
7181 } ) ;
82+
83+ test ( "should allow saving when duplicate shortcut is fixed" , async ( { page } ) => {
84+ // Open Git group edit dialog
85+ await page . getByRole ( "button" , { name : / E d i t c o m m a n d .* G i t / } ) . click ( ) ;
86+ const dialog = page . getByRole ( "dialog" , { name : "Edit Command" } ) ;
87+ await expect ( dialog ) . toBeVisible ( ) ;
88+
89+ // Get shortcut inputs within group
90+ const shortcutInputs = dialog . getByRole ( "textbox" , {
91+ name : "Shortcut (optional)" ,
92+ } ) ;
93+
94+ // Create duplicate shortcut
95+ await shortcutInputs . nth ( 1 ) . clear ( ) ;
96+ await shortcutInputs . nth ( 1 ) . fill ( "l" ) ;
97+
98+ // Try to save - should fail
99+ await page . getByRole ( "button" , { name : "Save" } ) . click ( ) ;
100+ await expect ( page . getByText ( / d u p l i c a t e s h o r t c u t s f o u n d i n g r o u p / i) ) . toBeVisible ( ) ;
101+
102+ // Fix the duplicate by using a unique shortcut
103+ await shortcutInputs . nth ( 1 ) . clear ( ) ;
104+ await shortcutInputs . nth ( 1 ) . fill ( "x" ) ;
105+
106+ // Now save should succeed
107+ await page . getByRole ( "button" , { name : "Save" } ) . click ( ) ;
108+
109+ // Dialog should close (save succeeded)
110+ await expect ( dialog ) . not . toBeVisible ( ) ;
111+ } ) ;
72112} ) ;
0 commit comments