@@ -2,46 +2,29 @@ import { test, expect } from '../../../playwright';
22
33test . describe ( 'Default Collection Location Feature' , ( ) => {
44 test ( 'Should hydrate the default location from preferences' , async ( { pageWithUserData : page } ) => {
5- // open preferences
5+ // open preferences tab
66 await page . locator ( '.preferences-button' ) . click ( ) ;
77
8+ // wait for preferences tab to be visible
9+ await page . waitForTimeout ( 500 ) ;
10+
11+ // navigate to General tab
12+ await page . getByRole ( 'tab' , { name : 'General' } ) . click ( ) ;
13+
814 // verify the default location is pre-filled
915 const defaultLocationInput = page . locator ( '.default-collection-location-input' ) ;
1016 await expect ( defaultLocationInput ) . toHaveValue ( '/tmp/bruno-collections' ) ;
11-
12- // close the preferences
13- await page . getByTestId ( 'modal-close-button' ) . click ( ) ;
14-
15- // wait for 2 seconds
16- await page . waitForTimeout ( 2000 ) ;
1717 } ) ;
1818
19- test ( 'Should save empty default location' , async ( { pageWithUserData : page } ) => {
20- // open preferences
19+ test ( 'Should save a valid default location' , async ( { pageWithUserData : page } ) => {
20+ // open preferences tab
2121 await page . locator ( '.preferences-button' ) . click ( ) ;
2222
23- // clear the default location field (readonly input, remove readonly then clear)
24- const defaultLocationInput = page . locator ( '.default-collection-location-input' ) ;
25- await defaultLocationInput . evaluate ( ( el ) => {
26- const input = el ;
27- input . removeAttribute ( 'readonly' ) ;
28- input . readOnly = false ;
29- } ) ;
30- await defaultLocationInput . clear ( ) ;
31-
32- // wait for auto-save to complete (debounce is 500ms)
33- await page . waitForTimeout ( 1000 ) ;
34-
35- // close the preferences
36- await page . getByTestId ( 'modal-close-button' ) . click ( ) ;
37-
38- // wait for modal to close
23+ // wait for preferences tab to be visible
3924 await page . waitForTimeout ( 500 ) ;
40- } ) ;
4125
42- test ( 'Should save a valid default location' , async ( { pageWithUserData : page } ) => {
43- // open preferences
44- await page . locator ( '.preferences-button' ) . click ( ) ;
26+ // navigate to General tab
27+ await page . getByRole ( 'tab' , { name : 'General' } ) . click ( ) ;
4528
4629 // set a default location (readonly input, remove readonly then fill)
4730 const defaultLocationInput = page . locator ( '.default-collection-location-input' ) ;
@@ -54,30 +37,27 @@ test.describe('Default Collection Location Feature', () => {
5437
5538 // wait for auto-save to complete (debounce is 500ms)
5639 await page . waitForTimeout ( 1000 ) ;
57-
58- // close the preferences
59- await page . getByTestId ( 'modal-close-button' ) . click ( ) ;
60-
61- // wait for modal to close
62- await page . waitForTimeout ( 500 ) ;
6340 } ) ;
6441
6542 test ( 'Should use default location in Create Collection modal' , async ( { pageWithUserData : page } ) => {
6643 // test Create Collection modal
6744 await page . getByTestId ( 'collections-header-add-menu' ) . click ( ) ;
6845 await page . locator ( '.tippy-box .dropdown-item' ) . filter ( { hasText : 'Create collection' } ) . click ( ) ;
6946
70- // verify the default location is pre-filled (if location input is visible)
71- const collectionLocationInput = page . getByLabel ( 'Location' ) ;
72- if ( await collectionLocationInput . isVisible ( ) ) {
73- await expect ( collectionLocationInput ) . toHaveValue ( '/tmp/bruno-collections' ) ;
74- }
47+ // Wait for modal to be visible
48+ await page . locator ( '.bruno-modal' ) . waitFor ( { state : 'visible' } ) ;
49+
50+ // verify the default location is pre-filled
51+ // Scope to the modal to avoid conflict with preferences tab
52+ const collectionLocationInput = page . locator ( '.bruno-modal' ) . getByLabel ( 'Location' , { exact : true } ) ;
53+ await expect ( collectionLocationInput ) . toBeVisible ( ) ;
54+
55+ const inputValue = await collectionLocationInput . inputValue ( ) ;
56+
57+ await expect ( collectionLocationInput ) . toHaveValue ( '/tmp/bruno-collections' , { timeout : 5000 } ) ;
7558
7659 // cancel the collection creation
7760 await page . locator ( '.bruno-modal' ) . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
78-
79- // wait for 2 seconds
80- await page . waitForTimeout ( 2000 ) ;
8161 } ) ;
8262
8363 test ( 'Should use default location in Clone Collection modal' , async ( { pageWithUserData : page } ) => {
@@ -87,16 +67,39 @@ test.describe('Default Collection Location Feature', () => {
8767 await collection . locator ( '.collection-actions .icon' ) . click ( ) ;
8868 await page . locator ( '.dropdown-item' ) . filter ( { hasText : 'Clone' } ) . click ( ) ;
8969
70+ // Wait for modal to be visible
71+ await page . locator ( '.bruno-modal' ) . waitFor ( { state : 'visible' } ) ;
72+
9073 // verify the default location is pre-filled
91- const cloneLocationInput = page . getByLabel ( 'Location' ) ;
92- if ( await cloneLocationInput . isVisible ( ) ) {
93- await expect ( cloneLocationInput ) . toHaveValue ( '/tmp/bruno-collections' ) ;
94- }
74+ // Scope to the modal to avoid conflict with preferences tab
75+ const cloneLocationInput = page . locator ( '.bruno-modal' ) . getByLabel ( 'Location' , { exact : true } ) ;
76+ await expect ( cloneLocationInput ) . toBeVisible ( ) ;
77+ await expect ( cloneLocationInput ) . toHaveValue ( '/tmp/bruno-collections' , { timeout : 5000 } ) ;
9578
9679 // cancel the clone operation
9780 await page . locator ( '.bruno-modal' ) . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
81+ } ) ;
82+
83+ test ( 'Should save empty default location' , async ( { pageWithUserData : page } ) => {
84+ // open preferences tab
85+ await page . locator ( '.preferences-button' ) . click ( ) ;
86+
87+ // wait for preferences tab to be visible
88+ await page . waitForTimeout ( 500 ) ;
9889
99- // wait for 2 seconds
100- await page . waitForTimeout ( 2000 ) ;
90+ // navigate to General tab
91+ await page . getByRole ( 'tab' , { name : 'General' } ) . click ( ) ;
92+
93+ // clear the default location field (readonly input, remove readonly then clear)
94+ const defaultLocationInput = page . locator ( '.default-collection-location-input' ) ;
95+ await defaultLocationInput . evaluate ( ( el ) => {
96+ const input = el ;
97+ input . removeAttribute ( 'readonly' ) ;
98+ input . readOnly = false ;
99+ } ) ;
100+ await defaultLocationInput . clear ( ) ;
101+
102+ // wait for auto-save to complete (debounce is 500ms)
103+ await page . waitForTimeout ( 1000 ) ;
101104 } ) ;
102105} ) ;
0 commit comments