Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cms/static/js/views/move_xblock_breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ function($, Backbone, _, gettext, HtmlUtils, StringUtils, MoveXBlockBreadcrumbVi
var MoveXBlockBreadcrumb = Backbone.View.extend({
el: '.breadcrumb-container',

defaultRenderOptions: {
breadcrumbs: ['Course Outline']
},

events: {
'click .parent-nav-button': 'handleBreadcrumbButtonPress'
},
Expand All @@ -29,7 +25,7 @@ function($, Backbone, _, gettext, HtmlUtils, StringUtils, MoveXBlockBreadcrumbVi
render: function(options) {
HtmlUtils.setHtml(
this.$el,
this.template(_.extend({}, this.defaultRenderOptions, options))
this.template(options)
);
Backbone.trigger('move:breadcrumbRendered');
return this;
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/js/move-xblock-list.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%- categoryText %>:
</span>
</div>
<ul class="xblock-items-container">
<ul class="xblock-items-container" data-items-category="<%- XBlocksCategory %>">
<% for (var i = 0; i < xblocks.length; i++) {
var xblock = xblocks[i];
%>
Expand Down
55 changes: 53 additions & 2 deletions common/test/acceptance/pages/studio/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ def _is_finished_loading():
is_done = num_wrappers == (num_initialized_xblocks + num_failed_xblocks)
return (is_done, is_done)

def _loading_spinner_hidden():
""" promise function to check loading spinner state """
is_spinner_hidden = self.q(css='div.ui-loading.is-hidden').present

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

present or visible ??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

present because we are checking if the element has this class or not

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not checking for visibility of loader ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes based on it's is-hidden class.

FYI @muhammad-ammar

return is_spinner_hidden, is_spinner_hidden

# First make sure that an element with the view-container class is present on the page,
# and then wait for the loading spinner to go away and all the xblocks to be initialized.
return (
self.q(css='body.view-container').present and
self.q(css='div.ui-loading.is-hidden').present and
Promise(_loading_spinner_hidden, 'loading spinner is hidden.').fulfill() and
Promise(_is_finished_loading, 'Finished rendering the xblock wrappers.').fulfill()
)

Expand Down Expand Up @@ -101,6 +106,13 @@ def active_xblocks(self):
"""
return self._get_xblocks(".is-active ")

@property
def displayed_children(self):
"""
Return a list of displayed xblocks loaded on the container page.
"""
return self._get_xblocks()[0].children

@property
def publish_title(self):
"""
Expand Down Expand Up @@ -262,6 +274,29 @@ def edit(self):
"""
return _click_edit(self, '.edit-button', '.xblock-studio_view')

def verify_confirmation_message(self, message):
"""
Verify for confirmation message.
"""
def _verify_message():
""" promise function to check confirmation message state """
text = self.q(css='#page-alert .alert.confirmation #alert-confirmation-title').text
return text and message in text[0]

self.wait_for(_verify_message, description='confirmation message present')

def click_undo_move_link(self):
"""
Click undo move link.
"""
click_css(self, '#page-alert .alert.confirmation .nav-actions .action-primary')

def click_take_me_there_link(self):
"""
Click take me there link.
"""
click_css(self, '#page-alert .alert.confirmation .nav-actions .action-secondary', require_notification=False)

def add_missing_groups(self):
"""
Click the "add missing groups" link.
Expand Down Expand Up @@ -382,7 +417,7 @@ def children(self):
"""
Will return any first-generation descendant xblocks of this xblock.
"""
descendants = self.q(css=self._bounded_selector(self.BODY_SELECTOR)).map(
descendants = self.q(css=self._bounded_selector(self.BODY_SELECTOR)).filter(lambda el: el.is_displayed()).map(
lambda el: XBlockWrapper(self.browser, el.get_attribute('data-locator'))).results

# Now remove any non-direct descendants.
Expand Down Expand Up @@ -468,6 +503,13 @@ def has_edit_visibility_button(self):
"""
return self.q(css=self._bounded_selector('.visibility-button')).is_present()

@property
def has_move_modal_button(self):
"""
Returns True if this xblock has move modal button else False
"""
return self.q(css=self._bounded_selector('.move-button')).is_present()

def go_to_container(self):
"""
Open the container page linked to by this xblock, and return
Expand Down Expand Up @@ -505,6 +547,15 @@ def open_settings_tab(self):
"""
self._click_button('settings_tab')

def open_move_modal(self):
"""
Opens the move modal.
"""
click_css(self, '.move-button', require_notification=False)
self.wait_for(
lambda: self.q(css='.modal-window.move-modal').visible, description='move modal is visible'
)

def set_field_val(self, field_display_name, field_value):
"""
If editing, set the value of a field.
Expand Down
78 changes: 78 additions & 0 deletions common/test/acceptance/pages/studio/move_xblock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""
Move XBlock Modal Page Object
"""
from bok_choy.page_object import PageObject
from common.test.acceptance.pages.common.utils import click_css


class MoveModalView(PageObject):
"""
A base class for move xblock
"""

def __init__(self, browser):
"""
Arguments:
browser (selenium.webdriver): The Selenium-controlled browser that this page is loaded in.
"""
super(MoveModalView, self).__init__(browser)

def is_browser_on_page(self):
return self.q(css='.modal-window.move-modal').present

def url(self):
"""
Returns None because this is not directly accessible via URL.
"""
return None

def save(self):
"""
Clicks save button.
"""
click_css(self, 'a.action-save')

def cancel(self):
"""
Clicks cancel button.
"""
click_css(self, 'a.action-cancel', require_notification=False)

def click_forward_button(self, source_index):
"""
Click forward button at specified `source_index`.
"""
css = '.move-modal .xblock-items-container .xblock-item'
self.q(css='.button-forward').nth(source_index).click()
self.wait_for(
lambda: len(self.q(css=css).results) > 0, description='children are visible'
)

def click_move_button(self):
"""
Click move button.
"""
self.q(css='.modal-actions .action-move').first.click()

@property
def is_move_button_enabled(self):
"""
Returns True if move button on modal is enabled else False.
"""
return not self.q(css='.modal-actions .action-move.is-disabled').present

@property
def children_category(self):
"""
Get displayed children category.
"""
return self.q(css='.xblock-items-container').attrs('data-items-category')[0]

def navigate_to_category(self, category, navigation_options):
"""
Navigates to specifec `category` for a specified `source_index`.
"""
child_category = self.children_category
while child_category != category:
self.click_forward_button(navigation_options[child_category])
child_category = self.children_category
Loading