Fix the remaining tests

This commit is contained in:
2020-05-25 22:47:34 +01:00
parent 177c37ffbc
commit fd6aee83cf
9 changed files with 33 additions and 24 deletions

View File

@@ -138,7 +138,7 @@ class SecureAPIRequest(generic.View):
class GenericListView(generic.ListView):
paginate_by = 20
def get_queryset(self):
q = self.request.GET.get('q', "")

View File

@@ -59,6 +59,7 @@ class EventDetail(BasePage):
_name_selector = (By.XPATH, '//dt[text()="Person"]/following-sibling::dd[1]')
_email_selector = (By.XPATH, '//dt[text()="Email"]/following-sibling::dd[1]')
_phone_selector = (By.XPATH, '//dt[text()="Phone Number"]/following-sibling::dd[1]')
_event_table_selector = (By.ID, 'item-table')
@property
def event_name(self):
@@ -76,6 +77,10 @@ class EventDetail(BasePage):
def phone(self):
return self.find_element(*self._person_panel_selector).find_element(*self._phone_selector).text
@property
def item_table(self):
return self.find_element(*self._event_table_selector)
class CreateEvent(FormPage):
URL_TEMPLATE = reverse('event_create')

View File

@@ -166,7 +166,9 @@ class TestEventCreate(BaseRigboardTest):
modal.submit()
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
self.assertFalse(modal.is_open)
self.assertEqual(self.page.person_selector.options[1].name, person_name)
self.page.person_selector.toggle()
self.assertEqual(self.page.person_selector.options[0].name, person_name)
self.page.person_selector.toggle()
# TODO
@@ -392,7 +394,7 @@ class TestEventDuplicate(BaseRigboardTest):
self.assertIn("Test Item 3", table.text)
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
self.assertIn("N0000%d" % self.testEvent.pk,
self.assertIn("N%05d" % self.testEvent.pk,
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
# Check the PO hasn't carried through
self.assertNotIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
@@ -404,7 +406,7 @@ class TestEventDuplicate(BaseRigboardTest):
# Check that based-on hasn't crept into the old event
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
self.assertNotIn("N0000%d" % self.testEvent.pk,
self.assertNotIn("N%05d" % self.testEvent.pk,
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
# Check the PO remains on the old event
self.assertIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
@@ -471,7 +473,8 @@ class TestEventEdit(BaseRigboardTest):
self.assertTrue(self.page.success)
self.page = pages.EventDetail(self.driver, self.live_server_url, event_id=self.testEvent.pk).open()
self.assertIn(self.page.event_name, self.testEvent.name)
self.testEvent.refresh_from_db()
self.assertIn(self.testEvent.name, self.page.event_name)
self.assertEqual(self.page.name, self.testEvent.person.name)
# Check the new items are visible
table = self.page.item_table
@@ -509,9 +512,9 @@ class TestEventDetail(BaseRigboardTest):
def test_rig_detail(self):
self.assertIn("N%05d | %s" % (self.testEvent.pk, self.testEvent.name), self.page.event_name)
self.assertEqual(person.name, self.page.name)
self.assertEqual(person.email, self.page.email)
self.assertEqual(person.phone, self.page.phone)
self.assertEqual(self.client.name, self.page.name)
self.assertEqual(self.client.email, self.page.email)
self.assertEqual(self.client.phone, None)
class TestCalendar(BaseRigboardTest):

View File

@@ -3,7 +3,8 @@ from reversion import revisions as reversion
from django.conf import settings
from django.core.exceptions import ValidationError
from django.test import TestCase
from RIGS import models, versioning
from RIGS import models
from versioning import versioning
from datetime import date, timedelta, datetime, time
from decimal import *
from PyRIGS.tests.base import create_browser

View File

@@ -29,7 +29,7 @@
{% include 'partials/audit_details.html' %}
</div>
</div>
{% if perms.RIGS.view_asset %}
{% if perms.assets.view_asset %}
<div class="row justify-content-end">
{% include 'partials/asset_buttons.html' %}
</div>

View File

@@ -82,6 +82,8 @@
</h1>
{% if duplicate %}
<form method="POST" id="asset_update_form" action="{% url 'asset_duplicate' pk=previous_asset_id %}">
{% elif edit %}
<form method="POST" id="asset_update_form" action="{% url 'asset_update' pk=object.asset_id %}">
{% else %}
<form method="POST" id="asset_update_form" action="{% url 'asset_create' %}">
{% endif %}

View File

@@ -21,7 +21,7 @@
<div class="input-group">
{% render_field form.query|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' style="width: 250px"%}
<label for="query" class="sr-only">Asset ID/Description/Serial Number:</label>
<span class="input-group-append"><button type="submit" class="btn btn-primary">Search</button></span>
<span class="input-group-append"><button type="submit" class="btn btn-primary" id="id_search">Search</button></span>
</div>
</div>
<div class="row justify-content-end">

View File

@@ -16,7 +16,7 @@ class AssetList(BasePage):
_search_text_locator = (By.ID, 'id_query')
_status_select_locator = (By.CSS_SELECTOR, 'div#status-group>div.bootstrap-select')
_category_select_locator = (By.CSS_SELECTOR, 'div#category-group>div.bootstrap-select')
_go_button_locator = (By.ID, 'filter-submit')
_go_button_locator = (By.ID, 'id_search')
class AssetListRow(Region):
_asset_id_locator = (By.CLASS_NAME, "assetID")
@@ -123,12 +123,12 @@ class AssetDuplicate(AssetForm):
class SupplierList(BasePage):
URL_TEMPLATE = reverse('supplier_list')
_supplier_item_locator = (By.CLASS_NAME, 'supplierRow')
_search_text_locator = (By.ID, 'id_query')
_supplier_item_locator = (By.ID, 'row_item')
_search_text_locator = (By.XPATH, '//*[@id="main"]/div[2]/form/div/input')
_go_button_locator = (By.ID, 'id_search')
class SupplierListRow(Region):
_name_locator = (By.CLASS_NAME, "supplierName")
_name_locator = (By.ID, "cell_name")
@property
def name(self):

View File

@@ -135,15 +135,12 @@ class TestAssetForm(AutoLoginTest):
self.page.parent_selector.toggle()
self.assertTrue(self.page.parent_selector.is_open)
# Searching it by ID autoselects it
self.page.parent_selector.search(self.parent.asset_id)
# Needed here but not earlier for whatever reason
self.driver.implicitly_wait(1)
# self.page.parent_selector.set_option(self.parent.asset_id + " | " + self.parent.description, True)
# Need to explicitly close as we haven't selected anything to trigger the auto close
self.page.parent_selector.search(Keys.ESCAPE)
self.assertFalse(self.page.parent_selector.is_open)
self.page.parent_selector.set_option(self.parent.asset_id + " | " + self.parent.description, True)
self.assertTrue(self.page.parent_selector.options[0].selected)
self.page.parent_selector.toggle()
self.assertFalse(self.driver.find_element_by_id('cable-table').is_displayed())
@@ -220,6 +217,7 @@ class TestSupplierList(AutoLoginTest):
def test_search(self):
self.page.set_query("TEC")
self.page.search()
self.assertTrue(len(self.page.suppliers) == 1)
self.assertEqual("TEC PA & Lighting", self.page.suppliers[0].name)
@@ -291,7 +289,7 @@ class TestAssetAudit(AutoLoginTest):
new_desc = "A BIG hammer"
mdl.description = new_desc
mdl.submit()
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())
# Check data is correct
@@ -309,13 +307,13 @@ class TestAssetAudit(AutoLoginTest):
self.assertEqual(len(models.Asset.objects.filter(last_audited_at=None)), len(self.page.assets))
asset_row = self.page.assets[0]
asset_row.find_element(By.XPATH, "//button[contains(., 'Audit')]").click()
self.driver.find_element(By.XPATH, "//*[@id='asset_table_body']/tr[1]/td[4]/a").click()
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
self.assertEqual(self.page.modal.asset_id, asset_row.id)
# First close button is for the not found error
self.page.find_element(By.XPATH, '(//button[@class="close"])[2]').click()
self.wait.until(animation_is_finished())
self.page.find_element(By.XPATH, '//*[@id="modal"]/div/div/div[1]/button').click()
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)