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

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

    beforeEach(() => {
        modal = new Login();
    });

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

    it('user can log in', () => {
        modal.login('admin', 'admin');
        waitForSuperdesk();
        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();
        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')).isPresent(), 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);
    });
});<commit_msg>fix: take one test logout<commit_after>const Login = require('./../node_modules/superdesk-core/spec/helpers/pages').login;
const waitForSuperdesk = require('./../node_modules/superdesk-core/spec/helpers/utils').waitForSuperdesk;

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

    beforeEach(() => {
        modal = new Login();
    });

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

    it('user can log in', () => {
        modal.login('admin', 'admin');
        waitForSuperdesk();
        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();
        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();
        expect(modal.btn.isDisplayed()).toBe(true);
    });

    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.20250391236306728, 'fraction_numerical': 0.003129890453834116, 'mean_word_length': 2.694797687861272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '4520792', 'n_tokens_mistral': 961, 'n_tokens_neox': 951, 'n_words': 144}