Retain filtered search results in URL for Commits list
What does this MR do and why?
Commit 1: Extract URL sync utilities to separate module
SHA: b2ef8a0b
- Created
utils/url_sync.jswith 3 utility functions - Created
utils/url_sync_spec.jswith 23 comprehensive tests - Improved code organization and testability
Commit 2: Add URL reflection for commit filter search tokens
SHA: 50192faa
- Implemented bidirectional URL synchronization
- Added URL reading on mount and route watching
- Added 29 new tests for URL synchronization features
- URL format:
?author=username&message=searchtext&page_size=N
Commit 3: Reorganize commits utilities into dedicated utils folder
SHA: 704e735d
- Moved
utils.js→utils/commit_grouping.js(more descriptive) - Moved
utils_spec.js→utils/commit_grouping_spec.js - Updated all import statements
- Consolidated all utility modules in dedicated
utils/directory
Commit 4: Refactor URL synchronization tests to follow GitLab testing guidelines
SHA: cc691292
- Reduced
wrapper.vmusage: 31 → 7 instances - Reduced test count: 187 → 180 tests
- Improved test descriptions using description field in
it.each
app/assets/javascripts/projects/commits/
├── utils/
│ ├── commit_grouping.js ← Groups commits by day
│ └── url_sync.js ← URL ↔ filter state conversion
└── components/
├── commit_list_app.vue
├── commit_list_header.vue
└── commit_filtered_search.vue
spec/frontend/projects/commits/
└── utils/
├── commit_grouping_spec.js (5 tests)
└── url_sync_spec.js (23 tests)References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- In rails console enable the feature flag
Feature.enable(:project_commits_refactor)
Test 1: Apply Author Filter
- On the commits page, click on the Author filter in the search bar
- Select a user (e.g., your own username or any committer)
- Verify: The URL updates to include the author parameter:
http://127.0.0.1:3000/.../commits/master?author=username - Verify: The commit list filters to show only commits by that author
Test 2: Apply Message Filter
- Clear any existing filters by clicking the X on filter tokens
- In the search bar, type a search term (e.g., "fix" or "add")
- Press Enter or click outside the search box
- Verify: The URL updates to include the message parameter:
http://127.0.0.1:3000/.../commits/master?message=fix - Verify: The commit list shows only commits with that text in the message
Test 3: Apply Both Filters
- Apply an author filter (e.g., select a username)
- Then add a message filter (e.g., type "merge")
- Verify: The URL includes both parameters:
http://127.0.0.1:3000/.../commits/master?author=username&message=merge - Verify: Commits are filtered by both author AND message
Test 4: Change Page Size
- If commits list has pagination (more than 20 commits), scroll to the bottom
- In the page size selector dropdown, select 50 or 100
- Verify: The URL updates to include page_size parameter:
http://127.0.0.1:3000/.../commits/master?page_size=50 - Verify: More commits are displayed per page Test 5: URL Persistence on Page Refresh
- Apply some filters (e.g., author and message)
- Copy the URL from the browser address bar
- Refresh the page (F5 or Cmd+R)
- Verify: The filters remain applied after refresh
- Verify: The filtered commit list is the same as before refresh
Test 6: Share URL with Filters
- Apply filters to get a specific view (e.g.,
?author=admin&message=fix) - Copy the URL from the address bar
- Open a new incognito/private browser window
- Paste the URL and navigate to it
- Verify: The same filters are automatically applied
- Verify: The commit list shows the same filtered results
Test 7: Browser Back/Forward Navigation
- Start on commits page without filters
- Apply an author filter → URL changes to
?author=username - Apply a message filter → URL changes to
?author=username&message=fix - Click browser Back button ←
- Verify: URL goes back to
?author=username - Verify: Message filter is removed, only author filter remains
- Click browser Forward button →
- Verify: URL returns to
?author=username&message=fix - Verify: Both filters are re-applied
Test 8: Clear Filters
- Apply multiple filters (author + message)
- Click the X button on each filter token to remove them
- Verify: URL parameters are removed as filters are cleared
- Verify: Final URL has no query parameters (or only default ones)
- Verify: All commits are displayed (unfiltered)
Test 9: Branch Switching with Filters
- Apply filters on master branch (e.g.,
?author=admin) - Use the branch selector dropdown to switch to a different branch
- Verify: Filters are preserved in the URL for the new branch:
http://127.0.0.1:3000/.../commits/develop?author=admin - Verify: Filters are applied to the new branch's commits
Test 10: Default Page Size Behavior
- Start with no filters applied
- Verify: URL does NOT include page_size parameter (default is 20)
- Change page size to 50 → URL includes
?page_size=50 - Change page size back to 20
- Verify: URL removes the page_size parameter (back to default)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Paulina Sedlak-Jakubowska