-
Notifications
You must be signed in to change notification settings - Fork 174
Respect the custom order of playlists and favorites #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d5e0b30
Respect a playlist's custom order (#202)
phanan 7677c2b
Respect the custom order on the Favorites screen too
phanan 90d077f
Gate the Custom order default on server support
phanan e99d7aa
Address review: descriptive test names + position immutability check
phanan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import 'package:app/enums.dart'; | ||
| import 'package:app/extensions/extensions.dart'; | ||
| import 'package:app/models/models.dart'; | ||
| import 'package:app/values/values.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| late Song a, b, c; | ||
|
|
||
| setUp(() { | ||
| a = Song.fake(title: 'A'); | ||
| b = Song.fake(title: 'B'); | ||
| c = Song.fake(title: 'C'); | ||
| }); | ||
|
|
||
| // Deliberately not alphabetical — mimics a playlist's custom order. | ||
| List<Playable> customOrder() => <Playable>[c, a, b]; | ||
|
|
||
| PlayableSortConfig config(String field, SortOrder order) => | ||
| PlayableSortConfig(field: field, order: order); | ||
|
|
||
| group('\$sort', () { | ||
| test('position keeps the server-provided order', () { | ||
| final sorted = customOrder().$sort(config('position', SortOrder.asc)); | ||
| expect(sorted, [c, a, b]); | ||
| }); | ||
|
|
||
| test('position descending reverses the server-provided order', () { | ||
| final sorted = customOrder().$sort(config('position', SortOrder.desc)); | ||
| expect(sorted, [b, a, c]); | ||
| }); | ||
|
|
||
| test('other fields still sort', () { | ||
| final sorted = customOrder().$sort(config('title', SortOrder.asc)); | ||
| expect(sorted.map((playable) => (playable as Song).title), ['A', 'B', 'C']); | ||
| }); | ||
|
|
||
| test('does not mutate the original list', () { | ||
| final original = customOrder(); | ||
| original.$sort(config('title', SortOrder.asc)); | ||
| expect(original, [c, a, b]); | ||
| }); | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add an immutability assertion for the
positionsort path.The immutability test only covers the
titlefield. Sincepositionis the primary new feature, explicitly verifying that it also doesn't mutate the original list would close the coverage gap.🧪 Suggested additional test
test('does not mutate the original list', () { final original = customOrder(); original.$sort(config('title', SortOrder.asc)); + original.$sort(config('position', SortOrder.asc)); + original.$sort(config('position', SortOrder.desc)); expect(original, [c, a, b]); });📝 Committable suggestion
🤖 Prompt for AI Agents