new list item valid test completed, even if it doesn't yet pass
This commit is contained in:
@@ -31,3 +31,12 @@ class FunctionalTest(StaticLiveServerTestCase):
|
|||||||
raise
|
raise
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
def wait_for(self, fn):
|
||||||
|
start_time = time.time()
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return fn()
|
||||||
|
except (AssertionError, WebDriverException):
|
||||||
|
if time.time() - start_time > MAX_WAIT:
|
||||||
|
raise
|
||||||
|
time.sleep(0.5)
|
||||||
@@ -5,4 +5,31 @@ from .base import FunctionalTest
|
|||||||
|
|
||||||
class ItemValidationTest(FunctionalTest):
|
class ItemValidationTest(FunctionalTest):
|
||||||
def test_cannot_add_empty_list_items(self):
|
def test_cannot_add_empty_list_items(self):
|
||||||
self.fail("write me!")
|
self.browser.get(self.live_server_url)
|
||||||
|
self.browser.find_element(By.ID, "id-new-item").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
|
self.wait_for(
|
||||||
|
lambda: self.assertEqual(
|
||||||
|
self.browser.find_element(By.CSS_SELECTOR, ".invalid-feedback").text,
|
||||||
|
"You can't have an empty list item",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.browser.find_element(By.ID, "id-new-item").send_keys("Purchase milk")
|
||||||
|
self.browser.find_element(By.ID, "id-new-item").send_keys(Keys.ENTER)
|
||||||
|
self.wait_for_row_in_list_table("1. Purchase milk")
|
||||||
|
|
||||||
|
self.browser.find_element(By.ID, "id-new-item").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
|
self.wait_for(
|
||||||
|
lambda: self.assertEqual(
|
||||||
|
self.browser.find_element(By.CSS_SELECTOR, ".invalid-feedback").text,
|
||||||
|
"You can't have an empty list item",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.browser.find_element(By.ID, 'id-new-item').send_keys("Make tea")
|
||||||
|
self.browser.find_element(By.ID, "id-new-item").send_keys(Keys.ENTER)
|
||||||
|
self.wait_for_row_in_list_table("2. Make tea")
|
||||||
|
|
||||||
|
self.fail("finish the fight!")
|
||||||
|
|||||||
Reference in New Issue
Block a user