<commit_before>(function () {
    var user, folder, subfolder, item, widget;

    describe('Test upload widget non-standard options', function () {
        it('create the widget', function () {
            runs(function () {
                $('body').off();

                new girder.views.widgets.UploadWidget({
                    noParent: true,
                    modal: false,
                    title: null,
                    el: 'body',
                    parentView: null
                }).render();

                expect($('.modal').length).toBe(0);
                expect($('#g-upload-form h4').length).toBe(0);
                expect($('.g-dialog-subtitle').length).toBe(0);
                expect($('.g-drop-zone:visible').length).toBe(1);
                expect($('.g-start-upload.btn.disabled:visible').length).toBe(1);
                expect($('.g-overall-progress-message').text()).toBe('No files selected');
            });
        });
    });

    describe('Test hierarchy widget non-standard options', function () {
        it('register a user', function () {
            runs(function () {
                var _user = new girder.models.UserModel({
                    login: 'mylogin',
                    password:'<PASSWORD>',
                    email: '<EMAIL>',
                    firstName: 'First',
                    lastName: 'Last'
                }).on('g:saved', function () {
                    user = _user;
                });

                _user.save();
            });

            waitsFor(function () {
                return !!user;
            }, 'user registration');
        });

        it('create top level folder', function () {
            runs(function () {
                var _folder = new girder.models.FolderModel({
                    parentType: 'user',
                    parentId: user.get('_id'),
                    name: 'top level folder'
                }).on('g:saved', function () {
                    folder = _folder;
                });

                _folder.save();
            });

            waitsFor(function () {
                return !!folder;
            }, 'folder creation');
        });

        it('create subfolder', function () {
            runs(function () {
                var _subfolder = new girder.models.FolderModel({
                    parentType: 'folder',
                    parentId: folder.get('_id'),
                    name: 'subfolder'
                }).on('g:saved', function () {
                    subfolder = _subfolder;
                });

                _subfolder.save();
            });

            waitsFor(function () {
                return !!subfolder;
            }, 'subfolder creation');
        });

        it('create item', function () {
            runs(function () {
                var _item = new girder.models.ItemModel({
                    folderId: folder.get('_id'),
                    name: 'an item'
                }).on('g:saved', function () {
                    item = _item;
                });

                _item.save();
            });

            waitsFor(function () {
                return !!item;
            }, 'item creation');
        });

        it('test custom hierarchy widget options', function () {
            runs(function () {
                $('body').off();

                widget = new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    onItemClick: function (item) {
                        widget.selectItem(item);
                    },
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-folder-list-link').text()).toBe('subfolder');
                expect($('.g-item-list-link').text()).toBe('an item');
                expect(widget.getSelectedItem()).toBe(null);

                $('.g-item-list-link').click();
            });

            waitsFor(function () {
                var selected = widget.getSelectedItem();
                return selected && selected.get('_id') === item.get('_id');
            }, 'item to be selected');

            runs(function () {
                expect($('.g-item-list-entry.g-selected').length).toBe(1);

                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    checkboxes: false,
                    parentView: null,
                    showItems: false
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0;
            }, 'the hierarchy widget with no checkboxes to display');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(1);
                expect($('.g-hierarchy-actions-header').length).toBe(1);
                expect($('.g-list-checkbox').length).toBe(0);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-checked-actions-buttons').length).toBe(0);
                expect($('.g-folder-list-link').text()).toBe('subfolder');
                expect($('.g-item-list-link').length).toBe(0);
            });
        });
    });

    describe('Test access widget with non-standard options', function () {
        it('test non-modal rendering', function () {
            runs(function () {
                new girder.views.widgets.AccessWidget({
                    el: 'body',
                    modal: false,
                    model: folder,
                    modelType: 'folder',
                    parentView: null<commit_msg>add tests for custom hierarchy widget options<commit_after>(function () {
    var user, folder, subfolder, item, widget;

    describe('Test upload widget non-standard options', function () {
        it('create the widget', function () {
            runs(function () {
                $('body').off();

                new girder.views.widgets.UploadWidget({
                    noParent: true,
                    modal: false,
                    title: null,
                    el: 'body',
                    parentView: null
                }).render();

                expect($('.modal').length).toBe(0);
                expect($('#g-upload-form h4').length).toBe(0);
                expect($('.g-dialog-subtitle').length).toBe(0);
                expect($('.g-drop-zone:visible').length).toBe(1);
                expect($('.g-start-upload.btn.disabled:visible').length).toBe(1);
                expect($('.g-overall-progress-message').text()).toBe('No files selected');
            });
        });
    });

    describe('Test hierarchy widget non-standard options', function () {
        it('register a user', function () {
            runs(function () {
                var _user = new girder.models.UserModel({
                    login: 'mylogin',
                    password:'<PASSWORD>',
                    email: '<EMAIL>',
                    firstName: 'First',
                    lastName: 'Last'
                }).on('g:saved', function () {
                    user = _user;
                });

                _user.save();
            });

            waitsFor(function () {
                return !!user;
            }, 'user registration');
        });

        it('create top level folder', function () {
            runs(function () {
                var _folder = new girder.models.FolderModel({
                    parentType: 'user',
                    parentId: user.get('_id'),
                    name: 'top level folder'
                }).on('g:saved', function () {
                    folder = _folder;
                });

                _folder.save();
            });

            waitsFor(function () {
                return !!folder;
            }, 'folder creation');
        });

        it('create subfolder', function () {
            runs(function () {
                var _subfolder = new girder.models.FolderModel({
                    parentType: 'folder',
                    parentId: folder.get('_id'),
                    name: 'subfolder'
                }).on('g:saved', function () {
                    subfolder = _subfolder;
                });

                _subfolder.save();
            });

            waitsFor(function () {
                return !!subfolder;
            }, 'subfolder creation');
        });

        it('create item', function () {
            runs(function () {
                var _item = new girder.models.ItemModel({
                    folderId: folder.get('_id'),
                    name: 'an item'
                }).on('g:saved', function () {
                    item = _item;
                });

                _item.save();
            });

            waitsFor(function () {
                return !!item;
            }, 'item creation');
        });

        it('test custom hierarchy widget options', function () {
            runs(function () {
                $('body').off();

                widget = new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    onItemClick: function (item) {
                        widget.selectItem(item);
                    },
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-folder-list-link').text()).toBe('subfolder');
                expect($('.g-item-list-link').text()).toBe('an item');
                expect(widget.getSelectedItem()).toBe(null);

                $('.g-item-list-link').click();
            });

            waitsFor(function () {
                var selected = widget.getSelectedItem();
                return selected && selected.get('_id') === item.get('_id');
            }, 'item to be selected');

            runs(function () {
                expect($('.g-item-list-entry.g-selected').length).toBe(1);

                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    checkboxes: false,
                    parentView: null,
                    showItems: false
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0;
            }, 'the hierarchy widget with no checkboxes to display');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(1);
                expect($('.g-hierarchy-actions-header').length).toBe(1);
                expect($('.g-list-checkbox').length).toBe(0);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-checked-actions-buttons').length).toBe(0);
                expect($('.g-folder-list-link').text()).toBe('subfolder');
                expect($('.g-item-list-link').length).toBe(0);
            });

            runs(function () {
                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    downloadLinks: false,
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display without download links');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('a[title="Download item"]').length).toBe(0);
            });

            runs(function () {
                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    viewLinks: false,
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display without view links');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-view-inline').length).toBe(0);
            });

            runs(function () {
                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    downloadLinks: false,
                    viewLinks: false,
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, ('the hierarchy widget to display neither ' +
                'view nor download links'));

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-view-inline').length).toBe(0);
                expect($('a[title="Download item"]').length).toBe(0);

                /* no border shown when there are no links */
                expect($('.g-right-border').length).toBe(0);
            });

            runs(function () {
                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    showMetadata: false,
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display without the metadata widget');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-folder-metadata').length).toBe(0);
            });

            runs(function () {
                $('body').empty().off();

                new girder.views.widgets.HierarchyWidget({
                    el: 'body',
                    parentModel: folder,
                    showSizes: false,
                    showActions: false,
                    parentView: null
                });
            });

            waitsFor(function () {
                return $('.g-hierarchy-widget').length > 0 &&
                       $('.g-folder-list-link').length > 0 &&
                       $('.g-item-list-link').length > 0;
            }, 'the hierarchy widget to display without item sizes');

            runs(function () {
                expect($('.g-upload-here-button').length).toBe(0);
                expect($('.g-hierarchy-actions-header').length).toBe(0);
                expect($('.g-list-checkbox').length).toBe(2);
                expect($('.g-select-all').length).toBe(0);
                expect($('.g-item-size').length).toBe(0);
            });
        });
    });

    describe('Test access widget with non-standard options', function () {
        it('test non-modal rendering', function () {
            runs(function () {
                new girder.views.widgets.AccessWidget({
                    el: 'body',
                    modal: false,
                    model: folder,
                    modelType: 'folder',
                    parentView: null
{'fraction_non_alphanumeric': 0.15614325068870524, 'fraction_numerical': 0.004738292011019283, 'mean_word_length': 1.2205774406655248, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388667', 'n_tokens_mistral': 4662, 'n_tokens_neox': 4297, 'n_words': 740}