Example #1
0
            it('can edit itself', function() {
                var editButtons, displayNameElement, request;
                renderContainerPage(this, mockContainerXBlockHtml);
                displayNameElement = containerPage.$('.page-header-title');

                // Click the root edit button
                editButtons = containerPage.$('.nav-actions .edit-button');
                editButtons.first().click();

                // Expect a request to be made to show the studio view for the container
                request = AjaxHelpers.currentRequest(requests);
                expect(str.startsWith(request.url, '/xblock/locator-container/studio_view')).toBeTruthy();
                AjaxHelpers.respondWithJson(requests, {
                    html: mockContainerXBlockHtml,
                    resources: []
                });
                expect(EditHelpers.isShowingModal()).toBeTruthy();

                // Expect the correct title to be shown
                expect(EditHelpers.getModalTitle()).toBe('Editing: Test Container');

                // Press the save button and respond with a success message to the save
                EditHelpers.pressModalButton('.action-save');
                AjaxHelpers.respondWithJson(requests, { });
                expect(EditHelpers.isShowingModal()).toBeFalsy();

                // Expect the last request be to refresh the container page
                handleContainerPageRefresh(requests);

                // Respond to the subsequent xblock info fetch request.
                AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName});

                // Expect the title to have been updated
                expect(displayNameElement.text().trim()).toBe(updatedDisplayName);
            });
Example #2
0
 handleContainerPageRefresh = function(requests) {
     var request = AjaxHelpers.currentRequest(requests);
     expect(str.startsWith(request.url,
         '/xblock/locator-container/container_preview')).toBeTruthy();
     AjaxHelpers.respondWithJson(requests, {
         html: mockUpdatedContainerXBlockHtml,
         resources: []
     });
 };
Example #3
0
 it('can show an edit modal for a child xblock', function() {
     var editButtons, request;
     renderContainerPage(this, mockContainerXBlockHtml);
     editButtons = containerPage.$('.wrapper-xblock .edit-button');
     // The container should have rendered six mock xblocks
     expect(editButtons.length).toBe(6);
     editButtons[0].click();
     // Make sure that the correct xblock is requested to be edited
     request = AjaxHelpers.currentRequest(requests);
     expect(str.startsWith(request.url, '/xblock/locator-component-A1/studio_view')).toBeTruthy();
     AjaxHelpers.respondWithJson(requests, {
         html: mockXBlockEditorHtml,
         resources: []
     });
     expect(EditHelpers.isShowingModal()).toBeTruthy();
 });
Example #4
0
 it('can show a visibility modal for a child xblock if supported for the page', function() {
     var accessButtons, request;
     renderContainerPage(this, mockContainerXBlockHtml);
     accessButtons = containerPage.$('.wrapper-xblock .access-button');
     if (hasVisibilityEditor) {
         expect(accessButtons.length).toBe(6);
         accessButtons[0].click();
         request = AjaxHelpers.currentRequest(requests);
         expect(str.startsWith(request.url, '/xblock/locator-component-A1/visibility_view'))
             .toBeTruthy();
         AjaxHelpers.respondWithJson(requests, {
             html: mockXBlockVisibilityEditorHtml,
             resources: []
         });
         expect(EditHelpers.isShowingModal()).toBeTruthy();
     } else {
         expect(accessButtons.length).toBe(0);
     }
 });