Commit 4ba34c45 authored by Nathan Friend's avatar Nathan Friend

Merge branch '250625-use-sorted-param-for-startup-call-lookup' into 'master'

Make startup.js to account for the param orders

See merge request gitlab-org/gitlab!42673
parents 5f5fe6f6 4b83d88f
......@@ -7,7 +7,7 @@ const removeGitLabUrl = url => url.replace(gon.gitlab_url, '');
const getFullUrl = req => {
const url = removeGitLabUrl(req.url);
return mergeUrlParams(req.params || {}, url);
return mergeUrlParams(req.params || {}, url, { sort: true });
};
const handleStartupCall = async ({ fetchCall }, req) => {
......
......@@ -111,21 +111,44 @@ describe('setupAxiosStartupCalls', () => {
});
});
it('removes GitLab Base URL from startup call', async () => {
const oldGon = window.gon;
window.gon = { gitlab_url: 'https://example.org/gitlab' };
window.gl.startup_calls = {
'/startup': {
fetchCall: mockFetchCall(200),
},
};
setupAxiosStartupCalls(axios);
describe('startup call', () => {
let oldGon;
beforeEach(() => {
oldGon = window.gon;
window.gon = { gitlab_url: 'https://example.org/gitlab' };
});
afterEach(() => {
window.gon = oldGon;
});
const { data } = await axios.get('https://example.org/gitlab/startup');
it('removes GitLab Base URL from startup call', async () => {
window.gl.startup_calls = {
'/startup': {
fetchCall: mockFetchCall(200),
},
};
setupAxiosStartupCalls(axios);
expect(data).toEqual(STARTUP_JS_RESPONSE);
const { data } = await axios.get('https://example.org/gitlab/startup');
window.gon = oldGon;
expect(data).toEqual(STARTUP_JS_RESPONSE);
});
it('sorts the params in the requested API url', async () => {
window.gl.startup_calls = {
'/startup?alpha=true&bravo=true': {
fetchCall: mockFetchCall(200),
},
};
setupAxiosStartupCalls(axios);
// Use a full url instead of passing options = { params: { ... } } to axios.get
// to ensure the params are listed in the specified order.
const { data } = await axios.get('https://example.org/gitlab/startup?bravo=true&alpha=true');
expect(data).toEqual(STARTUP_JS_RESPONSE);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment