Commit 1e508351 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'winh-fix-transient-loadDiff-failure' into 'master'

Fix racing condition in Ajax call of merge_request_tabs_spec.js

Closes #35294

See merge request gitlab-org/gitlab-ce!16012
parents 5d8d72f1 408b56bd
...@@ -290,15 +290,18 @@ import 'vendor/jquery.scrollTo'; ...@@ -290,15 +290,18 @@ import 'vendor/jquery.scrollTo';
$('body').removeAttr('data-page'); $('body').removeAttr('data-page');
}); });
it('requires an absolute pathname', function () { it('triggers Ajax request to JSON endpoint', function (done) {
spyOn($, 'ajax').and.callFake(function (options) { const url = '/foo/bar/merge_requests/1/diffs';
expect(options.url).toEqual('/foo/bar/merge_requests/1/diffs.json'); spyOn(this.class, 'ajaxGet').and.callFake((options) => {
expect(options.url).toEqual(`${url}.json`);
done();
}); });
this.class.loadDiff('/foo/bar/merge_requests/1/diffs'); this.class.loadDiff(url);
}); });
it('triggers scroll event when diff already loaded', function () { it('triggers scroll event when diff already loaded', function (done) {
spyOn(this.class, 'ajaxGet').and.callFake(() => done.fail());
spyOn(document, 'dispatchEvent'); spyOn(document, 'dispatchEvent');
this.class.diffsLoaded = true; this.class.diffsLoaded = true;
...@@ -307,6 +310,7 @@ import 'vendor/jquery.scrollTo'; ...@@ -307,6 +310,7 @@ import 'vendor/jquery.scrollTo';
expect( expect(
document.dispatchEvent, document.dispatchEvent,
).toHaveBeenCalledWith(new CustomEvent('scroll')); ).toHaveBeenCalledWith(new CustomEvent('scroll'));
done();
}); });
describe('with inline diff', () => { describe('with inline diff', () => {
......
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