Commit be8c4af8 authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Clement Ho

Filter groups and projects dropdowns of search page on backend

parent 5392568e
......@@ -15,6 +15,7 @@ export default class Search {
$groupDropdown.glDropdown({
selectable: true,
filterable: true,
filterRemote: true,
fieldName: 'group_id',
search: {
fields: ['full_name'],
......@@ -43,6 +44,7 @@ export default class Search {
$projectDropdown.glDropdown({
selectable: true,
filterable: true,
filterRemote: true,
fieldName: 'project_id',
search: {
fields: ['name'],
......
---
title: Filter groups and projects dropdowns of search page on backend
merge_request: 16336
author:
type: fixed
require 'spec_helper'
describe SearchController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
render_views
before(:all) do
clean_frontend_fixtures('search/')
end
it 'search/show.html.raw' do |example|
get :show
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
import Api from '~/api';
import Search from '~/pages/search/show/search';
describe('Search', () => {
const fixturePath = 'search/show.html.raw';
const searchTerm = 'some search';
const fillDropdownInput = (dropdownSelector) => {
const dropdownElement = document.querySelector(dropdownSelector).parentNode;
const inputElement = dropdownElement.querySelector('.dropdown-input-field');
inputElement.value = searchTerm;
return inputElement;
};
preloadFixtures(fixturePath);
beforeEach(() => {
loadFixtures(fixturePath);
new Search(); // eslint-disable-line no-new
});
it('requests groups from backend when filtering', (done) => {
spyOn(Api, 'groups').and.callFake((term) => {
expect(term).toBe(searchTerm);
done();
});
const inputElement = fillDropdownInput('.js-search-group-dropdown');
$(inputElement).trigger('input');
});
it('requests projects from backend when filtering', (done) => {
spyOn(Api, 'projects').and.callFake((term) => {
expect(term).toBe(searchTerm);
done();
});
const inputElement = fillDropdownInput('.js-search-project-dropdown');
$(inputElement).trigger('input');
});
});
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