Ejemplo n.º 1
0
 it('can show itself', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockXBlockEditorHtml);
     expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
     EditHelpers.cancelModal(modal);
     expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
 });
Ejemplo n.º 2
0
        init = function(caller) {
            var requests = AjaxHelpers.requests(caller);
            containerView.render();

            AjaxHelpers.respondWithJson(requests, {
                html: mockContainerHTML,
                resources: []
            });

            $('body').append(containerView.$el);

            // Give the whole container enough height to contain everything.
            $('.xblock[data-locator=locator-container]').css('height', 2000);

            // Give the groups enough height to contain their child vertical elements.
            $('.is-draggable[data-locator=locator-group-A]').css('height', 800);
            $('.is-draggable[data-locator=locator-group-B]').css('height', 800);


            // Give the leaf elements some height to mimic actual components. Otherwise
            // drag and drop fails as the elements on bunched on top of each other.
            $('.level-element').css('height', 230);

            return requests;
        };
Ejemplo n.º 3
0
 renderContainerPage = function(test, html, options, componentTemplates) {
     requests = AjaxHelpers.requests(test);
     containerPage = getContainerPage(options, componentTemplates);
     containerPage.render();
     respondWithHtml(html);
     AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
     AjaxHelpers.respondWithJson(requests, options || {});
 };
Ejemplo n.º 4
0
 it('mini operation message when undo moving an xblock', function() {
     var notificationSpy,
         requests = AjaxHelpers.requests(this);
     moveXBlockWithSuccess(requests);
     notificationSpy = ViewHelpers.createNotificationSpy();
     getMovedAlertNotification().find('.action-save').click();
     verifyNotificationStatus(requests, notificationSpy, 'Undo moving');
 });
Ejemplo n.º 5
0
 it('error message when undo move request fails', function() {
     var requests = AjaxHelpers.requests(this),
         notificationSpy = ViewHelpers.createNotificationSpy('Error');
     moveXBlockWithSuccess(requests);
     getMovedAlertNotification().find('.action-save').click();
     AjaxHelpers.respondWithError(requests);
     ViewHelpers.verifyNotificationShowing(notificationSpy, "Studio's having trouble saving your work");
 });
Ejemplo n.º 6
0
 it('shows a loading indicator', function() {
     requests = AjaxHelpers.requests(this);
     containerPage = getContainerPage();
     containerPage.render();
     expect(containerPage.$('.ui-loading')).not.toHaveClass('is-hidden');
     respondWithHtml(mockContainerXBlockHtml);
     expect(containerPage.$('.ui-loading')).toHaveClass('is-hidden');
 });
Ejemplo n.º 7
0
 it('mini operation message when moving an xblock', function() {
     var requests = AjaxHelpers.requests(this),
         notificationSpy = ViewHelpers.createNotificationSpy();
     // navigate to a target parent and click
     renderViews(courseOutline);
     _.each(_.range(3), function() {
         clickForwardButton(1);
     });
     modal.$el.find('.modal-actions .action-move').click();
     verifyNotificationStatus(requests, notificationSpy, 'Moving');
 });
Ejemplo n.º 8
0
 it('hides itself and does not refresh after cancel notification', function() {
     var requests = AjaxHelpers.requests(this),
         refreshed = false,
         refresh = function() {
             refreshed = true;
         };
     modal = showModal(requests, mockXBlockEditorHtml, {refresh: refresh});
     modal.editorView.notifyRuntime('cancel');
     expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
     expect(refreshed).toBeFalsy();
     expect(Backbone.trigger).toHaveBeenCalledWith('xblock:editorModalHidden');
 });
Ejemplo n.º 9
0
 it('undo move an xblock when undo move link is clicked', function() {
     var sourceIndex = 0,
         requests = AjaxHelpers.requests(this);
     moveXBlockWithSuccess(requests);
     getMovedAlertNotification().find('.action-save').click();
     AjaxHelpers.respondWithJson(requests, {
         move_source_locator: sourceLocator,
         parent_locator: sourceParentLocator,
         target_index: sourceIndex
     });
     verifyUndoConfirmationFeedbackTitleText(sourceDisplayName);
 });
Ejemplo n.º 10
0
 it('error message when move request fails', function() {
     var requests = AjaxHelpers.requests(this),
         notificationSpy = ViewHelpers.createNotificationSpy('Error');
     // select a target item and click
     renderViews(courseOutline);
     _.each(_.range(3), function() {
         clickForwardButton(1);
     });
     modal.$el.find('.modal-actions .action-move').click();
     AjaxHelpers.respondWithError(requests);
     ViewHelpers.verifyNotificationShowing(notificationSpy, "Studio's having trouble saving your work");
 });
Ejemplo n.º 11
0
 it('shows the correct default buttons', function() {
     var requests = AjaxHelpers.requests(this),
         editorButton,
         settingsButton;
     modal = showModal(requests, mockXModuleEditorHtml);
     expect(modal.$('.editor-modes a').length).toBe(2);
     editorButton = modal.$('.editor-button');
     settingsButton = modal.$('.settings-button');
     expect(editorButton.length).toBe(1);
     expect(editorButton).toHaveClass('is-set');
     expect(settingsButton.length).toBe(1);
     expect(settingsButton).not.toHaveClass('is-set');
 });
Ejemplo n.º 12
0
 it('can switch tabs', function() {
     var requests = AjaxHelpers.requests(this),
         editorButton,
         settingsButton;
     modal = showModal(requests, mockXModuleEditorHtml);
     expect(modal.$('.editor-modes a').length).toBe(2);
     editorButton = modal.$('.editor-button');
     settingsButton = modal.$('.settings-button');
     expect(modal.$('.metadata_edit')).toHaveClass('is-inactive');
     settingsButton.click();
     expect(modal.$('.metadata_edit')).toHaveClass('is-active');
     editorButton.click();
     expect(modal.$('.metadata_edit')).toHaveClass('is-inactive');
 });
Ejemplo n.º 13
0
 it('hides the modal\'s button bar', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockCustomButtonsHtml);
     expect(modal.$('.modal-actions')).toBeHidden();
 });
Ejemplo n.º 14
0
 it('hides the modal\'s header', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockCustomTabsHtml);
     expect(modal.$('.modal-header')).toBeHidden();
 });
Ejemplo n.º 15
0
 it('shows the correct title', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockCustomTabsHtml);
     expect(modal.$('.component-name').text()).toBe('Editing: Component');
 });
Ejemplo n.º 16
0
 it('move an xblock when move button is clicked', function() {
     var requests = AjaxHelpers.requests(this);
     moveXBlockWithSuccess(requests);
 });
Ejemplo n.º 17
0
 it('does not show the "Save" button', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockXBlockEditorHtml);
     expect(modal.$('.action-save')).not.toBeVisible();
     expect(modal.$('.action-cancel').text()).toBe('Close');
 });
Ejemplo n.º 18
0
 it('shows the correct title', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockXBlockEditorHtml);
     expect(modal.$('.modal-window-title').text()).toBe('Editing: Component');
 });
Ejemplo n.º 19
0
 it('does not show any editor mode buttons', function() {
     var requests = AjaxHelpers.requests(this);
     modal = showModal(requests, mockXBlockEditorHtml);
     expect(modal.$('.editor-modes a').length).toBe(0);
 });