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
d7f98f5a
Commit
d7f98f5a
authored
Dec 14, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix integration tests
parent
362da63d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
95 deletions
+67
-95
drag_and_drop_v2/public/js/drag_and_drop.js
+0
-4
drag_and_drop_v2/public/js/view.js
+6
-0
tests/integration/data/test_data.json
+2
-18
tests/integration/data/test_html_data.json
+5
-21
tests/integration/test_base.py
+3
-3
tests/integration/test_custom_data_render.py
+6
-3
tests/integration/test_interaction.py
+9
-7
tests/integration/test_render.py
+36
-39
No files found.
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
d7f98f5a
function
DragAndDropBlock
(
runtime
,
element
,
configuration
)
{
function
DragAndDropBlock
(
runtime
,
element
,
configuration
)
{
"use strict"
;
"use strict"
;
// Set up a mock for gettext if it isn't available in the client runtime:
if
(
!
window
.
gettext
)
{
var
gettext
=
function
gettext_stub
(
string
)
{
return
string
;
};
}
var
$element
=
$
(
element
);
var
$element
=
$
(
element
);
// root: root node managed by the virtual DOM
// root: root node managed by the virtual DOM
...
...
drag_and_drop_v2/public/js/view.js
View file @
d7f98f5a
(
function
(
h
)
{
(
function
(
h
)
{
"use strict"
;
"use strict"
;
// Set up a mock for gettext if it isn't available in the client runtime:
if
(
!
window
.
gettext
)
{
var
gettext
=
function
gettext_stub
(
string
)
{
return
string
;
};
}
var
FocusHook
=
function
()
{
var
FocusHook
=
function
()
{
if
(
!
(
this
instanceof
FocusHook
))
{
if
(
!
(
this
instanceof
FocusHook
))
{
return
new
FocusHook
();
return
new
FocusHook
();
...
...
tests/integration/data/test_data.json
View file @
d7f98f5a
...
@@ -28,11 +28,7 @@
...
@@ -28,11 +28,7 @@
},
},
"zone"
:
"Zone 1"
,
"zone"
:
"Zone 1"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
0
,
"id"
:
0
"size"
:
{
"width"
:
"190px"
,
"height"
:
"auto"
}
},
},
{
{
"displayName"
:
"2 here"
,
"displayName"
:
"2 here"
,
...
@@ -43,10 +39,6 @@
...
@@ -43,10 +39,6 @@
"zone"
:
"Zone 2"
,
"zone"
:
"Zone 2"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
1
,
"id"
:
1
,
"size"
:
{
"width"
:
"190px"
,
"height"
:
"auto"
},
"inputOptions"
:
{
"inputOptions"
:
{
"value"
:
100
,
"value"
:
100
,
"margin"
:
5
"margin"
:
5
...
@@ -60,17 +52,9 @@
...
@@ -60,17 +52,9 @@
},
},
"zone"
:
"none"
,
"zone"
:
"none"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
2
,
"id"
:
2
"size"
:
{
"width"
:
"100px"
,
"height"
:
"100px"
}
}
}
],
],
"state"
:
{
"items"
:
{},
"finished"
:
true
},
"feedback"
:
{
"feedback"
:
{
"start"
:
"Other Intro Feed"
,
"start"
:
"Other Intro Feed"
,
"finish"
:
"Other Final Feed"
"finish"
:
"Other Final Feed"
...
...
tests/integration/data/test_html_data.json
View file @
d7f98f5a
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
"width"
:
200
,
"width"
:
200
,
"title"
:
"Zone <i>1</i>"
,
"title"
:
"Zone <i>1</i>"
,
"height"
:
100
,
"height"
:
100
,
"y"
:
"200"
,
"y"
:
200
,
"x"
:
"100"
,
"x"
:
100
,
"id"
:
"zone-1"
"id"
:
"zone-1"
},
},
{
{
...
@@ -28,11 +28,7 @@
...
@@ -28,11 +28,7 @@
},
},
"zone"
:
"Zone <i>1</i>"
,
"zone"
:
"Zone <i>1</i>"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
0
,
"id"
:
0
"size"
:
{
"width"
:
"190px"
,
"height"
:
"auto"
}
},
},
{
{
"displayName"
:
"<i>2</i>"
,
"displayName"
:
"<i>2</i>"
,
...
@@ -43,10 +39,6 @@
...
@@ -43,10 +39,6 @@
"zone"
:
"Zone <b>2</b>"
,
"zone"
:
"Zone <b>2</b>"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
1
,
"id"
:
1
,
"size"
:
{
"width"
:
"190px"
,
"height"
:
"auto"
},
"inputOptions"
:
{
"inputOptions"
:
{
"value"
:
100
,
"value"
:
100
,
"margin"
:
5
"margin"
:
5
...
@@ -60,20 +52,12 @@
...
@@ -60,20 +52,12 @@
},
},
"zone"
:
"none"
,
"zone"
:
"none"
,
"backgroundImage"
:
""
,
"backgroundImage"
:
""
,
"id"
:
2
,
"id"
:
2
"size"
:
{
"width"
:
"100px"
,
"height"
:
"100px"
}
}
}
],
],
"state"
:
{
"items"
:
{},
"finished"
:
true
},
"feedback"
:
{
"feedback"
:
{
"start"
:
"Intro <i>Feed</i>"
,
"start"
:
"Intro <i>Feed</i>"
,
"finish"
:
"Final <b>Feed</b>"
"finish"
:
"Final <b>Feed</b>"
},
},
"targetImg"
:
"
https://www.edx.org/sites/default/files/theme/edx-logo-header.png
"
"targetImg"
:
"
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBzdHlsZT0iYmFja2dyb3VuZDogI2VlZjsiPjwvc3ZnPg==
"
}
}
tests/integration/test_base.py
View file @
d7f98f5a
...
@@ -21,7 +21,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
...
@@ -21,7 +21,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
def
_make_scenario_xml
(
self
,
display_name
,
show_title
,
question_text
,
completed
=
False
,
show_question_header
=
True
):
def
_make_scenario_xml
(
self
,
display_name
,
show_title
,
question_text
,
completed
=
False
,
show_question_header
=
True
):
return
"""
return
"""
<vertical_demo>
<vertical_demo>
<drag-and-drop-v2
<drag-and-drop-v2
display_name='{display_name}'
display_name='{display_name}'
show_title='{show_title}'
show_title='{show_title}'
...
@@ -30,7 +30,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
...
@@ -30,7 +30,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
weight='1'
weight='1'
completed='{completed}'
completed='{completed}'
/>
/>
</vertical_demo>
</vertical_demo>
"""
.
format
(
"""
.
format
(
display_name
=
escape
(
display_name
),
display_name
=
escape
(
display_name
),
show_title
=
show_title
,
show_title
=
show_title
,
...
@@ -50,7 +50,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
...
@@ -50,7 +50,7 @@ class BaseIntegrationTest(SeleniumBaseTest):
self
.
addCleanup
(
scenarios
.
remove_scenario
,
identifier
)
self
.
addCleanup
(
scenarios
.
remove_scenario
,
identifier
)
def
_get_items
(
self
):
def
_get_items
(
self
):
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'.item
s
'
)
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'.item
-bank
'
)
return
items_container
.
find_elements_by_css_selector
(
'.option'
)
return
items_container
.
find_elements_by_css_selector
(
'.option'
)
def
_get_zones
(
self
):
def
_get_zones
(
self
):
...
...
tests/integration/test_custom_data_render.py
View file @
d7f98f5a
...
@@ -26,6 +26,9 @@ class TestCustomDataDragAndDropRendering(BaseIntegrationTest):
...
@@ -26,6 +26,9 @@ class TestCustomDataDragAndDropRendering(BaseIntegrationTest):
self
.
assertIn
(
'<span style="color:red">X</span>'
,
self
.
get_element_html
(
items
[
2
]))
self
.
assertIn
(
'<span style="color:red">X</span>'
,
self
.
get_element_html
(
items
[
2
]))
def
test_background_image
(
self
):
def
test_background_image
(
self
):
bg_image
=
self
.
browser
.
execute_script
(
'return jQuery(".target-img").css("background-image")'
)
bg_image
=
self
.
browser
.
find_element_by_css_selector
(
".xblock--drag-and-drop .target-img"
)
custom_image_url
=
'https://www.edx.org/sites/default/files/theme/edx-logo-header.png'
custom_image_url
=
(
self
.
assertEqual
(
bg_image
,
'url("{}")'
.
format
(
custom_image_url
))
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciI"
"HdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBzdHlsZT0iYmFja2dyb3VuZDogI2VlZjsiPjwvc3ZnPg=="
)
self
.
assertEqual
(
bg_image
.
get_attribute
(
"src"
),
custom_image_url
)
tests/integration/test_interaction.py
View file @
d7f98f5a
...
@@ -12,7 +12,7 @@ class ItemDefinition(object):
...
@@ -12,7 +12,7 @@ class ItemDefinition(object):
self
.
input
=
input
self
.
input
=
input
class
InteractionTestFixture
(
BaseIntegrationTes
t
):
class
InteractionTestFixture
(
objec
t
):
"""
"""
Verifying Drag and Drop XBlock rendering against default data - if default data changes this would probably broke
Verifying Drag and Drop XBlock rendering against default data - if default data changes this would probably broke
"""
"""
...
@@ -28,8 +28,8 @@ class InteractionTestFixture(BaseIntegrationTest):
...
@@ -28,8 +28,8 @@ class InteractionTestFixture(BaseIntegrationTest):
all_zones
=
[
'Zone 1'
,
'Zone 2'
]
all_zones
=
[
'Zone 1'
,
'Zone 2'
]
feedback
=
{
feedback
=
{
"intro"
:
"
Intro Feed
"
,
"intro"
:
"
Drag the items onto the image above.
"
,
"final"
:
"
Final Feed
"
"final"
:
"
Good work! You have completed this drag and drop exercise.
"
}
}
def
_get_scenario_xml
(
self
):
def
_get_scenario_xml
(
self
):
...
@@ -54,7 +54,7 @@ class InteractionTestFixture(BaseIntegrationTest):
...
@@ -54,7 +54,7 @@ class InteractionTestFixture(BaseIntegrationTest):
self
.
browser
.
set_window_size
(
1024
,
800
)
self
.
browser
.
set_window_size
(
1024
,
800
)
def
_get_item_by_value
(
self
,
item_value
):
def
_get_item_by_value
(
self
,
item_value
):
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'.item
s
'
)
items_container
=
self
.
_page
.
find_element_by_css_selector
(
'.item
-bank
'
)
return
items_container
.
find_elements_by_xpath
(
"//div[@data-value='{item_id}']"
.
format
(
item_id
=
item_value
))[
0
]
return
items_container
.
find_elements_by_xpath
(
"//div[@data-value='{item_id}']"
.
format
(
item_id
=
item_value
))[
0
]
def
_get_zone_by_id
(
self
,
zone_id
):
def
_get_zone_by_id
(
self
,
zone_id
):
...
@@ -128,7 +128,9 @@ class InteractionTestFixture(BaseIntegrationTest):
...
@@ -128,7 +128,9 @@ class InteractionTestFixture(BaseIntegrationTest):
self
.
assertEqual
(
self
.
get_element_html
(
feedback_message
),
self
.
feedback
[
'intro'
])
# precondition check
self
.
assertEqual
(
self
.
get_element_html
(
feedback_message
),
self
.
feedback
[
'intro'
])
# precondition check
items
=
self
.
_get_correct_item_for_zone
()
items
=
self
.
_get_correct_item_for_zone
()
get_locations
=
lambda
:
{
item_id
:
self
.
_get_item_by_value
(
item_id
)
.
location
for
item_id
in
items
.
keys
()}
def
get_locations
():
return
{
item_id
:
self
.
_get_item_by_value
(
item_id
)
.
location
for
item_id
in
items
.
keys
()}
initial_locations
=
get_locations
()
initial_locations
=
get_locations
()
...
@@ -157,7 +159,7 @@ class InteractionTestFixture(BaseIntegrationTest):
...
@@ -157,7 +159,7 @@ class InteractionTestFixture(BaseIntegrationTest):
self
.
assertDictEqual
(
locations_after_reset
[
item_key
],
initial_locations
[
item_key
])
self
.
assertDictEqual
(
locations_after_reset
[
item_key
],
initial_locations
[
item_key
])
class
CustomDataInteractionTest
(
InteractionTestFixture
):
class
CustomDataInteractionTest
(
InteractionTestFixture
,
BaseIntegrationTest
):
items_map
=
{
items_map
=
{
0
:
ItemDefinition
(
0
,
'Zone 1'
,
"Yes 1"
,
"No 1"
),
0
:
ItemDefinition
(
0
,
'Zone 1'
,
"Yes 1"
,
"No 1"
),
1
:
ItemDefinition
(
1
,
'Zone 2'
,
"Yes 2"
,
"No 2"
,
"102"
),
1
:
ItemDefinition
(
1
,
'Zone 2'
,
"Yes 2"
,
"No 2"
,
"102"
),
...
@@ -175,7 +177,7 @@ class CustomDataInteractionTest(InteractionTestFixture):
...
@@ -175,7 +177,7 @@ class CustomDataInteractionTest(InteractionTestFixture):
return
self
.
_get_custom_scenario_xml
(
"integration/data/test_data.json"
)
return
self
.
_get_custom_scenario_xml
(
"integration/data/test_data.json"
)
class
CustomHtmlDataInteractionTest
(
InteractionTestFixture
):
class
CustomHtmlDataInteractionTest
(
InteractionTestFixture
,
BaseIntegrationTest
):
items_map
=
{
items_map
=
{
0
:
ItemDefinition
(
0
,
'Zone <i>1</i>'
,
"Yes <b>1</b>"
,
"No <b>1</b>"
),
0
:
ItemDefinition
(
0
,
'Zone <i>1</i>'
,
"Yes <b>1</b>"
,
"No <b>1</b>"
),
1
:
ItemDefinition
(
1
,
'Zone <b>2</b>'
,
"Yes <i>2</i>"
,
"No <i>2</i>"
,
"95"
),
1
:
ItemDefinition
(
1
,
'Zone <b>2</b>'
,
"Yes <i>2</i>"
,
"No <i>2</i>"
,
"95"
),
...
...
tests/integration/test_render.py
View file @
d7f98f5a
...
@@ -19,18 +19,16 @@ class Colors(object):
...
@@ -19,18 +19,16 @@ class Colors(object):
elif
color
==
cls
.
CORNFLOWERBLUE
:
elif
color
==
cls
.
CORNFLOWERBLUE
:
return
'rgb(100, 149, 237)'
return
'rgb(100, 149, 237)'
@ddt
@ddt
class
TestDragAndDropRender
(
BaseIntegrationTest
):
class
TestDragAndDropRender
(
BaseIntegrationTest
):
"""
"""
Verifying Drag and Drop XBlock rendering against default data - if default data changes this would probably broke
Verifying Drag and Drop XBlock rendering against default data - if default data changes this
will probably break.
"""
"""
PAGE_TITLE
=
'Drag and Drop v2'
PAGE_TITLE
=
'Drag and Drop v2'
PAGE_ID
=
'drag_and_drop_v2'
PAGE_ID
=
'drag_and_drop_v2'
ITEM_PROPERTIES
=
[
ITEM_PROPERTIES
=
[{
'text'
:
'1'
},
{
'text'
:
'2'
},
{
'text'
:
'X'
},
]
{
'text'
:
'1'
,
'style_settings'
:
{
'width'
:
'190px'
,
'height'
:
'auto'
}},
{
'text'
:
'2'
,
'style_settings'
:
{
'width'
:
'190px'
,
'height'
:
'auto'
}},
{
'text'
:
'X'
,
'style_settings'
:
{
'width'
:
'100px'
,
'height'
:
'100px'
}},
]
def
load_scenario
(
self
,
item_background_color
=
""
,
item_text_color
=
""
):
def
load_scenario
(
self
,
item_background_color
=
""
,
item_text_color
=
""
):
scenario_xml
=
"""
scenario_xml
=
"""
...
@@ -43,22 +41,27 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -43,22 +41,27 @@ class TestDragAndDropRender(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
_get_style
(
self
,
selector
,
style
):
def
_get_style
(
self
,
selector
,
style
,
computed
=
True
):
return
self
.
browser
.
execute_script
(
if
computed
:
'return getComputedStyle($("{selector}").get(0)).{style}'
.
format
(
selector
=
selector
,
style
=
style
)
query
=
'return getComputedStyle($("{selector}").get(0)).{style}'
)
else
:
query
=
'return $("{selector}").get(0).style.{style}'
def
_test_style
(
self
,
element
,
style_settings
,
element_type
):
return
self
.
browser
.
execute_script
(
query
.
format
(
selector
=
selector
,
style
=
style
))
style
=
element
.
get_attribute
(
'style'
)
for
style_prop
,
expected_value
in
style_settings
.
items
():
def
_assert_box_percentages
(
self
,
selector
,
left
,
top
,
width
,
height
):
if
style_prop
==
'color'
or
style_prop
==
'background-color'
and
expected_value
.
startswith
(
'#'
):
""" Assert that the element 'selector' has the specified position/size percentages """
expected_value
=
Colors
.
rgb
(
expected_value
)
values
=
{
key
:
self
.
_get_style
(
selector
,
key
,
False
)
for
key
in
[
'left'
,
'top'
,
'width'
,
'height'
]}
expected
=
u"{0}: {1}"
.
format
(
style_prop
,
expected_value
)
for
key
in
values
:
self
.
assertIn
(
expected
,
style
)
self
.
assertTrue
(
values
[
key
]
.
endswith
(
'
%
'
))
if
element_type
==
"item"
:
values
[
key
]
=
float
(
values
[
key
][:
-
1
])
self
.
_test_item_style
(
element
,
style_settings
,
style
)
self
.
assertAlmostEqual
(
values
[
'left'
],
left
,
places
=
2
)
self
.
assertAlmostEqual
(
values
[
'top'
],
top
,
places
=
2
)
def
_test_item_style
(
self
,
item
,
style_settings
,
style
):
self
.
assertAlmostEqual
(
values
[
'width'
],
width
,
places
=
2
)
self
.
assertAlmostEqual
(
values
[
'height'
],
height
,
places
=
2
)
def
_test_item_style
(
self
,
item_element
,
style_settings
):
item_val
=
item_element
.
get_attribute
(
'data-value'
)
style
=
item_element
.
get_attribute
(
'style'
)
# Check background color
# Check background color
background_color_property
=
'background-color'
background_color_property
=
'background-color'
if
background_color_property
not
in
style_settings
:
if
background_color_property
not
in
style_settings
:
...
@@ -66,18 +69,18 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -66,18 +69,18 @@ class TestDragAndDropRender(BaseIntegrationTest):
expected_background_color
=
Colors
.
BLUE
expected_background_color
=
Colors
.
BLUE
else
:
else
:
expected_background_color
=
Colors
.
rgb
(
style_settings
[
'background-color'
])
expected_background_color
=
Colors
.
rgb
(
style_settings
[
'background-color'
])
background_color
=
self
.
_get_style
(
'.item
s .option
'
,
'backgroundColor'
)
background_color
=
self
.
_get_style
(
'.item
-bank .option[data-value='
+
item_val
+
']
'
,
'backgroundColor'
)
self
.
assertEquals
(
background_color
,
expected_background_color
)
self
.
assertEquals
(
background_color
,
expected_background_color
)
# Check text color
# Check text color
color_property
=
'color'
color_property
=
'color'
if
color_property
not
in
style_settings
:
if
color_property
not
in
style_settings
:
self
.
assertNotIn
(
' '
+
color_property
,
style
)
# Leading space makes sure that
# Leading space below ensures that test does not find "color" in "background-color"
# test does not find "color" in "background-color"
self
.
assertNotIn
(
' '
+
color_property
,
style
)
expected_color
=
Colors
.
WHITE
expected_color
=
Colors
.
WHITE
else
:
else
:
expected_color
=
Colors
.
rgb
(
style_settings
[
'color'
])
expected_color
=
Colors
.
rgb
(
style_settings
[
'color'
])
color
=
self
.
_get_style
(
'.item
s .option
'
,
'color'
)
color
=
self
.
_get_style
(
'.item
-bank .option[data-value='
+
item_val
+
']
'
,
'color'
)
self
.
assertEquals
(
color
,
expected_color
)
self
.
assertEquals
(
color
,
expected_color
)
def
test_items
(
self
):
def
test_items
(
self
):
...
@@ -91,7 +94,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -91,7 +94,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
self
.
assertEqual
(
item
.
get_attribute
(
'data-value'
),
str
(
index
))
self
.
assertEqual
(
item
.
get_attribute
(
'data-value'
),
str
(
index
))
self
.
assertEqual
(
item
.
text
,
self
.
ITEM_PROPERTIES
[
index
][
'text'
])
self
.
assertEqual
(
item
.
text
,
self
.
ITEM_PROPERTIES
[
index
][
'text'
])
self
.
assertIn
(
'ui-draggable'
,
self
.
get_element_classes
(
item
))
self
.
assertIn
(
'ui-draggable'
,
self
.
get_element_classes
(
item
))
self
.
_test_
style
(
item
,
self
.
ITEM_PROPERTIES
[
index
][
'style_settings'
],
element_type
=
'item'
)
self
.
_test_
item_style
(
item
,
{}
)
@unpack
@unpack
@data
(
@data
(
...
@@ -116,9 +119,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -116,9 +119,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
self
.
assertEqual
(
item
.
get_attribute
(
'data-value'
),
str
(
index
))
self
.
assertEqual
(
item
.
get_attribute
(
'data-value'
),
str
(
index
))
self
.
assertEqual
(
item
.
text
,
self
.
ITEM_PROPERTIES
[
index
][
'text'
])
self
.
assertEqual
(
item
.
text
,
self
.
ITEM_PROPERTIES
[
index
][
'text'
])
self
.
assertIn
(
'ui-draggable'
,
self
.
get_element_classes
(
item
))
self
.
assertIn
(
'ui-draggable'
,
self
.
get_element_classes
(
item
))
self
.
_test_style
(
self
.
_test_item_style
(
item
,
color_settings
)
item
,
dict
(
self
.
ITEM_PROPERTIES
[
index
][
'style_settings'
],
**
color_settings
),
element_type
=
'item'
)
def
test_zones
(
self
):
def
test_zones
(
self
):
self
.
load_scenario
()
self
.
load_scenario
()
...
@@ -129,26 +130,22 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -129,26 +130,22 @@ class TestDragAndDropRender(BaseIntegrationTest):
self
.
assertEqual
(
zones
[
0
]
.
get_attribute
(
'data-zone'
),
'Zone 1'
)
self
.
assertEqual
(
zones
[
0
]
.
get_attribute
(
'data-zone'
),
'Zone 1'
)
self
.
assertIn
(
'ui-droppable'
,
self
.
get_element_classes
(
zones
[
0
]))
self
.
assertIn
(
'ui-droppable'
,
self
.
get_element_classes
(
zones
[
0
]))
self
.
_test_style
(
self
.
_assert_box_percentages
(
'#zone-1'
,
left
=
31.1284
,
top
=
6.17284
,
width
=
38.1323
,
height
=
36.6255
)
zones
[
0
],
{
'top'
:
'200px'
,
'left'
:
'120px'
,
'width'
:
'200px'
,
'height'
:
'100px'
},
element_type
=
'zone'
)
self
.
assertEqual
(
zones
[
1
]
.
get_attribute
(
'data-zone'
),
'Zone 2'
)
self
.
assertEqual
(
zones
[
1
]
.
get_attribute
(
'data-zone'
),
'Zone 2'
)
self
.
assertIn
(
'ui-droppable'
,
self
.
get_element_classes
(
zones
[
1
]))
self
.
assertIn
(
'ui-droppable'
,
self
.
get_element_classes
(
zones
[
1
]))
self
.
_test_style
(
self
.
_assert_box_percentages
(
'#zone-2'
,
left
=
16.7315
,
top
=
43.2099
,
width
=
66.1479
,
height
=
28.8066
)
zones
[
1
],
{
'top'
:
'360px'
,
'left'
:
'120px'
,
'width'
:
'200px'
,
'height'
:
'100px'
},
element_type
=
'zone'
)
def
test_feedback
(
self
):
def
test_feedback
(
self
):
self
.
load_scenario
()
self
.
load_scenario
()
feedback_message
=
self
.
_get_feedback_message
()
feedback_message
=
self
.
_get_feedback_message
()
self
.
assertEqual
(
feedback_message
.
text
,
"
Intro Feed
"
)
self
.
assertEqual
(
feedback_message
.
text
,
"
Drag the items onto the image above.
"
)
def
test_background_image
(
self
):
def
test_background_image
(
self
):
self
.
load_scenario
()
self
.
load_scenario
()
bg_image
=
self
.
browser
.
execute_script
(
'return jQuery(".target-img").css("background-image")'
)
bg_image
=
self
.
browser
.
find_element_by_css_selector
(
".xblock--drag-and-drop .target-img"
)
image_path
=
'/resource/drag-and-drop-v2/public/img/triangle.png'
image_path
=
'/resource/drag-and-drop-v2/public/img/triangle.png'
self
.
assert
Equal
(
bg_image
,
'url("{0}{1}")'
.
format
(
self
.
live_server_url
,
image_path
))
self
.
assert
True
(
bg_image
.
get_attribute
(
"src"
)
.
endswith
(
image_path
))
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