<commit_before>/**
 * As of v1.9.9, phantomJS does not correctly support sending Blobs in XHRs,
 * and the FormData API is extremely limited (i.e. does not support anything
 * other than "append"). We fake the chunk request to get around this by
 * wrapping XHR.prototype.send.
 */
/* globals girderTest, describe, it, runs, expect, waitsFor, spyOn */

/* used for adjusting minimum upload size */
var minUploadSize;


/* Set the minimum chunk size in the server settings, the upload handler, and
 *  the S3 asset store handler.
 * :param minSize: the new minimum size.  If null, revert to the original
 *                 minimums.
 */
function _setMinimumChunkSize(minSize) {
    var uploadChunkSize, settingSize;
    if (!minUploadSize) {
        minUploadSize = {UPLOAD_CHUNK_SIZE: girder.UPLOAD_CHUNK_SIZE};
        var resp = girder.restRequest({
            path: 'system/setting',
            type: 'GET',
            data: {key: 'core.upload_minimum_chunk_size'},
            async: false
        });
        minUploadSize.setting = resp.responseText;
    }
    if (!minSize) {
        uploadChunkSize = minUploadSize.UPLOAD_CHUNK_SIZE;
        settingSize = minUploadSize.setting;
    } else {
        uploadChunkSize = minSize;
        settingSize = minSize;
    }
    girder.UPLOAD_CHUNK_SIZE = uploadChunkSize;
    girder.restRequest({
        path: 'system/setting',
        type: 'PUT',
        data: {key: 'core.upload_minimum_chunk_size', value: settingSize},
        async: false
    });
}

/**
 * Intercept window.location.assign calls so we can test the behavior of,
 * e.g. download directives that occur from js.
 */
(function () {
    window.location.assign = function (url) {
        girderTest._redirect = url;
    };
} (window.location.assign));

/**
 * Start the girder backbone app.
 */
girderTest.startApp();

describe('Create a data hierarchy', function () {
    it('register a user',
        girderTest.createUser('johndoe',
                              '<EMAIL>',
                              'John',
                              'Doe',
                              'password!'));

    it('create a folder', function () {
        runs(function () {
            expect($('#g-user-action-menu.open').length).toBe(0);
            $('.g-user-text>a:first').click();
        });
        girderTest.waitForLoad();
        runs(function () {
            expect($('#g-user-action-menu.open').length).toBe(1);
            $('a.g-my-folders').click();
        });
        girderTest.waitForLoad();

        waitsFor(function () {
            return $('li.g-folder-list-entry').length > 0;
        }, 'my folders list to display');

        runs(function () {
            expect($('a.g-folder-list-link:first').text()).toBe('Private');
            expect($('.g-folder-privacy:first').text()).toBe('Private');<commit_msg>Add client-side testing for top level folder counts<commit_after>/**
 * As of v1.9.9, phantomJS does not correctly support sending Blobs in XHRs,
 * and the FormData API is extremely limited (i.e. does not support anything
 * other than "append"). We fake the chunk request to get around this by
 * wrapping XHR.prototype.send.
 */
/* globals girderTest, describe, it, runs, expect, waitsFor, spyOn */

/* used for adjusting minimum upload size */
var minUploadSize;


/* Set the minimum chunk size in the server settings, the upload handler, and
 *  the S3 asset store handler.
 * :param minSize: the new minimum size.  If null, revert to the original
 *                 minimums.
 */
function _setMinimumChunkSize(minSize) {
    var uploadChunkSize, settingSize;
    if (!minUploadSize) {
        minUploadSize = {UPLOAD_CHUNK_SIZE: girder.UPLOAD_CHUNK_SIZE};
        var resp = girder.restRequest({
            path: 'system/setting',
            type: 'GET',
            data: {key: 'core.upload_minimum_chunk_size'},
            async: false
        });
        minUploadSize.setting = resp.responseText;
    }
    if (!minSize) {
        uploadChunkSize = minUploadSize.UPLOAD_CHUNK_SIZE;
        settingSize = minUploadSize.setting;
    } else {
        uploadChunkSize = minSize;
        settingSize = minSize;
    }
    girder.UPLOAD_CHUNK_SIZE = uploadChunkSize;
    girder.restRequest({
        path: 'system/setting',
        type: 'PUT',
        data: {key: 'core.upload_minimum_chunk_size', value: settingSize},
        async: false
    });
}

/**
 * Intercept window.location.assign calls so we can test the behavior of,
 * e.g. download directives that occur from js.
 */
(function () {
    window.location.assign = function (url) {
        girderTest._redirect = url;
    };
} (window.location.assign));

/**
 * Start the girder backbone app.
 */
girderTest.startApp();

describe('Create a data hierarchy', function () {
    it('register a user',
        girderTest.createUser('johndoe',
                              '<EMAIL>',
                              'John',
                              'Doe',
                              'password!'));

    it('create a folder', function () {
        runs(function () {
            expect($('#g-user-action-menu.open').length).toBe(0);
            $('.g-user-text>a:first').click();
        });
        girderTest.waitForLoad();
        runs(function () {
            expect($('#g-user-action-menu.open').length).toBe(1);
            $('a.g-my-folders').click();
        });
        girderTest.waitForLoad();

        waitsFor(function () {
            // Wait for folders to show, and also the folder count
            return $('li.g-folder-list-entry').length > 0 &&
                $('.g-subfolder-count').text() === '2';
        }, 'my folders list to display');

        runs(function () {
            expect($('.g-item-count').length).toBe(0);
            expect($('a.g-folder-list-link:first').text()).toBe('Private');
            expect($('.g-folder-privacy:first').text()).toBe('Private');
{'fraction_non_alphanumeric': 0.13596342702336606, 'fraction_numerical': 0.0027091093802912294, 'mean_word_length': 2.2208287895310797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '3607823', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1721, 'n_words': 425}