-
Notifications
You must be signed in to change notification settings - Fork 607
Copy batch action: show only locales available in current project #4435
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
mathjazz
merged 8 commits into
mozilla:main
from
MundiaNderi:bug-4424-project-only-locales
Sep 3, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c1f5f8f
Fixes #4424
MundiaNderi 1cd571d
Adding tests
MundiaNderi 5ab5fdb
Fixing linting issues
MundiaNderi 0af3563
Remove extra request and use project state
MundiaNderi df9cf28
Fix batchactions test and remove calls to fetchAllLocales
MundiaNderi 6a49ea3
Fix project locale selection and reset stale locale
MundiaNderi aa42ab6
Fix project locale selection and reset stale locale
MundiaNderi c6ca5c0
Reset project state for all projects and guard against stale updates
MundiaNderi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { fetchAllLocales } from './other-locales'; | ||
| import { GET } from './utils/base'; | ||
|
|
||
| vi.mock('./utils/base', () => ({ | ||
| GET: vi.fn(), | ||
| })); | ||
|
|
||
| describe('fetchAllLocales', () => { | ||
| afterEach(() => { | ||
| vi.mocked(GET).mockReset(); | ||
| }); | ||
|
|
||
| describe('all-projects', () => { | ||
| it('hits the global locale list endpoint, not a project endpoint', async () => { | ||
| vi.mocked(GET).mockResolvedValueOnce({ results: [], next: null }); | ||
|
|
||
| await fetchAllLocales(); | ||
|
|
||
| expect(GET).toHaveBeenCalledWith( | ||
| expect.stringMatching(/^\/api\/v2\/locales\/\?/), | ||
| ); | ||
| expect(GET).not.toHaveBeenCalledWith( | ||
| expect.stringContaining('/api/v2/projects/'), | ||
| ); | ||
| }); | ||
|
|
||
| it('follows pagination until next is null', async () => { | ||
| vi.mocked(GET) | ||
| .mockResolvedValueOnce({ | ||
| results: [{ code: 'a', name: 'Locale A' }], | ||
| next: '/api/v2/locales/?page=2', | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| results: [{ code: 'b', name: 'Locale B' }], | ||
| next: null, | ||
| }); | ||
|
|
||
| const result = await fetchAllLocales(); | ||
|
|
||
| expect(GET).toHaveBeenCalledTimes(2); | ||
| expect(result).toEqual([ | ||
| { code: 'a', name: 'Locale A' }, | ||
| { code: 'b', name: 'Locale B' }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('stops looping and does not hang if next is missing rather than null', async () => { | ||
| vi.mocked(GET).mockResolvedValueOnce({ | ||
| results: [{ code: 'a', name: 'A' }], | ||
| }); | ||
| const result = await fetchAllLocales(); | ||
| expect(result).toEqual([{ code: 'a', name: 'A' }]); | ||
| }); | ||
| }); | ||
| }); |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.