mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-01 21:02:15 +00:00
Potentially make modal tests more consistent
This commit is contained in:
@@ -202,6 +202,10 @@ class AssetAuditList(AssetList):
|
|||||||
def search(self):
|
def search(self):
|
||||||
self.find_element(*self._go_button_locator).click()
|
self.find_element(*self._go_button_locator).click()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def modal_is_displayed(self):
|
||||||
|
return self.driver.find_element_by_id('modal').is_displayed()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def error(self):
|
def error(self):
|
||||||
try:
|
try:
|
||||||
@@ -231,10 +235,6 @@ class AssetAuditList(AssetList):
|
|||||||
'cores': (regions.TextBox, (By.ID, 'id_cores'))
|
'cores': (regions.TextBox, (By.ID, 'id_cores'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
|
||||||
def is_displayed(self):
|
|
||||||
return self.root.is_displayed()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def errors(self):
|
def errors(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -280,20 +280,20 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
|
|
||||||
mdl = self.page.modal
|
mdl = self.page.modal
|
||||||
self.assertTrue(mdl.is_displayed)
|
self.assertTrue(self.page.modal_is_displayed)
|
||||||
# Do it wrong on purpose to check error display
|
# Do it wrong on purpose to check error display
|
||||||
mdl.remove_all_required()
|
mdl.remove_all_required()
|
||||||
mdl.description = ""
|
mdl.description = ""
|
||||||
mdl.submit()
|
mdl.submit()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
self.assertTrue(mdl.is_displayed)
|
self.assertTrue(self.page.modal_is_displayed)
|
||||||
self.assertIn("This field is required.", mdl.errors["Description"])
|
self.assertIn("This field is required.", mdl.errors["Description"])
|
||||||
# Now do it properly
|
# Now do it properly
|
||||||
new_desc = "A BIG hammer"
|
new_desc = "A BIG hammer"
|
||||||
mdl.description = new_desc
|
mdl.description = new_desc
|
||||||
mdl.submit()
|
mdl.submit()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
self.assertFalse(mdl.is_displayed)
|
self.assertFalse(self.page.modal_is_displayed)
|
||||||
|
|
||||||
# Check data is correct
|
# Check data is correct
|
||||||
audited = models.Asset.objects.get(asset_id="1111")
|
audited = models.Asset.objects.get(asset_id="1111")
|
||||||
@@ -312,14 +312,13 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
assetRow = self.page.assets[0]
|
assetRow = self.page.assets[0]
|
||||||
assetRow.find_element(By.CSS_SELECTOR, "td:nth-child(5) > div:nth-child(1) > a:nth-child(1)").click()
|
assetRow.find_element(By.CSS_SELECTOR, "td:nth-child(5) > div:nth-child(1) > a:nth-child(1)").click()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
mdl = self.page.modal
|
self.assertTrue(self.page.modal_is_displayed)
|
||||||
self.assertTrue(mdl.is_displayed)
|
self.assertEqual(self.page.modal.asset_id, assetRow.id)
|
||||||
self.assertEqual(mdl.asset_id, assetRow.id)
|
|
||||||
|
|
||||||
# First close button is for the not found error
|
# First close button is for the not found error
|
||||||
mdl.find_element(By.XPATH, '(//button[@class="close"])[2]').click()
|
self.page.find_element(By.XPATH, '(//button[@class="close"])[2]').click()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
self.assertFalse(mdl.is_displayed)
|
self.assertFalse(self.page.modal_is_displayed)
|
||||||
# Make sure audit log was NOT filled out
|
# Make sure audit log was NOT filled out
|
||||||
audited = models.Asset.objects.get(asset_id=assetRow.id)
|
audited = models.Asset.objects.get(asset_id=assetRow.id)
|
||||||
self.assertEqual(None, audited.last_audited_by)
|
self.assertEqual(None, audited.last_audited_by)
|
||||||
@@ -328,7 +327,7 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.page.set_query("NOTFOUND")
|
self.page.set_query("NOTFOUND")
|
||||||
self.page.search()
|
self.page.search()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
self.assertFalse(self.page.modal.is_displayed)
|
self.assertFalse(self.page.modal_is_displayed)
|
||||||
self.assertIn("Asset with that ID does not exist!", self.page.error.text)
|
self.assertIn("Asset with that ID does not exist!", self.page.error.text)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user