Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ed3b9720
Commit
ed3b9720
authored
Dec 04, 2014
by
Jonathan Piacenti
Committed by
E. Kolpakov
Jan 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for Library pagination.
parent
ff1a08cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
214 additions
and
0 deletions
+214
-0
common/test/acceptance/pages/studio/library.py
+53
-0
common/test/acceptance/tests/studio/test_studio_library.py
+161
-0
No files found.
common/test/acceptance/pages/studio/library.py
View file @
ed3b9720
...
...
@@ -3,6 +3,7 @@ Library edit page in Studio
"""
from
bok_choy.page_object
import
PageObject
from
selenium.webdriver.common.keys
import
Keys
from
.container
import
XBlockWrapper
from
...tests.helpers
import
disable_animations
from
.utils
import
confirm_prompt
,
wait_for_notification
...
...
@@ -74,6 +75,58 @@ class LibraryPage(PageObject):
confirm_prompt
(
self
)
# this will also wait_for_notification()
self
.
wait_for_ajax
()
def
nav_disabled
(
self
,
position
,
arrows
=
(
'next'
,
'previous'
)):
"""
Verifies that pagination nav is disabled. Position can be 'top' or 'bottom'.
To specify a specific arrow, pass an iterable with a single element, 'next' or 'previous'.
"""
return
all
([
self
.
q
(
css
=
'nav.
%
s * a.
%
s-page-link.is-disabled'
%
(
position
,
arrow
))
for
arrow
in
arrows
])
def
move_back
(
self
,
position
):
"""
Clicks one of the forward nav buttons. Position can be 'top' or 'bottom'.
"""
self
.
q
(
css
=
'nav.
%
s * a.previous-page-link'
%
position
)[
0
]
.
click
()
self
.
wait_until_ready
()
def
move_forward
(
self
,
position
):
"""
Clicks one of the forward nav buttons. Position can be 'top' or 'bottom'.
"""
self
.
q
(
css
=
'nav.
%
s * a.next-page-link'
%
position
)[
0
]
.
click
()
self
.
wait_until_ready
()
def
revisit
(
self
):
"""
Visit the page's URL, instead of refreshing, so that a new state is created.
"""
self
.
browser
.
get
(
self
.
browser
.
current_url
)
self
.
wait_until_ready
()
def
go_to_page
(
self
,
number
):
"""
Enter a number into the page number input field, and then try to navigate to it.
"""
page_input
=
self
.
q
(
css
=
"#page-number-input"
)[
0
]
page_input
.
click
()
page_input
.
send_keys
(
str
(
number
))
page_input
.
send_keys
(
Keys
.
RETURN
)
self
.
wait_until_ready
()
def
check_page_unchanged
(
self
,
first_block_name
):
"""
Used to make sure that a page has not transitioned after a bogus number is given.
"""
if
not
self
.
xblocks
[
0
]
.
name
==
first_block_name
:
return
False
if
not
self
.
q
(
css
=
'#page-number-input'
)[
0
]
.
get_attribute
(
'value'
)
==
''
:
return
False
return
True
def
_get_xblocks
(
self
):
"""
Create an XBlockWrapper for each XBlock div found on the page.
...
...
common/test/acceptance/tests/studio/test_studio_library.py
View file @
ed3b9720
"""
Acceptance tests for Content Libraries in Studio
"""
from
ddt
import
ddt
,
data
from
.base_studio_test
import
StudioLibraryTest
from
...pages.studio.utils
import
add_component
from
...pages.studio.library
import
LibraryPage
@ddt
class
LibraryEditPageTest
(
StudioLibraryTest
):
"""
Test the functionality of the library edit page.
...
...
@@ -107,3 +110,161 @@ class LibraryEditPageTest(StudioLibraryTest):
Ensure the UI is not loaded for adding discussions.
"""
self
.
assertFalse
(
self
.
browser
.
find_elements_by_css_selector
(
'span.large-discussion-icon'
))
def
test_library_pagination
(
self
):
"""
Scenario: Ensure that adding several XBlocks to a library results in pagination.
Given that I have a library in Studio with no XBlocks
And I create 10 Multiple Choice XBlocks
Then 10 are displayed.
When I add one more Multiple Choice XBlock
Then 1 XBlock will be displayed
When I delete that XBlock
Then 10 are displayed.
"""
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
0
)
for
_
in
range
(
0
,
10
):
add_component
(
self
.
lib_page
,
"problem"
,
"Multiple Choice"
)
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
10
)
add_component
(
self
.
lib_page
,
"problem"
,
"Multiple Choice"
)
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
1
)
self
.
lib_page
.
click_delete_button
(
self
.
lib_page
.
xblocks
[
0
]
.
locator
)
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
10
)
@data
(
'top'
,
'bottom'
)
def
test_nav_present_but_disabled
(
self
,
position
):
"""
Scenario: Ensure that the navigation buttons aren't active when there aren't enough XBlocks.
Given that I have a library in Studio with no XBlocks
The Navigation buttons should be disabled.
When I add 5 multiple Choice XBlocks
The Navigation buttons should be disabled.
"""
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
0
)
self
.
assertTrue
(
self
.
lib_page
.
nav_disabled
(
position
))
for
_
in
range
(
0
,
5
):
add_component
(
self
.
lib_page
,
"problem"
,
"Multiple Choice"
)
self
.
assertTrue
(
self
.
lib_page
.
nav_disabled
(
position
))
@data
(
'top'
,
'bottom'
)
def
test_nav_buttons
(
self
,
position
):
"""
Scenario: Ensure that the navigation buttons work.
Given that I have a library in Studio with no XBlocks
And I create 10 Multiple Choice XBlocks
And I create 10 Checkbox XBlocks
And I create 10 Dropdown XBlocks
And I revisit the page
The previous button should be disabled.
The first XBlock should be a Multiple Choice XBlock
Then if I hit the next button
The first XBlock should be a Checkboxes XBlock
Then if I hit the next button
The first XBlock should be a Dropdown XBlock
And the next button should be disabled
Then if I hit the previous button
The first XBlock should be an Checkboxes XBlock
Then if I hit the previous button
The first XBlock should be a Multipe Choice XBlock
And the previous button should be disabled
"""
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
0
)
block_types
=
[(
'problem'
,
'Multiple Choice'
),
(
'problem'
,
'Checkboxes'
),
(
'problem'
,
'Dropdown'
)]
for
block_type
in
block_types
:
for
_
in
range
(
0
,
10
):
add_component
(
self
.
lib_page
,
*
block_type
)
# Don't refresh, as that may contain additional state.
self
.
lib_page
.
revisit
()
# Check forward navigation
self
.
assertTrue
(
self
.
lib_page
.
nav_disabled
(
position
,
[
'previous'
]))
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Multiple Choice'
)
self
.
lib_page
.
move_forward
(
position
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Checkboxes'
)
self
.
lib_page
.
move_forward
(
position
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Dropdown'
)
self
.
lib_page
.
nav_disabled
(
position
,
[
'next'
])
# Check backward navigation
self
.
lib_page
.
move_back
(
position
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Checkboxes'
)
self
.
lib_page
.
move_back
(
position
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Multiple Choice'
)
self
.
assertTrue
(
self
.
lib_page
.
nav_disabled
(
position
,
[
'previous'
]))
def
test_arbitrary_page_selection
(
self
):
"""
Scenario: I can pick a specific page number of a Library at will.
Given that I have a library in Studio with no XBlocks
And I create 10 Multiple Choice XBlocks
And I create 10 Checkboxes XBlocks
And I create 10 Dropdown XBlocks
And I create 10 Numerical Input XBlocks
And I revisit the page
When I go to the 3rd page
The first XBlock should be a Dropdown XBlock
When I go to the 4th Page
The first XBlock should be a Numerical Input XBlock
When I go to the 1st page
The first XBlock should be a Multiple Choice XBlock
When I go to the 2nd page
The first XBlock should be a Checkboxes XBlock
"""
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
0
)
block_types
=
[
(
'problem'
,
'Multiple Choice'
),
(
'problem'
,
'Checkboxes'
),
(
'problem'
,
'Dropdown'
),
(
'problem'
,
'Numerical Input'
),
]
for
block_type
in
block_types
:
for
_
in
range
(
0
,
10
):
add_component
(
self
.
lib_page
,
*
block_type
)
# Don't refresh, as that may contain additional state.
self
.
lib_page
.
revisit
()
self
.
lib_page
.
go_to_page
(
3
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Dropdown'
)
self
.
lib_page
.
go_to_page
(
4
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Numerical Input'
)
self
.
lib_page
.
go_to_page
(
1
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Multiple Choice'
)
self
.
lib_page
.
go_to_page
(
2
)
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Checkboxes'
)
def
test_bogus_page_selection
(
self
):
"""
Scenario: I can't pick a nonsense page number of a Library
Given that I have a library in Studio with no XBlocks
And I create 10 Multiple Choice XBlocks
And I create 10 Checkboxes XBlocks
And I create 10 Dropdown XBlocks
And I create 10 Numerical Input XBlocks
And I revisit the page
When I attempt to go to the 'a'th page
The input field will be cleared and no change of XBlocks will be made
When I attempt to visit the 5th page
The input field will be cleared and no change of XBlocks will be made
When I attempt to visit the -1st page
The input field will be cleared and no change of XBlocks will be made
When I attempt to visit the 0th page
The input field will be cleared and no change of XBlocks will be made
"""
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
0
)
block_types
=
[
(
'problem'
,
'Multiple Choice'
),
(
'problem'
,
'Checkboxes'
),
(
'problem'
,
'Dropdown'
),
(
'problem'
,
'Numerical Input'
),
]
for
block_type
in
block_types
:
for
_
in
range
(
0
,
10
):
add_component
(
self
.
lib_page
,
*
block_type
)
self
.
lib_page
.
revisit
()
self
.
assertEqual
(
self
.
lib_page
.
xblocks
[
0
]
.
name
,
'Multiple Choice'
)
self
.
lib_page
.
go_to_page
(
'a'
)
self
.
assertTrue
(
self
.
lib_page
.
check_page_unchanged
(
'Multiple Choice'
))
self
.
lib_page
.
go_to_page
(
-
1
)
self
.
assertTrue
(
self
.
lib_page
.
check_page_unchanged
(
'Multiple Choice'
))
self
.
lib_page
.
go_to_page
(
5
)
self
.
assertTrue
(
self
.
lib_page
.
check_page_unchanged
(
'Multiple Choice'
))
self
.
lib_page
.
go_to_page
(
0
)
self
.
assertTrue
(
self
.
lib_page
.
check_page_unchanged
(
'Multiple Choice'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment