<commit_before>'use strict';
describe('Suite: angular-typeaheadjs e2e local tests', function () {

//    browser.manage().window().setSize(600, 800);
//    browser.manage().window().setPosition(600, 0);
    beforeEach(function () {
        browser.get('/tests/local/test.html');
    });

    var UseCase = function(number) {
        var selectorUseCase = 'div.usecase' + number,
            selectorPath = selectorUseCase + ' span.twitter-typeahead',
            selectorInput = selectorPath + ' > input[id="usecase' + number + '"].tt-input',
            selectorHint = selectorPath + ' > input.tt-hint';

        this.input = element(by.css(selectorInput)),
        this.hint = element(by.css(selectorHint));
        this.dropdown = element(by.css(selectorPath + ' > div.tt-menu'));
        this.triggerEvents = element(by.css(selectorUseCase + ' span.trigger'));

        this.bodyClick = function() {
            //console.log(element(by.tagName('body')));
            element(by.tagName('body')).click();
        };
        this.inputClick = function() {
            this.input.click();
        };
        this.inputExists = function() {
            expect(browser.isElementPresent(this.input)).toBeTruthy();
        };
        this.hintExists = function() {
            expect(browser.isElementPresent(this.hint)).toBeTruthy();
        };
        this.dropdownExists = function() {
            expect(browser.isElementPresent(this.dropdown)).toBeTruthy();
        };
        this.inputSendKeys = function(keys) {
            this.input.sendKeys(keys);
        };
        this.inputValueIs = function (value){
            expect(this.input.getAttribute('value')).toBe(value);

        };
        this.hintValueIs = function (value){
            expect(this.hint.getAttribute('value')).toBe(value);

        };
        this.triggerEventsValueIs = function (value){
            expect(this.triggerEvents.getText()).toBe(value);
        };
        this.numberOfSuggestionsIs = function (number){
            var suggestions = element.all(by.css(selectorPath + ' .tt-suggestion'));
            expect(suggestions.count()).toBe(number);
        };
        this.firstSuggestionClick = function (){
            //element(by.css(selectorUseCase + ' .tt-suggestion:first-child')).click();
            element.all(by.css(selectorPath + ' .tt-suggestion')).first().click();
        };
    };

    xdescribe(':use case 1: prefetch / remote / ', function () {
        var useCase;

        beforeEach(function () {
            useCase = new UseCase(1);
        });

//        xit('should have a title', function () {
//            expect(browser.getTitle()).toBe('Test e2e angular-typeaheadjs');
//        });
        it('should have an input with typeahead applied', function () {
            browser.sleep(150).then(function(){
                useCase.inputExists();
            });

        });
        it('should open dropdown with 3 suggestions and correct hint when typing "uni"', function () {
            useCase.inputExists();
            useCase.hintExists();
            useCase.inputSendKeys('uni');
            useCase.dropdownExists();
            useCase.hintValueIs('united Arab Emirates');
            useCase.numberOfSuggestionsIs(3);
        });
        it('should open dropdown with 1 suggestion and correct hint when typing "uto"', function () {
            useCase.inputExists();
            useCase.hintExists();
            useCase.inputSendKeys('uto');
            browser.sleep(150).then(function(){
                useCase.dropdownExists();
                useCase.hintValueIs('utopia');
                useCase.numberOfSuggestionsIs(1);
            });

        });
    });
    describe(':use case 2: prefetch / remote / trigger all events on scope', function () {
        var useCase;
        beforeEach(function () {
            useCase = new UseCase(2);
        });
        it('should trigger events when onfocus and and loose focus', function () {
            useCase.inputExists();
            useCase.inputClick();
            if (process.env.BROWSER !== 'safari' ) {
                useCase.inputSendKeys(protractor.Key.TAB);
            } else {
                useCase.bodyClick();
            }
            browser.sleep(500).then(function(){
                useCase.triggerEventsValueIs('[1,1,1,1,0,0,0,0,0,0,0,0]');
            });

        });
        xit('should trigger events when typing "uni"', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('500').then(function(){
                useCase.triggerEventsValueIs('[1,0,1,0,0,2,0,0,0,1,0,1]');
            });

        });
        it('should trigger events when typing "uni" and autocomplete', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('250');
            useCase.inputSendKeys(protractor.Key.TAB);
            browser.sleep('250');
            useCase.triggerEventsValueIs('[1,0,1,0,0,4,0,1,0,2,0,2]');

        });
        xit('should trigger events when typing "uni" and select suggestion (with Enter)', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            //browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            useCase.inputSendKeys(protractor.Key.ENTER);
            //browser.sleep('150');
            useCase.triggerEventsValueIs('[1,0,1,1,0,2,1,0,1,1,0,1]');

        });
        it('should trigger events when typing "uni" and select suggestion (with Enter) and loose focus', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.ENTER);
            browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.TAB);
            browser.sleep('500').then(function() {
                useCase.triggerEventsValueIs('[1,1,1,1,1,2,1,0,1,1,0,1]');
            });
        });
        xit('should trigger events when typing "uni" and scroll suggestions', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            //browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            //browser.sleep('10');
            useCase.inputSendKeys(protractor.Key.DOWN);
            //browser.sleep('10');
            useCase.inputSendKeys(protractor.Key.UP);
            //browser.sleep('10');
            useCase.triggerEventsValueIs('[1,0,1,0,0,2,0,0,3,1,0,1]');<commit_msg>Correct e2e tests - experiment browser safari<commit_after>'use strict';
describe('Suite: angular-typeaheadjs e2e local tests', function () {

//    browser.manage().window().setSize(600, 800);
//    browser.manage().window().setPosition(600, 0);
    beforeEach(function () {
        browser.get('/tests/local/test.html');
    });

    var UseCase = function(number) {
        var selectorUseCase = 'div.usecase' + number,
            selectorPath = selectorUseCase + ' span.twitter-typeahead',
            selectorInput = selectorPath + ' > input[id="usecase' + number + '"].tt-input',
            selectorHint = selectorPath + ' > input.tt-hint';

        this.input = element(by.css(selectorInput)),
        this.hint = element(by.css(selectorHint));
        this.dropdown = element(by.css(selectorPath + ' > div.tt-menu'));
        this.triggerEvents = element(by.css(selectorUseCase + ' span.trigger'));

        this.bodyClick = function() {
            //console.log(element(by.tagName('body')));
            element(by.tagName('body')).click();
        };
        this.inputClick = function() {
            this.input.click();
        };
        this.inputExists = function() {
            expect(browser.isElementPresent(this.input)).toBeTruthy();
        };
        this.hintExists = function() {
            expect(browser.isElementPresent(this.hint)).toBeTruthy();
        };
        this.dropdownExists = function() {
            expect(browser.isElementPresent(this.dropdown)).toBeTruthy();
        };
        this.inputSendKeys = function(keys) {
            this.input.sendKeys(keys);
        };
        this.inputValueIs = function (value){
            expect(this.input.getAttribute('value')).toBe(value);

        };
        this.hintValueIs = function (value){
            expect(this.hint.getAttribute('value')).toBe(value);

        };
        this.triggerEventsValueIs = function (value){
            expect(this.triggerEvents.getText()).toBe(value);
        };
        this.numberOfSuggestionsIs = function (number){
            var suggestions = element.all(by.css(selectorPath + ' .tt-suggestion'));
            expect(suggestions.count()).toBe(number);
        };
        this.firstSuggestionClick = function (){
            //element(by.css(selectorUseCase + ' .tt-suggestion:first-child')).click();
            element.all(by.css(selectorPath + ' .tt-suggestion')).first().click();
        };
    };

    xdescribe(':use case 1: prefetch / remote / ', function () {
        var useCase;

        beforeEach(function () {
            useCase = new UseCase(1);
        });

//        xit('should have a title', function () {
//            expect(browser.getTitle()).toBe('Test e2e angular-typeaheadjs');
//        });
        it('should have an input with typeahead applied', function () {
            browser.sleep(150).then(function(){
                useCase.inputExists();
            });

        });
        it('should open dropdown with 3 suggestions and correct hint when typing "uni"', function () {
            useCase.inputExists();
            useCase.hintExists();
            useCase.inputSendKeys('uni');
            useCase.dropdownExists();
            useCase.hintValueIs('united Arab Emirates');
            useCase.numberOfSuggestionsIs(3);
        });
        it('should open dropdown with 1 suggestion and correct hint when typing "uto"', function () {
            useCase.inputExists();
            useCase.hintExists();
            useCase.inputSendKeys('uto');
            browser.sleep(150).then(function(){
                useCase.dropdownExists();
                useCase.hintValueIs('utopia');
                useCase.numberOfSuggestionsIs(1);
            });

        });
    });
    describe(':use case 2: prefetch / remote / trigger all events on scope', function () {
        var useCase;
        beforeEach(function () {
            useCase = new UseCase(2);
        });
        it('should trigger events when onfocus and and loose focus', function () {
            useCase.inputExists();
            useCase.inputClick();
            if (process.env.BROWSER !== 'safari' ) {
                useCase.inputSendKeys(protractor.Key.TAB);
            } else {
                useCase.bodyClick();
            }
            browser.sleep(500).then(function(){
                useCase.triggerEventsValueIs('[1,1,1,1,0,0,0,0,0,0,0,0]');
            });

        });
        xit('should trigger events when typing "uni"', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('500').then(function(){
                useCase.triggerEventsValueIs('[1,0,1,0,0,2,0,0,0,1,0,1]');
            });

        });
        it('should trigger events when typing "uni" and autocomplete', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('250');
            useCase.inputSendKeys(protractor.Key.TAB);
            browser.sleep('250');
            useCase.triggerEventsValueIs('[1,0,1,0,0,4,0,1,0,2,0,2]');

        });
        xit('should trigger events when typing "uni" and select suggestion (with Enter)', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            //browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            useCase.inputSendKeys(protractor.Key.ENTER);
            //browser.sleep('150');
            useCase.triggerEventsValueIs('[1,0,1,1,0,2,1,0,1,1,0,1]');

        });
        it('should trigger events when typing "uni" and select suggestion (with Enter) and loose focus', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.ENTER);
            browser.sleep('150');
            if (process.env.BROWSER !== 'safari' ) {
                useCase.inputSendKeys(protractor.Key.TAB);
            } else {
                useCase.bodyClick();
            }
            browser.sleep('500').then(function() {
                useCase.triggerEventsValueIs('[1,1,1,1,1,2,1,0,1,1,0,1]');
            });
        });
        xit('should trigger events when typing "uni" and scroll suggestions', function () {
            useCase.inputExists();
            useCase.inputSendKeys('uni');
            //browser.sleep('150');
            useCase.inputSendKeys(protractor.Key.DOWN);
            //browser.sleep('10');
            useCase.inputSendKeys(protractor.Key.DOWN);
            //browser.sleep('10');
            useCase.inputSendKeys(protractor.Key.UP);
            //browser.sleep('10');
            useCase.triggerEventsValueIs('[1,0,1,0,0,2,0,0,3,1,0,1]');
{'fraction_non_alphanumeric': 0.15014436958614052, 'fraction_numerical': 0.020359813430073294, 'mean_word_length': 2.076993166287016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6683848', 'n_tokens_mistral': 3889, 'n_tokens_neox': 3696, 'n_words': 579}