<commit_before>
'use strict';

var openUrl = require('./helpers/utils').open,
    workspace = require('./helpers/pages').workspace,
    content = require('./helpers/pages').content;

describe('Search', function() {

    beforeEach(function(done) {openUrl('/#/workspace/content').then(done);});

    it('can search by search field', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var searchTextbox = element(by.id('search-input'));
        searchTextbox.clear();
        searchTextbox.sendKeys('<PASSWORD>');
        var focused = browser.driver.switchTo().activeElement().getAttribute('id');
        expect(searchTextbox.getAttribute('id')).toEqual(focused);

        element(by.id('search-button')).click();
        content.setListView();
        expect(element.all(by.repeater('items._items')).count()).toBe(1);
    });

    it('can search by search within field', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var filterPanelButton = element(by.css('.fitler-trigger'));
        filterPanelButton.click();

        var searchTextbox = element(by.id('search_within'));
        searchTextbox.clear();
        searchTextbox.sendKeys('<PASSWORD>');
        element(by.id('search_within_button')).click();
        content.setListView();
        expect(element.all(by.repeater('items._items')).count()).toBe(1);
        expect(element.all(by.repeater('parameter in tags.selectedKeywords')).count()).toBe(1);
    });

    it('can filter by state', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var filterPanelButton = element(by.css('.fitler-trigger'));
        filterPanelButton.click();

        element.all(by.repeater('(key,value) in aggregations.state'))
        .first().element(by.css('.sd-checkbox')).click();
        content.setListView();

        expect(element.all(by.repeater('items._items')).count()).toBe(2);
        expect(element.all(by.repeater('(type,keys) in tags.selectedFacets')).count()).toBe(1);
    });
});<commit_msg>feat(e2e test): Added e2e test for subject codes<commit_after>
'use strict';

var openUrl = require('./helpers/utils').open,
    workspace = require('./helpers/pages').workspace,
    content = require('./helpers/pages').content;

describe('Search', function() {

    beforeEach(function(done) {openUrl('/#/workspace/content').then(done);});

    it('can search by search field', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var searchTextbox = element(by.id('search-input'));
        searchTextbox.clear();
        searchTextbox.sendKeys('item3');
        var focused = browser.driver.switchTo().activeElement().getAttribute('id');
        expect(searchTextbox.getAttribute('id')).toEqual(focused);

        element(by.id('search-button')).click();
        content.setListView();
        expect(element.all(by.repeater('items._items')).count()).toBe(1);
    });

    it('can search by search within field', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var filterPanelButton = element(by.css('.fitler-trigger'));
        filterPanelButton.click();

        var searchTextbox = element(by.id('search_within'));
        searchTextbox.clear();
        searchTextbox.sendKeys('item3');
        element(by.id('search_within_button')).click();
        content.setListView();
        expect(element.all(by.repeater('items._items')).count()).toBe(1);
        expect(element.all(by.repeater('parameter in tags.selectedKeywords')).count()).toBe(1);
    });
    
    it('can search by subject codes field', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);
        
        var filterPanelButton = element(by.css('.fitler-trigger'));
        var subject = element.all(by.css('.dropdown-nested')).first();
        var subjectToggle = subject.element(by.css('.dropdown-toggle'));
        
        filterPanelButton.click().then(
            function(){
                return element.all(by.css('[ng-click="toggleModule()"]')).first().click();
            }).then(
            function(){             
                return subjectToggle.click();
            }).then(
            function () {
                return subject.all(by.css('.nested-toggle')).first().click();
            }).then(
            function () {
                return subject.all(by.repeater('term in activeTree')).first().click();
            }).then(function () {
                expect(element.all(by.repeater('item in items._items')).count()).toBe(0);
                expect(element.all(by.repeater('parameter in tags.selectedParameters')).count()).toBe(1);
                expect(element.all(by.repeater('t in item[field]')).count()).toBe(1);
            });
    });

    it('can filter by state', function() {
        workspace.switchToDesk('SPORTS DESK').then(content.setListView);
        expect(element.all(by.repeater('items._items')).count()).toBe(2);

        var filterPanelButton = element(by.css('.fitler-trigger'));
        filterPanelButton.click();

        element.all(by.repeater('(key,value) in aggregations.state'))
        .first().element(by.css('.sd-checkbox')).click();
        content.setListView();

        expect(element.all(by.repeater('items._items')).count()).toBe(2);
        expect(element.all(by.repeater('(type,keys) in tags.selectedFacets')).count()).toBe(1);
    });
});
{'fraction_non_alphanumeric': 0.18469834850016853, 'fraction_numerical': 0.004044489383215369, 'mean_word_length': 3.2062367115520907, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4861518', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1718, 'n_words': 216}