Commit 9f33c1d7 by Andrew Gaylard

Add tests for borders, enabled and disabled.

parent e4bfb226
{
"zones": [
{
"index": 1,
"title": "Zone 1",
"description": "This describes zone 1",
"height": 178,
"width": 196,
"y": "30",
"x": "160",
"id": "zone-1"
},
{
"index": 2,
"title": "Zone 2",
"description": "This describes zone 2",
"height": 140,
"width": 340,
"y": "210",
"x": "86",
"id": "zone-2"
}
],
"items": [
{
"displayName": "1",
"imageURL": "https://placehold.it/100x100",
"imageDescription": "This describes the background image of item 1",
"feedback": {
"incorrect": "No, 1 does not belong here",
"correct": "Yes, 1 goes here"
},
"zone": "Zone 1",
"id": 0
},
{
"displayName": "2",
"imageURL": "https://placehold.it/100x100",
"imageDescription": "This describes the background image of item 2",
"feedback": {
"incorrect": "No, 2 does not belong here",
"correct": "Yes, 2 goes here"
},
"zone": "Zone 2",
"id": 1
},
{
"displayName": "X",
"imageURL": "",
"feedback": {
"incorrect": "You silly, there are no zones for X",
"correct": ""
},
"zone": "none",
"id": 2
}
],
"feedback": {
"start": "Drag the items onto the image above.",
"finish": "Good work! You have completed this drag and drop exercise."
},
"targetImgDescription": "This describes the target image",
"displayBorders": true,
"displayLabels": true
}
......@@ -33,7 +33,11 @@ class TestDragAndDropRender(BaseIntegrationTest):
PAGE_ID = 'drag_and_drop_v2'
ITEM_PROPERTIES = [{'text': '1'}, {'text': '2'}, {'text': 'X'}, ]
def load_scenario(self, item_background_color="", item_text_color=""):
def load_scenario(self, item_background_color="", item_text_color="", borders=False):
if borders:
json="integration/data/test_data_a11y_borders.json"
else:
json="integration/data/test_data_a11y.json"
scenario_xml = """
<vertical_demo>
<drag-and-drop-v2 item_background_color='{item_background_color}'
......@@ -43,7 +47,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
""".format(
item_background_color=item_background_color,
item_text_color=item_text_color,
data=load_resource("integration/data/test_data_a11y.json")
data=load_resource(json)
)
self._add_scenario(self.PAGE_ID, self.PAGE_TITLE, scenario_xml)
......@@ -57,6 +61,10 @@ class TestDragAndDropRender(BaseIntegrationTest):
query = 'return $("{selector}").get(0).style.{style}'
return self.browser.execute_script(query.format(selector=selector, style=style))
def _get_border_style(self, id, style):
query = 'return window.getComputedStyle(document.getElementById("{id}"), null).getPropertyValue("{style}")'
return self.browser.execute_script(query.format(id=id, style=style))
def _assert_box_percentages(self, selector, left, top, width, height):
""" Assert that the element 'selector' has the specified position/size percentages """
values = {key: self._get_style(selector, key, False) for key in ['left', 'top', 'width', 'height']}
......@@ -194,3 +202,21 @@ class TestDragAndDropRender(BaseIntegrationTest):
image_path = '/resource/drag-and-drop-v2/public/img/triangle.png'
self.assertTrue(bg_image.get_attribute("src").endswith(image_path))
self.assertEqual(bg_image.get_attribute("alt"), 'This describes the target image')
def test_borders_inactive(self):
self.load_scenario()
zones = self._get_zones()
for index, zone in enumerate(zones):
id = 'zone-{}'.format(index + 1)
# Firefox does not provide a single "border-style", so we check "border-top-style"
self.assertEqual(self._get_border_style(id, 'border-top-style'), 'none')
self.assertEqual(self._get_border_style(id, 'border-top-width'), '0px')
def test_borders_active(self):
self.load_scenario("", "", True)
zones = self._get_zones()
for index, zone in enumerate(zones):
id = 'zone-{}'.format(index + 1)
self.assertEqual(self._get_border_style(id, 'border-top-style'), 'dotted')
self.assertEqual(self._get_border_style(id, 'border-top-width'), '1px')
self.assertEqual(self._get_border_style(id, 'border-top-color'), 'rgb(86, 86, 86)') # == #565656
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