Commit f31475a2 by Ben McMorran Committed by cahrens

Add bokchoy tests for outline page

parent 327a97f7
......@@ -125,6 +125,7 @@ define(["jquery", "underscore", "js/views/xblock_outline", "js/views/utils/view_
// as it cannot visually effect the other sections.
if (childCategory === 'chapter' && children && children.length > 1) {
childView.$el.remove();
children.splice(children.indexOf(childView.model), 1);
} else {
this.refresh();
}
......
......@@ -22,7 +22,7 @@ define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views
});
this.nameEditor.render();
if (this.options.action === 'new') {
this.nameEditor.$('.xblock-field-value').click();
this.nameEditor.$('.xblock-field-value-edit').click();
}
this.xblockView = new ContainerView({
el: this.$('.wrapper-xblock'),
......
......@@ -194,7 +194,7 @@ define(["jquery", "underscore", "gettext", "js/views/baseview", "js/views/utils/
}
ViewUtils.setScrollOffset(locatorElement, scrollOffset);
if (editDisplayName) {
locatorElement.find('> .wrapper-xblock-header .xblock-field-value').click();
locatorElement.find('> .wrapper-xblock-header .xblock-field-value-edit').click();
}
}
this.initialState = null;
......
......@@ -8,7 +8,7 @@ from . import BASE_URL
from selenium.webdriver.common.action_chains import ActionChains
from utils import click_css, wait_for_notification
from utils import click_css, wait_for_notification, confirm_prompt
class ContainerPage(PageObject):
......@@ -16,6 +16,8 @@ class ContainerPage(PageObject):
Container page in Studio
"""
NAME_SELECTOR = '.page-header-title'
NAME_INPUT_SELECTOR = '.page-header .xblock-field-input'
NAME_FIELD_WRAPPER_SELECTOR = '.page-header .wrapper-xblock-field'
def __init__(self, browser, locator):
super(ContainerPage, self).__init__(browser)
......@@ -134,7 +136,7 @@ class ContainerPage(PageObject):
Discards draft changes (which will then re-render the page).
"""
click_css(self, 'a.action-discard', 0, require_notification=False)
self.q(css='a.button.action-primary').first.click()
confirm_prompt(self)
self.wait_for_ajax()
def toggle_staff_lock(self):
......@@ -149,7 +151,7 @@ class ContainerPage(PageObject):
self.q(css='a.action-staff-lock').first.click()
else:
click_css(self, 'a.action-staff-lock', 0, require_notification=False)
self.q(css='a.button.action-primary').first.click()
confirm_prompt(self)
self.wait_for_ajax()
return not was_locked_initially
......@@ -218,16 +220,8 @@ class ContainerPage(PageObject):
"""
# Click the delete button
click_css(self, 'a.delete-button', source_index, require_notification=False)
# Wait for the warning prompt to appear
self.wait_for_element_visibility('#prompt-warning', 'Deletion warning prompt is visible')
# Make sure the delete button is there
confirmation_button_css = '#prompt-warning a.button.action-primary'
self.wait_for_element_visibility(confirmation_button_css, 'Confirmation dialog button is visible')
# Click the confirmation dialog button
click_css(self, confirmation_button_css, 0)
confirm_prompt(self)
def edit(self):
"""
......@@ -255,6 +249,12 @@ class ContainerPage(PageObject):
"""
return self.q(css=".xblock-message.information").first.text[0]
def is_inline_editing_display_name(self):
"""
Return whether this container's display name is in its editable form.
"""
return "is-editing" in self.q(css=self.NAME_FIELD_WRAPPER_SELECTOR).first.attrs("class")[0]
class XBlockWrapper(PageObject):
"""
......
......@@ -139,3 +139,14 @@ def set_input_value_and_save(page, css, value):
action = action.send_keys(Keys.BACKSPACE)
# Send the new text, then hit the enter key so that the change event is triggered).
action.send_keys(value).send_keys(Keys.ENTER).perform()
def confirm_prompt(page, cancel=False):
"""
Ensures that a modal prompt and confirmation button are visible, then clicks the button. The prompt is canceled iff
cancel is True.
"""
page.wait_for_element_visibility('.prompt', 'Prompt is visible')
confirmation_button_css = '.prompt .action-' + ('secondary' if cancel else 'primary')
page.wait_for_element_visibility(confirmation_button_css, 'Confirmation button is visible')
click_css(page, confirmation_button_css, require_notification=(not cancel))
......@@ -6,18 +6,17 @@ displaying containers within units.
from nose.plugins.attrib import attr
from ..pages.studio.overview import CourseOutlinePage
from ..fixtures.course import XBlockFixtureDesc
from ..fixtures.course import XBlockFixtureDesc
from ..pages.studio.component_editor import ComponentEditorView
from ..pages.studio.html_component_editor import HtmlComponentEditorView
from ..pages.studio.utils import add_discussion
from ..pages.lms.courseware import CoursewarePage
from ..pages.lms.staff_view import StaffPage
from unittest import skip
from acceptance.tests.base_studio_test import StudioCourseTest
import datetime
from bok_choy.promise import Promise, EmptyPromise
from acceptance.tests.base_studio_test import StudioCourseTest
@attr('shard_1')
......@@ -388,23 +387,17 @@ class UnitPublishingTest(ContainerBase):
LAST_PUBLISHED = 'Last published'
LAST_SAVED = 'Draft saved on'
def setup_fixtures(self):
def populate_course_fixture(self, course_fixture):
"""
Sets up a course structure with a unit and a single HTML child.
"""
self.html_content = '<p><strong>Body of HTML Unit.</strong></p>'
self.courseware = CoursewarePage(self.browser, self.course_id)
course_fix = CourseFixture(
self.course_info['org'],
self.course_info['number'],
self.course_info['run'],
self.course_info['display_name']
)
past_start_date = datetime.datetime(1974, 6, 22)
self.past_start_date_text = "Jun 22, 1974 at 00:00 UTC"
course_fix.add_children(
course_fixture.add_children(
XBlockFixtureDesc('chapter', 'Test Section').add_children(
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
XBlockFixtureDesc('vertical', 'Test Unit').add_children(
......@@ -426,9 +419,7 @@ class UnitPublishingTest(ContainerBase):
)
)
)
).install()
self.user = course_fix.user
)
def test_publishing(self):
"""
......@@ -495,7 +486,7 @@ class UnitPublishingTest(ContainerBase):
Then I see the published content in LMS
"""
unit = self.go_to_unit_page()
unit.view_published_version()
self._view_published_version(unit)
self._verify_components_visible(['html'])
def test_view_live_changes(self):
......@@ -510,7 +501,7 @@ class UnitPublishingTest(ContainerBase):
"""
unit = self.go_to_unit_page()
add_discussion(unit)
unit.view_published_version()
self._view_published_version(unit)
self._verify_components_visible(['html'])
self.assertEqual(self.html_content, self.courseware.xblock_component_html_content(0))
......@@ -527,7 +518,7 @@ class UnitPublishingTest(ContainerBase):
unit = self.go_to_unit_page()
add_discussion(unit)
unit.publish_action.click()
unit.view_published_version()
self._view_published_version(unit)
self._verify_components_visible(['html', 'discussion'])
def test_initially_unlocked_visible_to_students(self):
......@@ -547,7 +538,7 @@ class UnitPublishingTest(ContainerBase):
self._verify_release_date_info(
unit, self.RELEASE_TITLE_RELEASED, self.past_start_date_text + ' with Section "Unlocked Section"'
)
unit.view_published_version()
self._view_published_version(unit)
self._verify_student_view_visible(['problem'])
def test_locked_visible_to_staff_only(self):
......@@ -567,7 +558,7 @@ class UnitPublishingTest(ContainerBase):
self.assertTrue(checked)
self.assertFalse(unit.currently_visible_to_students)
self._verify_publish_title(unit, self.LOCKED_STATUS)
unit.view_published_version()
self._view_published_version(unit)
# Will initially be in staff view, locked component should be visible.
self._verify_components_visible(['problem'])
# Switch to student view and verify not visible
......@@ -591,7 +582,7 @@ class UnitPublishingTest(ContainerBase):
unit, self.RELEASE_TITLE_RELEASED,
self.past_start_date_text + ' with Subsection "Subsection With Locked Unit"'
)
unit.view_published_version()
self._view_published_version(unit)
self._verify_student_view_locked()
def test_unlocked_visible_to_all(self):
......@@ -611,7 +602,7 @@ class UnitPublishingTest(ContainerBase):
self.assertFalse(checked)
self._verify_publish_title(unit, self.PUBLISHED_STATUS)
self.assertTrue(unit.currently_visible_to_students)
unit.view_published_version()
self._view_published_version(unit)
# Will initially be in staff view, components always visible.
self._verify_components_visible(['discussion'])
# Switch to student view and verify visible.
......@@ -641,7 +632,7 @@ class UnitPublishingTest(ContainerBase):
unit.publish_action.click()
unit.wait_for_ajax()
self._verify_publish_title(unit, self.PUBLISHED_STATUS)
unit.view_published_version()
self._view_published_version(unit)
self.assertTrue(modified_content in self.courseware.xblock_component_html_content(0))
def test_delete_child_in_published_unit(self):
......@@ -662,9 +653,16 @@ class UnitPublishingTest(ContainerBase):
unit.publish_action.click()
unit.wait_for_ajax()
self._verify_publish_title(unit, self.PUBLISHED_STATUS)
unit.view_published_version()
self._view_published_version(unit)
self.assertEqual(0, self.courseware.num_xblock_components)
def _view_published_version(self, unit):
"""
Goes to the published version, then waits for the browser to load the page.
"""
unit.view_published_version()
self.courseware.wait_for_page()
def _verify_and_return_staff_page(self):
"""
Verifies that the browser is on the staff page and returns a StaffPage.
......
......@@ -113,57 +113,6 @@ class CoursePagesTest(StudioCourseTest):
page.visit()
@attr('shard_1')
class CourseSectionTest(StudioCourseTest):
"""
Tests that verify the sections name editable only inside headers in Studio Course Outline that you can get to
when logged in and have a course.
"""
COURSE_ID_SEPARATOR = "."
def setUp(self):
"""
Install a course with no content using a fixture.
"""
super(CourseSectionTest, self).setUp()
self.course_outline_page = CourseOutlinePage(
self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']
)
self.course_outline_page.visit()
def populate_course_fixture(self, course_fixture):
""" Populates the course fixture with a test section """
course_fixture.add_children(
XBlockFixtureDesc('chapter', 'Test Section')
)
def test_section_name_editable_in_course_outline(self):
"""
Check that section name is editable on course outline page.
"""
new_name = u"Test Section New"
section = self.course_outline_page.section_at(0)
self.assertEqual(section.name, u"Test Section")
section.change_name(new_name)
self.browser.refresh()
self.assertEqual(section.name, new_name)
# TODO: re-enable when release date support is added back
# def test_section_name_not_editable_inside_modal(self):
# """
# Check that section name is not editable inside "Section Release Date" modal on course outline page.
# """
# parent_css='div.modal-window'
# self.course_outline_page.click_release_date()
# section_name = self.course_outline_page.get_section_name(parent_css)[0]
# self.assertEqual(section_name, '"Test Section"')
# self.course_outline_page.click_section_name(parent_css)
# section_name_edit_form = self.course_outline_page.section_name_edit_form_present(parent_css)
# self.assertFalse(section_name_edit_form)
@attr('shard_1')
class DiscussionPreviewTest(StudioCourseTest):
"""
Tests that Inline Discussions are rendered with a custom preview in Studio
......
......@@ -65,30 +65,22 @@ class SplitTestMixin(object):
Promise(missing_groups_button_not_present, "Add missing groups button should not be showing.").fulfill()
@attr('shard_1')
class SplitTest(ContainerBase, SplitTestMixin):
class SplitTest(ContainerBase):
"""
Tests for creating and editing split test instances in Studio.
"""
__test__ = True
def setUp(self):
super(SplitTest, self).setUp()
# This line should be called once courseFixture is installed
self.course_fixture._update_xblock(self.course_fixture._course_location, {
"metadata": {
u"user_partitions": [
UserPartition(0, 'Configuration alpha,beta', 'first', [Group("0", 'alpha'), Group("1", 'beta')]).to_json(),
UserPartition(1, 'Configuration 0,1,2', 'second', [Group("0", 'Group 0'), Group("1", 'Group 1'), Group("2", 'Group 2')]).to_json()
],
},
})
def populate_course_fixture(self, course_fixture):
""" Populates the course """
course_fixture.add_advanced_settings(
{u"advanced_modules": {"value": ["split_test"]}}
{
u"advanced_modules": {"value": ["split_test"]},
u"user_partitions": {"value": [
UserPartition(0, 'Configuration alpha,beta', 'first', [Group("0", 'alpha'), Group("1", 'beta')]).to_json(),
UserPartition(1, 'Configuration 0,1,2', 'second', [Group("0", 'Group 0'), Group("1", 'Group 1'), Group("2", 'Group 2')]).to_json()
]}
}
)
course_fixture.add_children(
......@@ -99,6 +91,16 @@ class SplitTest(ContainerBase, SplitTestMixin):
)
)
def verify_add_missing_groups_button_not_present(self, container):
"""
Checks that the "add missing groups" button/link is not present.
"""
def missing_groups_button_not_present():
button_present = container.missing_groups_button_present()
return (not button_present, not button_present)
Promise(missing_groups_button_not_present, "Add missing groups button should not be showing.").fulfill()
def create_poorly_configured_split_instance(self):
"""
Creates a split test instance with a missing group and an inactive group.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment