<commit_before>'use strict';

let libUser = require('elyoos-server-lib').user();
let requestHandler = require('elyoos-server-test-util').requestHandler;
let users = require('elyoos-server-test-util').user;
let db = require('elyoos-server-test-util').db;
let moment = require('moment');
let should = require('chai').should();

describe('Integration Tests for the privacy settings', function () {

    beforeEach(function () {

        libUser.removeFromCache('<EMAIL>');
        return db.clearDatabase().then(function () {
            let commands = [], startTime = Math.floor(moment.utc().valueOf() / 1000);
            commands.push(db.cypher().create("(:User {email: '<EMAIL>', password: <PASSWORD>', name: 'user Meier', userId: '1'})").end().getCommand());
            commands.push(db.cypher().create("(:User {email: '<EMAIL>', password: <PASSWORD>', name: 'user Meier2', userId: '2'})").end().getCommand());
            commands.push(db.cypher().create("(:User {email: '<EMAIL>', password: <PASSWORD>', name: 'user Meier3', userId: '3'})").end().getCommand());
            commands.push(db.cypher().create("(:User {email: '<EMAIL>', password: <PASSWORD>821opXpMgKAm', name: 'user Meier4', userId: '4'})").end().getCommand());

            //Add Contacts
            commands.push(db.cypher().match("(u:User {userId: '1'}), (u2:User {userId: '2'})")
                .create("(u)-[:IS_CONTACT {type: 'Freund', contactAdded: {contactAdded}}]->(u2)")
                .end({contactAdded: startTime - 86401}).getCommand());
            commands.push(db.cypher().match("(u:User {userId: '1'}), (u2:User {userId: '3'})")
                .create("(u)-[:IS_CONTACT {type: 'Freund', contactAdded: {contactAdded}}]->(u2)")
                .end({contactAdded: startTime - 86401}).getCommand());
            commands.push(db.cypher().match("(u:User {userId: '1'}), (u2:User {userId: '4'})")
                .create("(u)-[:IS_CONTACT {type: 'Familie', contactAdded: {contactAdded}}]->(u2)")
                .end({contactAdded: startTime - 86401}).getCommand());

            //Add Blogs for privacy test
            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:WRITTEN]->(blog:Blog:PinwallElement {pageId: '1', visible: {visibility}})")
                .end({visibility: ['Freund', 'Familie']}).getCommand());
            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:WRITTEN]->(blog:Blog:PinwallElement {pageId: '2', visible: {visibility}})")
                .end({visibility: ['Familie']}).getCommand());
            //Visible to the public
            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:WRITTEN]->(blog:Blog:PinwallElement {pageId: '3'})").end().getCommand());

            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:HAS_PRIVACY {type: 'Freund'}]->(:Privacy {profile: true, profileData: true, contacts: false, image: true, pinwall: true})")
                .end().getCommand());
            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:HAS_PRIVACY {type: 'Familie'}]->(:Privacy {profile: true, profileData: true, contacts: true, image: true, pinwall: true})")
                .end().getCommand());
            commands.push(db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:HAS_PRIVACY {type: 'Bekannter'}]->(:Privacy {profile: true, profileData: false, contacts: false, image: true, pinwall: false})")
                .end().getCommand());
            return db.cypher().match("(u:User {userId: '1'})")
                .create("(u)-[:HAS_PRIVACY_NO_CONTACT]->(:Privacy {profile: false, profileData: false, contacts: false, image: false, pinwall: false})")
                .end().send(commands);
        });
    });

    afterEach(function () {
        return requestHandler.logout();
    });

    it('Get the privacy settings of the user- Return a 200', function () {
        return requestHandler.login(users.validUser).then(function (agent) {
            return requestHandler.get('/api/user/settings/privacy', agent);
        }).then(function (res) {
            res.status.should.equal(200);
            res.body.normal.length.should.equal(3);
            res.body.normal[0].type.should.equal('Bekannter');
            res.body.normal[0].profileVisible.should.be.true;
            res.body.normal[0].profileDataVisible.should.be.false;
            res.body.normal[0].imageVisible.should.be.true;
            res.body.normal[0].contactsVisible.should.be.false;
            res.body.normal[0].pinwallVisible.should.be.false;
            res.body.normal[1].type.should.equal('Familie');
            res.body.normal[1].profileVisible.should.be.true;
            res.body.normal[1].profileDataVisible.should.be.true;
            res.body.normal[1].imageVisible.should.be.true;<commit_msg>Using dsl language for creating test data.<commit_after>'use strict';

let libUser = require('elyoos-server-lib').user();
let requestHandler = require('elyoos-server-test-util').requestHandler;
let users = require('elyoos-server-test-util').user;
let db = require('elyoos-server-test-util').db;
let dbDsl = require('elyoos-server-test-util').dbDSL;
let moment = require('moment');
let should = require('chai').should();

describe('Integration Tests for the privacy settings', function () {

    beforeEach(function () {

        libUser.removeFromCache('<EMAIL>');
        return dbDsl.init(4).then(function () {
            let startTime = Math.floor(moment.utc().valueOf() / 1000);
            dbDsl.createPrivacyNoContact(['1'], {profile: false, image: false, profileData: false, contacts: false, pinwall: false});
            dbDsl.createPrivacy(['1'], 'Freund', {profile: true, image: true, profileData: true, contacts: false, pinwall: true});
            dbDsl.createPrivacy(['1'], 'Familie', {profile: true, image: true, profileData: true, contacts: true, pinwall: true});
            dbDsl.createPrivacy(['1'], 'Bekannter', {profile: true, image: true, profileData: false, contacts: false, pinwall: false});

            dbDsl.createBlog('1', {blogWriterUserId: '1', language: ['de'], topic: ['health'], visible: ['Freund', 'Familie'], created: 450});
            dbDsl.createBlog('2', {blogWriterUserId: '1', language: ['de'], topic: ['health'], visible: ['Familie'], created: 450});
            dbDsl.createBlog('3', {blogWriterUserId: '1', language: ['de'], topic: ['health'], created: 450});

            dbDsl.createContactConnection('1', '2', 'Freund', startTime - 86401);
            dbDsl.createContactConnection('1', '3', 'Freund', startTime - 86401);
            dbDsl.createContactConnection('1', '4', 'Familie', startTime - 86401);
            return dbDsl.sendToDb();
        });
    });

    afterEach(function () {
        return requestHandler.logout();
    });

    it('Get the privacy settings of the user- Return a 200', function () {
        return requestHandler.login(users.validUser).then(function (agent) {
            return requestHandler.get('/api/user/settings/privacy', agent);
        }).then(function (res) {
            res.status.should.equal(200);
            res.body.normal.length.should.equal(3);
            res.body.normal[0].type.should.equal('Bekannter');
            res.body.normal[0].profileVisible.should.be.true;
            res.body.normal[0].profileDataVisible.should.be.false;
            res.body.normal[0].imageVisible.should.be.true;
            res.body.normal[0].contactsVisible.should.be.false;
            res.body.normal[0].pinwallVisible.should.be.false;
            res.body.normal[1].type.should.equal('Familie');
            res.body.normal[1].profileVisible.should.be.true;
            res.body.normal[1].profileDataVisible.should.be.true;
            res.body.normal[1].imageVisible.should.be.true;
{'fraction_non_alphanumeric': 0.1923611989376502, 'fraction_numerical': 0.016441128114329077, 'mean_word_length': 3.0741885625966, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '6344785', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2448, 'n_words': 430}