<commit_before><commit_msg>add automated test for instrument import<commit_after>'use strict';
const _ = require('lodash');
const config = require('config');
const should = require('should');
const homedir = require('homedir');

const client = require('./lib/client.js').client;
const nav = require('./lib/nav/navigation.js')(client, config);
const micis = require('./lib/auth/micis.js')(client);

describe('Doing various imports', function() {
    this.timeout(config.defaultTimeout);

    before('initialize', function(done) {
        client.clientReady.then(function boot() {
            if (!micis.loggedOn) {
                micis.logon();
            }
            client.call(done);
        });
    });

    describe('Import subjects', function(done) {
        it ('Should navigate to Subjects > Import Participants from CSV', function(done) {
            nav.micisMenu.clickNested('Import Participants from CSV', done);
        });
        
    });

    describe('Import assessments', function(done) {

    });

    describe('Import instruments', function(done) {
        it ('Should go to asmt and select NITEST (study_id 2319)', function(done) {
            nav.gotoAsmt();
            nav.selectAsmtStudy(2319, done);
        });

        it ('Should navigate to Admin > Import Instruments', function(done) {
            nav.asmtMenu.clickNested('Import Instruments', done);
        });

        it ('Should fill in the inst prefix and upload file', function(done) {
            client.setValue('input#questPrefix', 'QWEQWEQWE')
                .chooseFile('input#file', homedir() + '/Downloads/COINS_TEST/Adverse_Events_Log_formatted.csv')
                .waitForPaginationComplete(done);

        });

        it ('Should see the upload is successful', function(done) {
            client.getText('div#page-container')
                .then(response => {
                    response.should.containEql('Instrument successfully added');
                })
                .call(done);
        });
    });
});

{'fraction_non_alphanumeric': 0.1394658753709199, 'fraction_numerical': 0.003956478733926805, 'mean_word_length': 2.5060658578856154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4967350', 'n_tokens_mistral': 566, 'n_tokens_neox': 531, 'n_words': 121}