<commit_before>import '~/filtered_search/dropdown_utils';
import '~/filtered_search/filtered_search_tokenizer';
import '~/filtered_search/filtered_search_dropdown';
import '~/filtered_search/dropdown_user';

describe('Dropdown User', () => {
  describe('getSearchInput', () => {
    let dropdownUser;

    beforeEach(() => {
      spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
      spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
      spyOn(gl.DropdownUtils, 'getSearchInput').and.callFake(() => {});

      dropdownUser = new gl.DropdownUser(null, null, null, gl.FilteredSearchTokenKeys);
    });

    it('should not return the double quote found in value', () => {
      spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
        lastToken: '"<PASSWORD>',
      });

      expect(dropdownUser.getSearchInput()).toBe('<PASSWORD>');
    });

    it('should not return the single quote found in value', () => {
      spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
        lastToken: '\'<PASSWORD>',
      });

      expect(dropdownUser.getSearchInput()).toBe('<PASSWORD>');
    });
  });

  describe('config AjaxFilter\'s endpoint', () => {
    beforeEach(() => {
      spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
      spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
    });

    it('should return endpoint', () => {
      window.gon = {
        relative_url_root: '',
      };
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
    });

    it('should return endpoint when relative_url_root is undefined', () => {
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
    });

    it('should return endpoint with relative url when available', () => {
      window.gon = {
        relative_url_root: '/gitlab_directory',
      };
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/gitlab_directory/autocomplete/users.json');
    });

    afterEach(() => {
      window.gon = {};
    });
  });
});<commit_msg>Add failing test for #34141<commit_after>import '~/filtered_search/dropdown_utils';
import '~/filtered_search/filtered_search_tokenizer';
import '~/filtered_search/filtered_search_dropdown';
import '~/filtered_search/dropdown_user';

describe('Dropdown User', () => {
  describe('getSearchInput', () => {
    let dropdownUser;

    beforeEach(() => {
      spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
      spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
      spyOn(gl.DropdownUtils, 'getSearchInput').and.callFake(() => {});

      dropdownUser = new gl.DropdownUser(null, null, null, gl.FilteredSearchTokenKeys);
    });

    it('should not return the double quote found in value', () => {
      spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
        lastToken: '"jo<PASSWORD>y <PASSWORD>',
      });

      expect(dropdownUser.getSearchInput()).toBe('<PASSWORD>');
    });

    it('should not return the single quote found in value', () => {
      spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
        lastToken: '\'larry boy',
      });

      expect(dropdownUser.getSearchInput()).toBe('<PASSWORD>');
    });
  });

  describe('config AjaxFilter\'s endpoint', () => {
    beforeEach(() => {
      spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
      spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
    });

    it('should return endpoint', () => {
      window.gon = {
        relative_url_root: '',
      };
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
    });

    it('should return endpoint when relative_url_root is undefined', () => {
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
    });

    it('should return endpoint with relative url when available', () => {
      window.gon = {
        relative_url_root: '/gitlab_directory',
      };
      const dropdown = new gl.DropdownUser();

      expect(dropdown.config.AjaxFilter.endpoint).toBe('/gitlab_directory/autocomplete/users.json');
    });

    afterEach(() => {
      window.gon = {};
    });
  });

  describe('hideCurrentUser', () => {
    const fixtureTemplate = 'issues/issue_list.html.raw';
    preloadFixtures(fixtureTemplate);

    let dropdown;
    let authorFilterDropdownElement;

    beforeEach(() => {
      loadFixtures(fixtureTemplate);
      authorFilterDropdownElement = document.querySelector('#js-dropdown-author');
      const dummyInput = document.createElement('div');
      dropdown = new gl.DropdownUser(null, authorFilterDropdownElement, dummyInput);
    });

    const findCurrentUserElement = () => authorFilterDropdownElement.querySelector('.js-current-user');

    it('hides the current user from dropdown', () => {
      const currentUserElement = findCurrentUserElement();
      expect(currentUserElement).not.toBe(null);

      dropdown.hideCurrentUser();

      expect(currentUserElement.classList).toContain('hidden');
    });

    it('does nothing if no user is logged in', () => {
      const currentUserElement = findCurrentUserElement();
      currentUserElement.parentNode.removeChild(currentUserElement);
      expect(findCurrentUserElement()).toBe(null);

      dropdown.hideCurrentUser();
    });
  });
});
{'fraction_non_alphanumeric': 0.16573033707865167, 'fraction_numerical': 0.0008778089887640449, 'mean_word_length': 3.643031784841076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149449', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1628, 'n_words': 260}