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,10 +111,19 @@ describe('setupAxiosStartupCalls', () => {
});
});
it('removes GitLab Base URL from startup call', async () => {
const oldGon = window.gon;
describe('startup call', () => {
let oldGon;
beforeEach(() => {
oldGon = window.gon;
window.gon = { gitlab_url: 'https://example.org/gitlab' };
});
afterEach(() => {
window.gon = oldGon;
});
it('removes GitLab Base URL from startup call', async () => {
window.gl.startup_calls = {
'/startup': {
fetchCall: mockFetchCall(200),
......@@ -125,7 +134,21 @@ describe('setupAxiosStartupCalls', () => {
const { data } = await axios.get('https://example.org/gitlab/startup');
expect(data).toEqual(STARTUP_JS_RESPONSE);
});
window.gon = oldGon;
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