64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from .base import FunctionalTest
|
|
from .note_page import NotePage
|
|
|
|
|
|
class NewVisitorTest(FunctionalTest):
|
|
# Test methods
|
|
def test_can_start_a_note(self):
|
|
self.create_pre_authenticated_session("alice@test.io")
|
|
self.browser.get(self.live_server_url)
|
|
note_page = NotePage(self)
|
|
|
|
self.assertIn('Earthman RPG', self.browser.title)
|
|
header_text = self.browser.find_element(By.TAG_NAME, 'h1').text
|
|
self.assertIn('Welcome', header_text)
|
|
|
|
inputbox = note_page.get_item_input_box()
|
|
self.assertEqual(inputbox.get_attribute('placeholder'), 'Enter a note item')
|
|
|
|
inputbox.send_keys('Buy peacock feathers')
|
|
|
|
inputbox.send_keys(Keys.ENTER)
|
|
note_page.wait_for_row_in_note_table("Buy peacock feathers", 1)
|
|
|
|
note_page.add_note_item("Use peacock feathers to make a fly")
|
|
|
|
note_page.wait_for_row_in_note_table("Use peacock feathers to make a fly", 2)
|
|
note_page.wait_for_row_in_note_table("Buy peacock feathers", 1)
|
|
|
|
def test_multiple_users_can_start_notes_at_different_urls(self):
|
|
self.create_pre_authenticated_session("alice@test.io")
|
|
self.browser.get(self.live_server_url)
|
|
note_page = NotePage(self)
|
|
note_page.add_note_item("Buy peacock feathers")
|
|
|
|
edith_dash_url = self.browser.current_url
|
|
self.assertRegex(
|
|
edith_dash_url,
|
|
r'/dashboard/note/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/$',
|
|
)
|
|
|
|
self.browser.delete_all_cookies()
|
|
|
|
self.create_pre_authenticated_session("disco@test.io")
|
|
self.browser.get(self.live_server_url)
|
|
note_page = NotePage(self)
|
|
page_text = self.browser.find_element(By.TAG_NAME, 'body').text
|
|
self.assertNotIn('Buy peacock feathers', page_text)
|
|
|
|
note_page.add_note_item("Buy milk")
|
|
|
|
francis_dash_url = self.browser.current_url
|
|
self.assertRegex(
|
|
francis_dash_url,
|
|
r'/dashboard/note/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/$',
|
|
)
|
|
self.assertNotEqual(francis_dash_url, edith_dash_url)
|
|
|
|
page_text = self.browser.find_element(By.TAG_NAME, 'body').text
|
|
self.assertNotIn('Buy peacock feathers', page_text)
|
|
self.assertIn('Buy milk', page_text)
|