diff --git a/cms/djangoapps/contentstore/views/tests/test_container.py b/cms/djangoapps/contentstore/views/tests/test_container.py index a18e0552a8..0310a9544b 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container.py +++ b/cms/djangoapps/contentstore/views/tests/test_container.py @@ -124,14 +124,19 @@ class ContainerViewTestCase(CourseTestCase): Verify that an xblock returns the expected HTML for a container preview """ # First verify that the behavior is correct with a published container + self._test_preview_html(self.vertical) self._test_preview_html(self.child_vertical) # Now make the unit and its children into a draft and validate the preview again - modulestore('draft').convert_to_draft(self.vertical.location) + draft_unit = modulestore('draft').convert_to_draft(self.vertical.location) draft_container = modulestore('draft').convert_to_draft(self.child_vertical.location) + self._test_preview_html(draft_unit) self._test_preview_html(draft_container) def _test_preview_html(self, xblock): + """ + Verify that the specified xblock has the expected HTML elements for container preview + """ locator = loc_mapper().translate_location(self.course.id, xblock.location, published=False) publish_state = compute_publish_state(xblock) preview_url = '/xblock/{locator}/container_preview'.format(locator=locator) diff --git a/cms/djangoapps/contentstore/views/tests/test_tabs.py b/cms/djangoapps/contentstore/views/tests/test_tabs.py index fd04089bc6..886ed2668b 100644 --- a/cms/djangoapps/contentstore/views/tests/test_tabs.py +++ b/cms/djangoapps/contentstore/views/tests/test_tabs.py @@ -4,6 +4,7 @@ import json from contentstore.views import tabs from contentstore.tests.utils import CourseTestCase from django.test import TestCase +from xmodule.modulestore.django import loc_mapper from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from courseware.courses import get_course_by_id from xmodule.tabs import CourseTabList, WikiTab @@ -22,7 +23,7 @@ class TabsPageTests(CourseTestCase): self.url = self.course_locator.url_reverse('tabs') # add a static tab to the course, for code coverage - ItemFactory.create( + self.test_tab = ItemFactory.create( parent_location=self.course_location, category="static_tab", display_name="Static_1" @@ -172,6 +173,25 @@ class TabsPageTests(CourseTestCase): ) self.check_invalid_tab_id_response(resp) + def test_tab_preview_html(self): + """ + Verify that the static tab renders itself with the correct HTML + """ + locator = loc_mapper().translate_location(self.course.id, self.test_tab.location) + preview_url = '/xblock/{locator}/student_view'.format(locator=locator) + + resp = self.client.get(preview_url, HTTP_ACCEPT='application/json') + self.assertEqual(resp.status_code, 200) + resp_content = json.loads(resp.content) + html = resp_content['html'] + + # Verify that the HTML contains the expected elements + self.assertIn('Edit', html) + self.assertIn('Duplicate this component', html) + self.assertIn('Delete this component', html) + self.assertIn('', html) + + class PrimitiveTabEdit(TestCase): """Tests for the primitive tab edit data manipulations""" diff --git a/cms/static/js/spec/views/container_spec.js b/cms/static/js/spec/views/container_spec.js index 170e90d672..b563a2b535 100644 --- a/cms/static/js/spec/views/container_spec.js +++ b/cms/static/js/spec/views/container_spec.js @@ -8,7 +8,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers describe("Supports reordering components", function () { var model, containerView, mockContainerHTML, respondWithMockXBlockFragment, init, getComponent, - getDragHandle, dragComponentVertically, dragComponentToY, dragComponentAbove, dragComponentBelow, + getDragHandle, dragComponentVertically, dragComponentToY, dragComponentAbove, verifyRequest, verifyNumReorderCalls, respondToRequest, rootLocator = 'testCourse/branch/draft/split_test/splitFFF', @@ -93,11 +93,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers dragComponentToY(sourceLocator, targetElement.offset().top + 1); }; - dragComponentBelow = function (sourceLocator, targetLocator) { - var targetElement = containerView.$('[data-locator="' + targetLocator + '"]'); - dragComponentToY(sourceLocator, targetElement.offset().top + targetElement.height() - 1); - }; - verifyRequest = function (requests, reorderCallIndex, expectedURL, expectedChildren) { var actualIndex, request, children, i; // 0th call is the response to the initial render call to get HTML. diff --git a/common/test/acceptance/pages/studio/container.py b/common/test/acceptance/pages/studio/container.py index 2f3b8a09b5..e9de30c957 100644 --- a/common/test/acceptance/pages/studio/container.py +++ b/common/test/acceptance/pages/studio/container.py @@ -59,7 +59,7 @@ class ContainerPage(PageObject): action = ActionChains(self.browser) action.click_and_hold(source).perform() # pylint: disable=protected-access action.move_to_element_with_offset( - target, 0, target.size['height']/2 if after else 0 + target, 0, target.size['height'] / 2 if after else 0 ).perform() # pylint: disable=protected-access action.release().perform() # TODO: should wait for "Saving" to go away so we know the operation is complete? diff --git a/common/test/acceptance/tests/test_studio_acid_xblock.py b/common/test/acceptance/tests/test_studio_acid_xblock.py index 0e1e2d7231..26e84eabec 100644 --- a/common/test/acceptance/tests/test_studio_acid_xblock.py +++ b/common/test/acceptance/tests/test_studio_acid_xblock.py @@ -10,6 +10,7 @@ from ..pages.studio.overview import CourseOutlinePage from ..pages.xblock.acid import AcidView from ..fixtures.course import CourseFixture, XBlockFixtureDesc + class XBlockAcidBase(WebAppTest): """ Base class for tests that verify that XBlock integration is working correctly diff --git a/common/test/acceptance/tests/test_studio_general.py b/common/test/acceptance/tests/test_studio_general.py index 4b58d0e57b..a170ee1c61 100644 --- a/common/test/acceptance/tests/test_studio_general.py +++ b/common/test/acceptance/tests/test_studio_general.py @@ -131,11 +131,11 @@ class DiscussionPreviewTest(UniqueCourseTest): AutoAuthPage(self.browser, staff=True).visit() cop = CourseOutlinePage( - self.browser, - self.course_info['org'], - self.course_info['number'], - self.course_info['run'] - ) + self.browser, + self.course_info['org'], + self.course_info['number'], + self.course_info['run'] + ) cop.visit() self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit') self.unit.go_to()