usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
25.56k stars 1.17k forks source link

sort folders in collections #1974

Open neuromagus opened 5 months ago

neuromagus commented 5 months ago

now folders in collections sorted by

collection 11
collection 12
collection 3
collection 31
collection 4
collection 9

I prefer normal order:

collection 3
collection 4
collection 9
collection 11
collection 12
collection 31
neuromagus commented 5 months ago

@sanjai0py, i watched a code. Need a refactoring something... in files

packages/bruno-electron/src/ipc/network/helper.js line 23
packages/bruno-electron/src/ipc/network/index.js line 845
packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js line 113
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js line 181

duplicated code. Next: Collections reading by Watchers.js from filesystem and did not use any sorting formats...

for change this behavior just need a change 'sortBy' or 'sort' to this scenario or this For example, solution:

console.log(
  ['a 1', 'a 11', 'a 3', 'a 22'].sort(new Intl.Collator([], {numeric: true}).compare)
);
//result: Array ["a 1", "a 3", "a 11", "a 22"]

I'm lost, trying fix this behavior alone =( I did not found this place. So sad...

DanaEpp commented 5 months ago

This sounds like a bad idea. If the Collection Runner relies on order to run in the proper order, sorting will BREAK that.

Instead, allow for custom ordering, and drag and drop.

I think #1568 covers this well.

neuromagus commented 5 months ago

If the Collection Runner relies on order to run in the proper order, sorting will BREAK that.

what do you mean by 'proper order'? IMO, default behavior - 'A-z sorted' and later if user want - drag&drop custom order.

DanaEpp commented 5 months ago

How about the order they were imported or created represents the order in which tests are supposed to run?

When doing an import from Postman, I had over 100 folders in a specific order to run the test plan in a certain way so previous tests seeded data expected in later tests. That was completely lost due to Bruno's sorting.

Sorting it does nothing to help. My only solution was to number each folder and reimport it so things stayed in the same order as I expected it.

What is your use case where alphabetic sorting has a specific "value"? Is it to make finding the folders easier?

Typically, folders in collections represent test scenarios. Those usually have order precedence when conducting entire test plans since they run top to bottom. Sorting would break that.

neuromagus commented 5 months ago

What is your use case where alphabetic sorting has a specific "value"? Is it to make finding the folders easier?

to make it easier to navigate and find the folder you need.

Sometimes folders contain duplicate names containing numbers and combined by topic (for example: 'testDB 1', 'testDB N', where 'testDB 2' or 'testDB 3' added later and another developer) and if I see list of folders in collection like this:

testDB 1
testDB 11
testDB 2

I'm at a loss... ttt

When doing an import from Postman, I had over 100 folders in a specific order to run the test plan in a certain way so previous tests seeded data expected in later tests. That was completely lost due to Bruno's sorting.

About Importing from Postman - IMO, in Bruno now this module needs improvement. Firstly, import from Postman json break order. I create for testing folders with names 'name 1'...'name 13' (in Postman order is normal - 1,2,3..11,12,n) and after import to Bruno I watch order name 1, name 11, name 12, name 13, name 2. Maybe this behavior is related to the Linux file system, where Bruno saves collections.

And THIS behavior i want fix it!

For testing:

➥ touch a1;touch a2; touch a11; ls -la
total 8
drwxr-xr-x 2 4096 Apr  5 00:21 .
drwxr-xr-x 7 4096 Apr  5 00:18 ..
-rw-r--r-- 1    0 Apr  5 00:21 a1
-rw-r--r-- 1    0 Apr  5 00:21 a11
-rw-r--r-- 1    0 Apr  5 00:21 a2

How about the order they were imported or created represents the order in which tests are supposed to run?

Yes and yes.

Typically, folders in collections represent test scenarios. Those usually have order precedence when conducting entire test plans since they run top to bottom. Sorting would break that.

And again - yes. Most likely we are talking about the same thing. I described the problem above.