Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
OpenEdx
xblock-drag-and-drop-v2
Commits
5b8a8465
Commit
5b8a8465
authored
Sep 30, 2014
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interaction tests: items feedback, final feedback and reset
parent
5cd4c402
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
25 deletions
+53
-25
tests/integration/test_base.py
+3
-0
tests/integration/test_block_contents_plain.py
+0
-19
tests/integration/test_interaction.py
+49
-4
tests/integration/test_render.py
+1
-2
No files found.
tests/integration/test_base.py
View file @
5b8a8465
...
@@ -34,6 +34,9 @@ class BaseIntegrationTest(SeleniumTest):
...
@@ -34,6 +34,9 @@ class BaseIntegrationTest(SeleniumTest):
scenarios
.
add_xml_scenario
(
identifier
,
title
,
xml
)
scenarios
.
add_xml_scenario
(
identifier
,
title
,
xml
)
self
.
addCleanup
(
scenarios
.
remove_scenario
,
identifier
)
self
.
addCleanup
(
scenarios
.
remove_scenario
,
identifier
)
def
_get_feedback_message
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".feedback .message"
)
def
go_to_page
(
self
,
page_name
,
css_selector
=
'section.xblock--drag-and-drop'
):
def
go_to_page
(
self
,
page_name
,
css_selector
=
'section.xblock--drag-and-drop'
):
"""
"""
Navigate to the page `page_name`, as listed on the workbench home
Navigate to the page `page_name`, as listed on the workbench home
...
...
tests/integration/test_block_contents_plain.py
deleted
100644 → 0
View file @
5cd4c402
from
tests.integration.test_base
import
SingleScenarioIntegrationTest
from
tests.utils
import
load_scenario_from_file
class
TestBlockContentsPlain
(
SingleScenarioIntegrationTest
):
def
_get_scenario_for_test
(
self
):
return
load_scenario_from_file
(
'integration/data/drag_and_drop-whats_up.json'
)
def
test_check_item_labels
(
self
):
page
=
self
.
go_to_page
(
self
.
_page_title
)
items_container
=
page
.
find_element_by_css_selector
(
'ul.items'
)
items
=
items_container
.
find_elements_by_css_selector
(
'li.option'
)
self
.
assertEqual
(
len
(
items
),
3
)
self
.
assertEqual
(
items
[
0
]
.
text
,
'A'
)
self
.
assertEqual
(
items
[
1
]
.
text
,
'B'
)
self
.
assertEqual
(
items
[
2
]
.
text
,
'X'
)
\ No newline at end of file
tests/integration/test_interaction.py
View file @
5b8a8465
from
nose_parameterized
import
parameterized
from
selenium.webdriver
import
ActionChains
from
selenium.webdriver
import
ActionChains
from
selenium.webdriver.firefox
import
webdriver
from
selenium.webdriver.firefox
import
webdriver
...
@@ -20,16 +21,60 @@ class TestInteraction(BaseIntegrationTest):
...
@@ -20,16 +21,60 @@ class TestInteraction(BaseIntegrationTest):
self
.
browser
.
get
(
self
.
live_server_url
)
self
.
browser
.
get
(
self
.
live_server_url
)
self
.
_page
=
self
.
go_to_page
(
self
.
PAGE_TITLE
)
self
.
_page
=
self
.
go_to_page
(
self
.
PAGE_TITLE
)
def
test_correct_item_positive_feedback
(
self
):
def
_get_item_by_value
(
self
,
item_value
):
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'ul.items'
)
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'ul.items'
)
return
items_container
.
find_elements_by_xpath
(
"//li[@data-value='{item_id}']"
.
format
(
item_id
=
item_value
))[
0
]
def
_get_zone_by_id
(
self
,
zone_id
):
zones_container
=
self
.
_page
.
find_element_by_css_selector
(
'div.target'
)
zones_container
=
self
.
_page
.
find_element_by_css_selector
(
'div.target'
)
element
=
items_container
.
find_elements_by_xpath
(
"//li[@data-value='0']"
)[
0
]
return
zones_container
.
find_elements_by_xpath
(
"//div[@data-zone='{zone_id}']"
.
format
(
zone_id
=
zone_id
))[
0
]
target
=
zones_container
.
find_elements_by_xpath
(
"//div[@data-zone='Zone A']"
)[
0
]
def
drag_item_to_zone
(
self
,
item_value
,
zone_id
):
element
=
self
.
_get_item_by_value
(
item_value
)
target
=
self
.
_get_zone_by_id
(
zone_id
)
action_chains
=
ActionChains
(
self
.
browser
)
action_chains
=
ActionChains
(
self
.
browser
)
action_chains
.
drag_and_drop
(
element
,
target
)
.
perform
()
action_chains
.
drag_and_drop
(
element
,
target
)
.
perform
()
self
.
assertEqual
(
self
.
_page
.
find_element_by_css_selector
(
".popup-content"
)
.
text
,
"Yes, it's an A"
)
@parameterized.expand
([
(
"Item A"
,
0
,
'Zone A'
,
"Yes, it's an A"
),
(
"Item B"
,
1
,
'Zone B'
,
"Yes, it's a B"
),
])
def
test_correct_item_positive_feedback
(
self
,
_
,
item_value
,
zone_id
,
expected_feedback
):
self
.
drag_item_to_zone
(
item_value
,
zone_id
)
self
.
assertEqual
(
self
.
_page
.
find_element_by_css_selector
(
".popup-content"
)
.
text
,
expected_feedback
)
@parameterized.expand
([
(
"Item A"
,
0
,
'Zone B'
,
"No, A does not belong here"
),
(
"Item B"
,
1
,
'Zone A'
,
"No, B does not belong here"
),
(
"Item X"
,
2
,
'Zone A'
,
"You silly, there are no zones for X"
),
(
"Item X"
,
2
,
'Zone B'
,
"You silly, there are no zones for X"
),
])
def
test_incorrect_item_negative_feedback
(
self
,
_
,
item_value
,
zone_id
,
expected_feedback
):
self
.
drag_item_to_zone
(
item_value
,
zone_id
)
self
.
assertEqual
(
self
.
_page
.
find_element_by_css_selector
(
".popup-content"
)
.
text
,
expected_feedback
)
def
test_final_feedback_and_reset
(
self
):
feedback_message
=
self
.
_get_feedback_message
()
self
.
assertEqual
(
feedback_message
.
text
,
"Intro Feed"
)
# precondition check
item0_initial_position
=
self
.
_get_item_by_value
(
0
)
.
location
item1_initial_position
=
self
.
_get_item_by_value
(
1
)
.
location
self
.
drag_item_to_zone
(
0
,
'Zone A'
)
self
.
drag_item_to_zone
(
1
,
'Zone B'
)
self
.
assertEqual
(
feedback_message
.
text
,
"Final Feed"
)
reset
=
self
.
_page
.
find_element_by_css_selector
(
".reset-button"
)
reset
.
click
()
self
.
assertEqual
(
feedback_message
.
text
,
"Intro Feed"
)
self
.
assertDictEqual
(
self
.
_get_item_by_value
(
0
)
.
location
,
item0_initial_position
)
self
.
assertDictEqual
(
self
.
_get_item_by_value
(
1
)
.
location
,
item1_initial_position
)
tests/integration/test_render.py
View file @
5b8a8465
...
@@ -24,8 +24,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -24,8 +24,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
def
_get_zones
(
self
):
def
_get_zones
(
self
):
return
self
.
_page
.
find_elements_by_css_selector
(
".drag-container .zone"
)
return
self
.
_page
.
find_elements_by_css_selector
(
".drag-container .zone"
)
def
_get_feedback_message
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".feedback .message"
)
def
test_items
(
self
):
def
test_items
(
self
):
items
=
self
.
_get_items
()
items
=
self
.
_get_items
()
...
...
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