feat(web): filter GitLab merge requests by source branch

This commit is contained in:
2026-08-16 16:23:36 +00:00
parent 6868a58359
commit 267db3fb9d
6 changed files with 73 additions and 4 deletions
+40
View File
@@ -105,6 +105,46 @@ describe('createWebGitLabAPI', () => {
});
});
it('passes sourceBranch query param to mrsList', async () => {
const result = {
connected: true,
repo: null,
mrs: [],
page: 1,
hasMore: false,
};
runtimeFetchMock.mockResolvedValueOnce(Response.json(result));
const api = await createAPI();
await expect(api.mrsList('/workspace', { page: 1, query: 'search', sourceBranch: 'feat/api' })).resolves.toEqual(result);
const params = new URLSearchParams({ directory: '/workspace', page: '1', query: 'search', sourceBranch: 'feat/api' });
expect(runtimeFetchMock).toHaveBeenCalledWith(`/api/gitlab/mrs/list?${params.toString()}`, {
method: 'GET',
headers: { Accept: 'application/json' },
});
});
it('omits sourceBranch when not provided to mrsList', async () => {
const result = {
connected: true,
repo: null,
mrs: [],
page: 1,
hasMore: false,
};
runtimeFetchMock.mockResolvedValueOnce(Response.json(result));
const api = await createAPI();
await expect(api.mrsList('/workspace', { page: 1 })).resolves.toEqual(result);
const params = new URLSearchParams({ directory: '/workspace', page: '1' });
expect(runtimeFetchMock).toHaveBeenCalledWith(`/api/gitlab/mrs/list?${params.toString()}`, {
method: 'GET',
headers: { Accept: 'application/json' },
});
});
it('throws the server error message on {error} payloads', async () => {
runtimeFetchMock.mockResolvedValueOnce(Response.json({ error: 'Not connected to GitLab' }, { status: 401 }));
+4 -1
View File
@@ -129,7 +129,7 @@ export const createWebGitLabAPI = ({ urls }: WebGitLabAPIOptions): GitLabAPI =>
return payload;
},
async mrsList(directory: string, options?: { page?: number; query?: string }): Promise<GitLabMergeRequestsListResult> {
async mrsList(directory: string, options?: { page?: number; query?: string; sourceBranch?: string }): Promise<GitLabMergeRequestsListResult> {
const page = options?.page ?? 1;
const params = new URLSearchParams({
directory,
@@ -138,6 +138,9 @@ export const createWebGitLabAPI = ({ urls }: WebGitLabAPIOptions): GitLabAPI =>
if (options?.query) {
params.set('query', options.query);
}
if (options?.sourceBranch) {
params.set('sourceBranch', options.sourceBranch);
}
const response = await runtimeFetch(
`/api/gitlab/mrs/list?${params.toString()}`,
{ method: 'GET', headers: { Accept: 'application/json' } }