<commit_before>var Login = require('./../node_modules/superdesk-core/spec/helpers/pages').login;
var waitForSuperdesk = require('./../node_modules/superdesk-core/spec/helpers/utils').waitForSuperdesk;
var until = protractor.ExpectedConditions;

describe('login', () => {
    var modal;

    beforeEach(() => {
        browser.ignoreSynchronization = true;
        modal = new Login();
    });

    it('form renders modal on load', () => {
        expect(modal.btn.isDisplayed()).toBe(true);
        browser.ignoreSynchronization = false;
    });

    it('user can log in', () => {
        modal.login('admin', 'admin');

        waitForSuperdesk().then(() => {
            browser.ignoreSynchronization = false;
            expect(modal.btn.isDisplayed()).toBe(false);
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + '/#/liveblog');
            element(by.css('button.current-user')).click();
            expect(
                element(by.css('.user-info .displayname'))
                    .waitReady()
                    .then((elem) => elem.getText())
            ).toBe('admin');
        });
    });

    it('user can log out', () => {
        modal.login('admin', 'admin');

        waitForSuperdesk().then(() => {
            browser.ignoreSynchronization = false;
            element(by.css('button.current-user')).click();

            // wait for sidebar animation to finish
            browser.wait(() => element(by.buttonText('SIGN OUT')).isDisplayed(), 200);

            element(by.buttonText('SIGN OUT')).click();

            browser.wait(() => element(by.id('login-btn')), 5000);
        });
    });

    it('unknown user can\'t log in', () => {
        modal.login('foo', 'bar');
        expect(modal.btn.isDisplayed()).toBe(true);
        expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + '/#/liveblog');
        browser.wait(until.presenceOf(modal.error.isDisplayed()), 5000, 'Element taking too long to appear in the DOM');
        expect(modal.error.isDisplayed()).toBe(true);
    });
});

<commit_msg>Reverted commit: 5<PASSWORD>560431611e31d2f4c301ce69b253ed6<commit_after>var Login = require('./../node_modules/superdesk-core/spec/helpers/pages').login;
var waitForSuperdesk = require('./../node_modules/superdesk-core/spec/helpers/utils').waitForSuperdesk;

describe('login', () => {
    var modal;

    beforeEach(() => {
        browser.ignoreSynchronization = true;
        modal = new Login();
    });

    it('form renders modal on load', () => {
        expect(modal.btn.isDisplayed()).toBe(true);
        browser.ignoreSynchronization = false;
    });

    it('user can log in', () => {
        modal.login('admin', 'admin');

        waitForSuperdesk().then(() => {
            browser.ignoreSynchronization = false;
            expect(modal.btn.isDisplayed()).toBe(false);
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + '/#/liveblog');
            element(by.css('button.current-user')).click();
            expect(
                element(by.css('.user-info .displayname'))
                    .waitReady()
                    .then((elem) => elem.getText())
            ).toBe('admin');
        });
    });

    it('user can log out', () => {
        modal.login('admin', 'admin');

        waitForSuperdesk().then(() => {
            browser.ignoreSynchronization = false;
            element(by.css('button.current-user')).click();

            // wait for sidebar animation to finish
            browser.wait(() => element(by.buttonText('SIGN OUT')).isDisplayed(), 200);

            element(by.buttonText('SIGN OUT')).click();

            browser.wait(() => element(by.id('login-btn')), 5000);
        });
    });

    it('unknown user can\'t log in', () => {
        modal.login('foo', 'bar');
        expect(modal.btn.isDisplayed()).toBe(true);
        expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + '/#/liveblog');
        expect(modal.error.isDisplayed()).toBe(true);
    });
});


{'fraction_non_alphanumeric': 0.1832998996990973, 'fraction_numerical': 0.010280842527582748, 'mean_word_length': 2.4064901793339026, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 26, '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': '3187387', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1136, 'n_words': 174}