diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-08-07 01:23:16 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:02 +0200 |
commit | 5124549dd86b3a4522cc953768a93e4dcce1a89c (patch) | |
tree | ba8aedfa4f07511f11ce49fb60f1b656104c7ccb /archaeological_context_records/tests.py | |
parent | 8eeb37c0648690e4ffca7234b710e44be4359b20 (diff) | |
download | Ishtar-5124549dd86b3a4522cc953768a93e4dcce1a89c.tar.bz2 Ishtar-5124549dd86b3a4522cc953768a93e4dcce1a89c.zip |
PR for peer review
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r-- | archaeological_context_records/tests.py | 105 |
1 files changed, 104 insertions, 1 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index 0d1c84c7f..a71706e40 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -59,7 +59,7 @@ from ishtar_common.tests import ( GenericSerializationTest, COMMON_FIXTURES, WAREHOUSE_FIXTURES, - SearchText, + SearchText, SeleniumTests, ) from archaeological_operations.models import Operation @@ -1362,3 +1362,106 @@ class GraphGenerationTest(ContextRecordInit, TestCase): self.assertNotIn('"CR 4"', content) self.assertNotIn('"CR 2C"', content) self.assertNotIn('"CR 2D"', content) + + +class SeleniumTestsContextRecords(SeleniumTests): + fixtures = CONTEXT_RECORD_FIXTURES + + def test_geo_items(self): + def test_cr(i): + cr_label = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td[2]').text + if cr_label[3:5] == "Pt": + dic_base = dic_point + else: + dic_base = dic_polygon + cr = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td/a[@class="display_details"]') + self.scroll(cr) + cr.click() + self.WebDriverWait(self.selenium, 2).until( + lambda driver: driver.find_element_by_xpath( + '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]')) + self.selenium.find_element_by_xpath( + '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]') + dd = '//dl[@class="col-12"]/dd' + self.selenium.find_element_by_xpath(dd + '/label[text()="Display associated features: "]') + select = dd + '/select[@name="display-geo-items"]' + disp = self.selenium.find_element_by_xpath(select) + self.assertEqual(disp.get_attribute("value"), "") + self.assertMap(dic_base) + + # context record specific + + # click on "Base finds" + self.selenium.execute_script('return initialize_test_map()') + self.scroll(disp) + disp.click() + self.selenium.find_element_by_xpath(select + '/option[@value="basefinds"]').click() + cr_geoms = [ + {'type': 'FeatureCollection', + 'features': [ + {'geometry': + {'coordinates': [[[[1, 1], [5, 1], [5, 5], [1, 5], [1, 1]], [[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]], [[[6, 3], [9, 2], [9, 4], [6, 3]]]], + 'type': 'MultiPolygon'}, + 'properties': {'label': 'Find 1 from ' + cr_label}, + 'type': 'Feature'}, + {'geometry': {'coordinates': [], + 'type': 'MultiPolygon'}, + 'properties': {'label': 'Find 2 from ' + cr_label}, + 'type': 'Feature'}] + } + ] + self.assertMap(dic_base, cr_geoms) + + select_get_poly = dd + '/select[@name="get-polygons"]' + get_poly = self.selenium.find_element_by_xpath(select_get_poly) + self.selenium.execute_script('return initialize_test_map()') + get_poly.click() + self.selenium.find_element_by_xpath(select_get_poly + '/option[@value="points"]').click() + cr_geoms = [ + {'type': 'FeatureCollection', + 'features': [ + {'geometry': + {'coordinates': [3.861, 3.028], + 'type': 'Point'}, + 'properties': {'label': 'Find 1 from ' + cr_label}, + 'type': 'Feature'}, + {'geometry': {'coordinates': [2, 43], + 'type': 'Point'}, + 'properties': {'label': 'Find 2 from ' + cr_label}, + 'type': 'Feature'}] + } + ] + self.assertMap(dic_base, cr_geoms) + + # Click on "None" + self.selenium.execute_script('return initialize_test_map()') + disp.click() + self.selenium.find_element_by_xpath(select + '/option[@value=""]').click() + self.assertMap(dic_base) + + self.setUpDefaultGeoItems() + + dic_polygon = { + 'type': 'FeatureCollection', + 'features': [ + {'geometry': + {'coordinates': [[[[1,1],[5,1],[5,5],[1,5],[1,1]],[[2,2],[2,3],[3,3],[3,2],[2,2]]],[[[6,3],[9,2],[9,4],[6,3]]]], + 'type': 'MultiPolygon'}, + 'properties': {}, + 'type': 'Feature'} + ]} + dic_point = { + 'type': 'FeatureCollection', + 'features': [ + {'geometry': + {'coordinates': [2,43], + 'type': 'Point'}, + 'properties': {}, + 'type': 'Feature'} + ]} + for i in range(1, 5): + dropdown = self.selenium.find_element_by_xpath('//a[@class="nav-link dropdown-toggle"]') + self.scroll(dropdown) + dropdown.click() + self.selenium.find_element_by_xpath('//div[@class="dropdown-menu show"]/a[@href="/record_search/"]').click() + test_cr(i)
\ No newline at end of file |