From a99e4b1d1c5aa113ffff057d8761f43ced466e14 Mon Sep 17 00:00:00 2001 From: Arona Jones Date: Tue, 26 Jan 2021 21:51:59 +0000 Subject: [PATCH] What about this? Swear I spend my life jiggerypokerying the damn test suite... --- .github/workflows/django.yml | 2 +- PyRIGS/tests/base.py | 3 --- assets/tests/pages.py | 1 + assets/tests/test_assets.py | 17 ++++++++--------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index cffd27f3..ad548bd9 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -58,7 +58,7 @@ jobs: if: failure() # Screenshots only make sense for the non-parallel, i.e. interaction tests anyway with: name: failure-screenshots ${{ matrix.test-group }} - path: screenshots/* + path: screenshots/ retention-days: 5 - name: Run Tests (Parallel) if: ${{ matrix.parallel }} diff --git a/PyRIGS/tests/base.py b/PyRIGS/tests/base.py index 0cacca87..96ea899e 100644 --- a/PyRIGS/tests/base.py +++ b/PyRIGS/tests/base.py @@ -20,9 +20,6 @@ def create_datetime(year, month, day, hour, min): def create_browser(): options = webdriver.ChromeOptions() options.add_argument("--window-size=1920,1080") - # No caching, please and thank you - options.add_argument("--aggressive-cache-discard") - options.add_argument("--disk-cache-size=0") options.add_argument("--headless") if settings.CI: options.add_argument("--no-sandbox") diff --git a/assets/tests/pages.py b/assets/tests/pages.py index d6a85b3e..529a81cd 100644 --- a/assets/tests/pages.py +++ b/assets/tests/pages.py @@ -243,6 +243,7 @@ class AssetAuditList(AssetList): # self.wait.until(lambda x: not self.is_displayed) TODO def close(self): + previous_errors = self.errors self.page.find_element(*self._close_selector).click() def remove_all_required(self): diff --git a/assets/tests/test_assets.py b/assets/tests/test_assets.py index fc14bb75..f73be0fb 100644 --- a/assets/tests/test_assets.py +++ b/assets/tests/test_assets.py @@ -294,17 +294,16 @@ class TestAssetAudit(AutoLoginTest): asset_id = "1111" self.page.set_query(asset_id) self.page.search() - mdl = self.page.modal self.wait.until(EC.visibility_of_element_located((By.ID, 'modal'))) # Do it wrong on purpose to check error display - mdl.remove_all_required() - mdl.description = "" - mdl.submit() + self.page.modal.remove_all_required() + self.page.modal.description = "" + self.page.modal.submit() self.wait.until(animation_is_finished()) - self.assertIn("This field is required.", mdl.errors["Description"]) + self.assertIn("This field is required.", self.page.modal.errors["Description"]) # Now do it properly - mdl.description = new_desc = "A BIG hammer" - mdl.submit() + self.page.modal.description = new_desc = "A BIG hammer" + self.page.modal.submit() submit_time = timezone.now() self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal'))) self.assertFalse(self.driver.find_element_by_id('modal').is_displayed()) @@ -325,14 +324,14 @@ class TestAssetAudit(AutoLoginTest): self.driver.find_element(By.XPATH, "//a[contains(@class,'btn') and contains(., 'Audit')]").click() self.wait.until(EC.visibility_of_element_located((By.ID, 'modal'))) self.assertEqual(self.page.modal.asset_id, asset_row.id) - self.page.modal.close() - self.wait.until(animation_is_finished()) + self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal'))) self.assertFalse(self.driver.find_element_by_id('modal').is_displayed()) # Make sure audit log was NOT filled out audited = models.Asset.objects.get(asset_id=asset_row.id) self.assertEqual(None, audited.last_audited_by) + def test_audit_search(self): # Check that a failed search works self.page.set_query("NOTFOUND") self.page.search()