04dc2b76d7
* master: (181 commits) Fixed adding to list bug Remove unnecessary queries for .atom and .json in Dashboard::ProjectsController#index Fixed modal lists dropdown not updating when list is deleted Fixed remove btn error after creating new issue in list Removed duplicated test Removed Masonry, instead uses groups of data Uses mixins for repeated functions Fixed up specs Props use objects with required & type values Removes labels instead of closing issue when clicking remove button Fixed JS lint errors Fixed issue card spec Added webkit CSS properties Fixed bug with empty state showing after search Fixed users href path being incorrect Fixed bug where 2 un-selected issues would stay on selected tab Fixed DB schema Changed how components are added in objects Added remove button Add optional id property to the issue schema Fixed issue link href Disabled add issues button if no lists exist ...
80 lines
2.2 KiB
JavaScript
80 lines
2.2 KiB
JavaScript
/* global Issuable */
|
|
|
|
require('~/lib/utils/url_utility');
|
|
require('~/issuable');
|
|
|
|
(() => {
|
|
const BASE_URL = '/user/project/issues?scope=all&state=closed';
|
|
const DEFAULT_PARAMS = '&utf8=%E2%9C%93';
|
|
|
|
function updateForm(formValues, form) {
|
|
$.each(formValues, (id, value) => {
|
|
$(`#${id}`, form).val(value);
|
|
});
|
|
}
|
|
|
|
function resetForm(form) {
|
|
$('input[name!="utf8"]', form).each((index, input) => {
|
|
input.setAttribute('value', '');
|
|
});
|
|
}
|
|
|
|
describe('Issuable', () => {
|
|
preloadFixtures('static/issuable_filter.html.raw');
|
|
|
|
beforeEach(() => {
|
|
loadFixtures('static/issuable_filter.html.raw');
|
|
Issuable.init();
|
|
});
|
|
|
|
it('should be defined', () => {
|
|
expect(window.Issuable).toBeDefined();
|
|
});
|
|
|
|
describe('filtering', () => {
|
|
let $filtersForm;
|
|
|
|
beforeEach(() => {
|
|
$filtersForm = $('.js-filter-form');
|
|
loadFixtures('static/issuable_filter.html.raw');
|
|
resetForm($filtersForm);
|
|
});
|
|
|
|
it('should contain only the default parameters', () => {
|
|
spyOn(gl.utils, 'visitUrl');
|
|
|
|
Issuable.filterResults($filtersForm);
|
|
|
|
expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + DEFAULT_PARAMS);
|
|
});
|
|
|
|
it('should filter for the phrase "broken"', () => {
|
|
spyOn(gl.utils, 'visitUrl');
|
|
|
|
updateForm({ search: 'broken' }, $filtersForm);
|
|
Issuable.filterResults($filtersForm);
|
|
const params = `${DEFAULT_PARAMS}&search=broken`;
|
|
|
|
expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params);
|
|
});
|
|
|
|
it('should keep query parameters after modifying filter', () => {
|
|
spyOn(gl.utils, 'visitUrl');
|
|
|
|
// initial filter
|
|
updateForm({ milestone_title: 'v1.0' }, $filtersForm);
|
|
|
|
Issuable.filterResults($filtersForm);
|
|
let params = `${DEFAULT_PARAMS}&milestone_title=v1.0`;
|
|
expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params);
|
|
|
|
// update filter
|
|
updateForm({ label_name: 'Frontend' }, $filtersForm);
|
|
|
|
Issuable.filterResults($filtersForm);
|
|
params = `${DEFAULT_PARAMS}&milestone_title=v1.0&label_name=Frontend`;
|
|
expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params);
|
|
});
|
|
});
|
|
});
|
|
})();
|