<commit_before>'use strict';

//https://github.com/angular/protractor/blob/master/docs/api.md
//GetAttribute() returns "boolean" values and will return either "true" or null

describe('Registration process and similar', function(){

    var HomePage = require('../../app/home/home-page');
    var AuthPage = require('../../app/auth/auth-page');
    var credentials = require('./config/credentials').credentials;
    var home = new HomePage();
    var auth = new AuthPage();
    var start = home.start;
    var login = auth.login;
    var register = auth.register;
    var reset = auth.reset;
    var profile = home.account.profile;
    var homeRegistrationForm = start.registration;
    var signUpRegistrationForm = register.registration;

    it('should be able to see the registration form', function() {
        start.visitPage();

        // we are logged in
        expect(homeRegistrationForm.isDisplayed()).toBe(false);
        auth.doLogout();
        start.visitPage();

        // we are logged out now
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
    });

    it('should fail to register', function() {
        register.visitPage();
        signUpRegistrationForm.register('', '', '', '', '', '');
        expect(signUpRegistrationForm.form.errors.firstnameRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.lastnameRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.emailRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.confirmationRequired.isDisplayed()).toBe(true);

        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '', '');
        expect(signUpRegistrationForm.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.confirmationRequired.isDisplayed()).toBe(true);

        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '12345', '1234');
        expect(signUpRegistrationForm.form.errors.passwordsDontMatch.isDisplayed()).toBe(true);

        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '123', '123');
        expect(signUpRegistrationForm.form.errors.passwordTooShort.isDisplayed()).toBe(true);

        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '<PASSWORD>', '<PASSWORD>');
        expect(signUpRegistrationForm.form.errors.emailInvalid.isDisplayed()).toBe(true);
    });

    it('should be able to register', function() {
        start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
        homeRegistrationForm.register('Test', 'User', '<EMAIL>', credentials.testPassword, credentials.testPassword);
        expect(homeRegistrationForm.form.errors.emailInUse.isPresent()).toBe(false);
        // should have automatically logged us in
        expect(profile.form.isDisplayed()).toBe(true);

        start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(false);
    });

    it('should not be able to register again', function() {
        auth.doLogout();
        start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
        homeRegistrationForm.register('Test', 'User', '<EMAIL>', credentials.testPassword, credentials.testPassword);
        expect(homeRegistrationForm.form.errors.emailInUse.isDisplayed()).toBe(true);
    });

    it('should be able to request password reset', function() {
        login.visitPage();
        login.showPasswordReset();
        expect(login.forgotForm.isDisplayed()).toBe(true);

        login.requestResetPassword('');
        expect(login.form.errors.forgotEmailRequired.isDisplayed()).toBe(true);

        login.requestResetPassword('<EMAIL>');
        expect(login.form.errors.forgotEmailInvalid.isDisplayed()).toBe(true);

        login.requestResetPassword('<EMAIL>');
        expect(home.alert.header.getText()).toBe('Help on the way!');

        reset.visitPage('<EMAIL>','84736f6d-4c70-4a69-8ef8-2444f4ee4646');
        expect(reset.changeForm.isDisplayed()).toBe(true);

        reset.resetPassword('', '');
        expect(reset.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(reset.form.errors.passwordRepeatRequired.isDisplayed()).toBe(true);

        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(reset.form.errors.passwordMinLength.isDisplayed()).toBe(true);

        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(reset.form.errors.passwordRepeatDoesntMatch.isDisplayed()).toBe(true);

        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(home.error.header.getText()).toBe('Error'); // token is not valid
    });

    // reset
    it('should be able to log in as support user', function() {
        login.visitPage();
        login.login('<EMAIL>', credentials.testPassword);
        login.getCurrentUrl().then(function(url) {
            expect(url.substring(url.length - '/account'.length)).toBe('/account');
        });
    });

});
<commit_msg>more fine grained testing.<commit_after>'use strict';

//https://github.com/angular/protractor/blob/master/docs/api.md
//GetAttribute() returns "boolean" values and will return either "true" or null

describe('Registration process and similar', function(){

    var HomePage = require('../../app/home/home-page');
    var AuthPage = require('../../app/auth/auth-page');
    var config = require('./config/config').config;
    var home = new HomePage();
    var auth = new AuthPage();
    var start = home.start;
    var login = auth.login;
    var register = auth.register;
    var reset = auth.reset;
    var profile = home.account.profile;
    var homeRegistrationForm = start.registration;
    var signUpRegistrationForm = register.registration;

    it('should not display the registration form', function() {
        start.visitPage();

        // we are logged in
        expect(homeRegistrationForm.isDisplayed()).toBe(false);
    });

    it('should display the registration form', function() {
        auth.doLogout();
        start.visitPage();

        // we are logged out now
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
    });

    it('should fail to register 1', function() {
        register.visitPage();
        signUpRegistrationForm.register('', '', '', '', '', '');
        expect(signUpRegistrationForm.form.errors.firstnameRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.lastnameRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.emailRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.confirmationRequired.isDisplayed()).toBe(true);
    });

    it('should fail to register 2', function() {
        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '', '');
        expect(signUpRegistrationForm.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(signUpRegistrationForm.form.errors.confirmationRequired.isDisplayed()).toBe(true);
    });

    it('should fail to register 3', function() {
        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '12345', '1234');
        expect(signUpRegistrationForm.form.errors.passwordsDontMatch.isDisplayed()).toBe(true);
    });

    it('should fail to register 4', function() {
        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', '123', '123');
        expect(signUpRegistrationForm.form.errors.passwordTooShort.isDisplayed()).toBe(true);
    });

    it('should fail to register 5', function() {
        signUpRegistrationForm.register('Test', 'User', '<EMAIL>', 'abc123', 'abc123');
        expect(signUpRegistrationForm.form.errors.emailInvalid.isDisplayed()).toBe(true);
    });

    it('should be able to register', function() {
        start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
        homeRegistrationForm.register('Test', 'User', '<EMAIL>', config.testPassword, config.testPassword);
        expect(homeRegistrationForm.form.errors.emailInUse.isPresent()).toBe(false);
        // should have automatically logged us in
        expect(profile.form.isDisplayed()).toBe(true);
    });

    it('should not display the registration form', function() {
            start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(false);
    });

    it('should not be able to register again', function() {
        auth.doLogout();
        start.visitPage();
        expect(homeRegistrationForm.isDisplayed()).toBe(true);
        homeRegistrationForm.register('Test', 'User', '<EMAIL>', config.testPassword, config.testPassword);
        expect(homeRegistrationForm.form.errors.emailInUse.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 1', function() {
        login.visitPage();
        login.showPasswordReset();
        expect(login.forgotForm.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 2', function() {
        login.requestResetPassword('');
        expect(login.form.errors.forgotEmailRequired.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 3', function() {
        login.requestResetPassword('<EMAIL>');
        expect(login.form.errors.forgotEmailInvalid.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 4', function() {
        login.requestResetPassword('<EMAIL>');
        expect(home.alert.header.getText()).toBe('Help on the way!');
    });

    it('should fail to request password reset 5', function() {
        reset.visitPage('<EMAIL>','84736f6d-4c70-4a69-8ef8-2444f4ee4646');
        expect(reset.changeForm.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 6', function() {
        reset.resetPassword('', '');
        expect(reset.form.errors.passwordRequired.isDisplayed()).toBe(true);
        expect(reset.form.errors.passwordRepeatRequired.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 7', function() {
        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(reset.form.errors.passwordMinLength.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 8', function() {
        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(reset.form.errors.passwordRepeatDoesntMatch.isDisplayed()).toBe(true);
    });

    it('should fail to request password reset 9', function() {
        reset.resetPassword('<PASSWORD>', '<PASSWORD>');
        expect(home.error.header.getText()).toBe('Error'); // token is not valid
    });

    // reset
    it('should be able to log in as support user', function() {
        login.visitPage();
        login.login('<EMAIL>', config.testPassword);
        login.getCurrentUrl().then(function(url) {
            expect(url.substring(url.length - '/account'.length)).toBe('/account');
        });
    });

});

{'fraction_non_alphanumeric': 0.15698092839150773, 'fraction_numerical': 0.008636200071968334, 'mean_word_length': 3.597601323407775, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421501', 'n_tokens_mistral': 3085, 'n_tokens_neox': 2992, 'n_words': 523}