renamed List to Note everywhere thru-out project in preparation for complete overhaul of applet capabilities
This commit is contained in:
@@ -47,7 +47,7 @@ class FunctionalTest(StaticLiveServerTestCase):
|
||||
if self.test_server:
|
||||
self.live_server_url = 'http://' + self.test_server
|
||||
reset_database(self.test_server)
|
||||
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List"})
|
||||
Applet.objects.get_or_create(slug="new-note", defaults={"name": "New Note"})
|
||||
|
||||
def tearDown(self):
|
||||
if self._test_has_failed():
|
||||
|
||||
@@ -3,11 +3,11 @@ from selenium.webdriver.common.by import By
|
||||
from apps.lyric.models import User
|
||||
|
||||
|
||||
class MyListsPage:
|
||||
class MyNotesPage:
|
||||
def __init__(self, test):
|
||||
self.test = test
|
||||
|
||||
def go_to_my_lists_page(self, email):
|
||||
|
||||
def go_to_my_notes_page(self, email):
|
||||
self.test.browser.get(self.test.live_server_url)
|
||||
user = User.objects.get(email=email)
|
||||
self.test.browser.get(
|
||||
@@ -4,42 +4,42 @@ from selenium.webdriver.common.keys import Keys
|
||||
from .base import wait
|
||||
|
||||
|
||||
class ListPage:
|
||||
class NotePage:
|
||||
def __init__(self, test):
|
||||
self.test = test
|
||||
|
||||
def get_table_rows(self):
|
||||
return self.test.browser.find_elements(By.CSS_SELECTOR, "#id_list_table tr")
|
||||
return self.test.browser.find_elements(By.CSS_SELECTOR, "#id_note_table tr")
|
||||
|
||||
@wait
|
||||
def wait_for_row_in_list_table(self, item_text, item_number):
|
||||
def wait_for_row_in_note_table(self, item_text, item_number):
|
||||
expected_row_text = f"{item_number}. {item_text}"
|
||||
rows = self.get_table_rows()
|
||||
self.test.assertIn(expected_row_text, [row.text for row in rows])
|
||||
|
||||
|
||||
def get_item_input_box(self):
|
||||
return self.test.browser.find_element(By.ID, "id_text")
|
||||
|
||||
def add_list_item(self, item_text):
|
||||
def add_note_item(self, item_text):
|
||||
new_item_no = len(self.get_table_rows()) + 1
|
||||
self.get_item_input_box().send_keys(item_text)
|
||||
self.get_item_input_box().send_keys(Keys.ENTER)
|
||||
self.wait_for_row_in_list_table(item_text, new_item_no)
|
||||
self.wait_for_row_in_note_table(item_text, new_item_no)
|
||||
return self
|
||||
|
||||
|
||||
def get_share_box(self):
|
||||
return self.test.browser.find_element(
|
||||
By.CSS_SELECTOR,
|
||||
'input[name="recipient"]',
|
||||
)
|
||||
|
||||
|
||||
def get_shared_with_list(self):
|
||||
return self.test.browser.find_elements(
|
||||
By.CSS_SELECTOR,
|
||||
".list-recipient"
|
||||
".note-recipient"
|
||||
)
|
||||
|
||||
def share_list_with(self, email):
|
||||
|
||||
def share_note_with(self, email):
|
||||
self.get_share_box().send_keys(email)
|
||||
self.get_share_box().send_keys(Keys.ENTER)
|
||||
self.test.wait_for(
|
||||
@@ -48,5 +48,5 @@ class ListPage:
|
||||
)
|
||||
)
|
||||
|
||||
def get_list_owner(self):
|
||||
return self.test.browser.find_element(By.ID, "id_list_owner").text
|
||||
def get_note_owner(self):
|
||||
return self.test.browser.find_element(By.ID, "id_note_owner").text
|
||||
@@ -9,7 +9,7 @@ from apps.applets.models import Applet
|
||||
class DashboardMaintenanceTest(FunctionalTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List"})
|
||||
Applet.objects.get_or_create(slug="new-note", defaults={"name": "New Note"})
|
||||
Applet.objects.get_or_create(slug="username", defaults={"name": "Username"})
|
||||
Applet.objects.get_or_create(slug="palette", defaults={"name": "Palette"})
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
from .base import FunctionalTest
|
||||
from .list_page import ListPage
|
||||
from .note_page import NotePage
|
||||
|
||||
|
||||
class LayoutAndStylingTest(FunctionalTest):
|
||||
def test_layout_and_styling(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
note_page = NotePage(self)
|
||||
|
||||
self.browser.set_window_size(1024, 768)
|
||||
# print("Viewport width:", self.browser.execute_script("return window.innerWidth"))
|
||||
|
||||
inputbox = list_page.get_item_input_box()
|
||||
inputbox = note_page.get_item_input_box()
|
||||
self.assertAlmostEqual(
|
||||
inputbox.location['x'] + inputbox.size['width'] / 2,
|
||||
512,
|
||||
delta=10,
|
||||
)
|
||||
|
||||
list_page.add_list_item("testing")
|
||||
inputbox = list_page.get_item_input_box()
|
||||
note_page.add_note_item("testing")
|
||||
inputbox = note_page.get_item_input_box()
|
||||
self.assertAlmostEqual(
|
||||
inputbox.location['x'] + inputbox.size['width'] / 2,
|
||||
512,
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from .base import FunctionalTest
|
||||
from .list_page import ListPage
|
||||
from .my_lists_page import MyListsPage
|
||||
from .note_page import NotePage
|
||||
from .my_notes_page import MyNotesPage
|
||||
|
||||
|
||||
class MyListsTest(FunctionalTest):
|
||||
class MyNotesTest(FunctionalTest):
|
||||
|
||||
def test_logged_in_users_lists_are_saved_as_my_lists(self):
|
||||
def test_logged_in_users_notes_are_saved_as_my_notes(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
list_page.add_list_item("Reticulate splines")
|
||||
list_page.add_list_item("Regurgitate spines")
|
||||
first_list_url = self.browser.current_url
|
||||
note_page = NotePage(self)
|
||||
note_page.add_note_item("Reticulate splines")
|
||||
note_page.add_note_item("Regurgitate spines")
|
||||
first_note_url = self.browser.current_url
|
||||
|
||||
MyListsPage(self).go_to_my_lists_page("disco@test.io")
|
||||
MyNotesPage(self).go_to_my_notes_page("disco@test.io")
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.LINK_TEXT, "Reticulate splines")
|
||||
)
|
||||
self.browser.find_element(By.LINK_TEXT, "Reticulate splines").click()
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(self.browser.current_url, first_list_url)
|
||||
lambda: self.assertEqual(self.browser.current_url, first_note_url)
|
||||
)
|
||||
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page.add_list_item("Ribbon of death")
|
||||
second_list_url = self.browser.current_url
|
||||
note_page.add_note_item("Ribbon of death")
|
||||
second_note_url = self.browser.current_url
|
||||
|
||||
MyListsPage(self).go_to_my_lists_page("disco@test.io")
|
||||
MyNotesPage(self).go_to_my_notes_page("disco@test.io")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.LINK_TEXT, "Ribbon of death")
|
||||
)
|
||||
@@ -38,7 +38,7 @@ class MyListsTest(FunctionalTest):
|
||||
self.browser.find_element(By.CSS_SELECTOR, "#id_logout").click()
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
self.browser.find_elements(By.LINK_TEXT, "My lists"),
|
||||
self.browser.find_elements(By.LINK_TEXT, "My notes"),
|
||||
[],
|
||||
)
|
||||
)
|
||||
@@ -2,7 +2,7 @@ from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
from .base import FunctionalTest
|
||||
from .list_page import ListPage
|
||||
from .note_page import NotePage
|
||||
|
||||
|
||||
class ItemValidationTest(FunctionalTest):
|
||||
@@ -11,69 +11,69 @@ class ItemValidationTest(FunctionalTest):
|
||||
return self.browser.find_element(By.CSS_SELECTOR, ".invalid-feedback")
|
||||
|
||||
# Test methods
|
||||
def test_cannot_add_empty_list_items(self):
|
||||
def test_cannot_add_empty_note_items(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page = NotePage(self)
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:invalid")
|
||||
)
|
||||
|
||||
list_page.get_item_input_box().send_keys("Purchase milk")
|
||||
note_page.get_item_input_box().send_keys("Purchase milk")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:valid")
|
||||
)
|
||||
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
list_page.wait_for_row_in_list_table("Purchase milk", 1)
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page.wait_for_row_in_note_table("Purchase milk", 1)
|
||||
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
|
||||
list_page.wait_for_row_in_list_table("Purchase milk", 1)
|
||||
note_page.wait_for_row_in_note_table("Purchase milk", 1)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:invalid")
|
||||
)
|
||||
|
||||
list_page.get_item_input_box().send_keys("Make tea")
|
||||
note_page.get_item_input_box().send_keys("Make tea")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR,
|
||||
"#id_text:valid",
|
||||
)
|
||||
)
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
list_page.wait_for_row_in_list_table("Make tea", 2)
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page.wait_for_row_in_note_table("Make tea", 2)
|
||||
|
||||
def test_cannot_add_duplicate_items(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
list_page.add_list_item("Witness divinity")
|
||||
note_page = NotePage(self)
|
||||
note_page.add_note_item("Witness divinity")
|
||||
|
||||
list_page.get_item_input_box().send_keys("Witness divinity")
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page.get_item_input_box().send_keys("Witness divinity")
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
self.get_error_element().text,
|
||||
"You've already logged this to your list",
|
||||
"You've already logged this to your note",
|
||||
)
|
||||
)
|
||||
|
||||
def test_error_messages_are_cleared_on_input(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
list_page.add_list_item("Gobbledygook")
|
||||
list_page.get_item_input_box().send_keys("Gobbledygook")
|
||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
note_page = NotePage(self)
|
||||
note_page.add_note_item("Gobbledygook")
|
||||
note_page.get_item_input_box().send_keys("Gobbledygook")
|
||||
note_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||
self.wait_for(
|
||||
lambda: self.assertTrue(self.get_error_element().is_displayed())
|
||||
)
|
||||
|
||||
list_page.get_item_input_box().send_keys("a")
|
||||
note_page.get_item_input_box().send_keys("a")
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.assertFalse(self.get_error_element().is_displayed())
|
||||
@@ -5,8 +5,8 @@ from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from .base import FunctionalTest
|
||||
from .list_page import ListPage
|
||||
from .my_lists_page import MyListsPage
|
||||
from .note_page import NotePage
|
||||
from .my_notes_page import MyNotesPage
|
||||
|
||||
|
||||
# Helper fns
|
||||
@@ -19,7 +19,7 @@ def quit_if_possible(browser):
|
||||
|
||||
# Test mdls
|
||||
class SharingTest(FunctionalTest):
|
||||
def test_can_share_a_list_with_another_user(self):
|
||||
def test_can_share_a_note_with_another_user(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
disco_browser = self.browser
|
||||
self.addCleanup(lambda: quit_if_possible(disco_browser))
|
||||
@@ -34,40 +34,39 @@ class SharingTest(FunctionalTest):
|
||||
|
||||
self.browser = disco_browser
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self).add_list_item("Send help")
|
||||
note_page = NotePage(self).add_note_item("Send help")
|
||||
|
||||
share_box = list_page.get_share_box()
|
||||
share_box = note_page.get_share_box()
|
||||
self.assertEqual(
|
||||
share_box.get_attribute("placeholder"),
|
||||
"friend@example.com",
|
||||
)
|
||||
|
||||
list_page.share_list_with("alice@test.io")
|
||||
note_page.share_note_with("alice@test.io")
|
||||
|
||||
self.browser = ali_browser
|
||||
MyListsPage(self).go_to_my_lists_page("alice@test.io")
|
||||
MyNotesPage(self).go_to_my_notes_page("alice@test.io")
|
||||
|
||||
self.browser.find_element(By.LINK_TEXT, "Send help").click()
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(list_page.get_list_owner(), "disco@test.io")
|
||||
lambda: self.assertEqual(note_page.get_note_owner(), "disco@test.io")
|
||||
)
|
||||
|
||||
list_page.add_list_item("At your command, Disco King")
|
||||
note_page.add_note_item("At your command, Disco King")
|
||||
|
||||
self.browser = disco_browser
|
||||
self.browser.refresh()
|
||||
list_page.wait_for_row_in_list_table("At your command, Disco King", 2)
|
||||
note_page.wait_for_row_in_note_table("At your command, Disco King", 2)
|
||||
|
||||
class ListAccessTest(FunctionalTest):
|
||||
def test_stranger_cannot_access_owned_list(self):
|
||||
class NoteAccessTest(FunctionalTest):
|
||||
def test_stranger_cannot_access_owned_note(self):
|
||||
self.create_pre_authenticated_session("disco@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self).add_list_item("private eye")
|
||||
list_url = self.browser.current_url
|
||||
note_page = NotePage(self).add_note_item("private eye")
|
||||
note_url = self.browser.current_url
|
||||
|
||||
self.browser.delete_cookie(settings.SESSION_COOKIE_NAME)
|
||||
self.browser.get(list_url)
|
||||
|
||||
self.assertNotEqual(self.browser.current_url, list_url)
|
||||
self.browser.get(note_url)
|
||||
|
||||
self.assertNotEqual(self.browser.current_url, note_url)
|
||||
|
||||
@@ -2,7 +2,7 @@ from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
from .base import FunctionalTest
|
||||
from .list_page import ListPage
|
||||
from .note_page import NotePage
|
||||
|
||||
|
||||
class NewVisitorTest(FunctionalTest):
|
||||
@@ -10,51 +10,51 @@ class NewVisitorTest(FunctionalTest):
|
||||
def test_can_start_a_todo_list(self):
|
||||
self.create_pre_authenticated_session("alice@test.io")
|
||||
self.browser.get(self.live_server_url)
|
||||
list_page = ListPage(self)
|
||||
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 = list_page.get_item_input_box()
|
||||
inputbox = note_page.get_item_input_box()
|
||||
self.assertEqual(inputbox.get_attribute('placeholder'), 'Enter a to-do item')
|
||||
|
||||
inputbox.send_keys('Buy peacock feathers')
|
||||
|
||||
inputbox.send_keys(Keys.ENTER)
|
||||
list_page.wait_for_row_in_list_table("Buy peacock feathers", 1)
|
||||
|
||||
list_page.add_list_item("Use peacock feathers to make a fly")
|
||||
|
||||
list_page.wait_for_row_in_list_table("Use peacock feathers to make a fly", 2)
|
||||
list_page.wait_for_row_in_list_table("Buy peacock feathers", 1)
|
||||
note_page.wait_for_row_in_note_table("Buy peacock feathers", 1)
|
||||
|
||||
def test_multiple_users_can_start_lists_at_different_urls(self):
|
||||
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)
|
||||
list_page = ListPage(self)
|
||||
list_page.add_list_item("Buy peacock feathers")
|
||||
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/list/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/$',
|
||||
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)
|
||||
list_page = ListPage(self)
|
||||
note_page = NotePage(self)
|
||||
page_text = self.browser.find_element(By.TAG_NAME, 'body').text
|
||||
self.assertNotIn('Buy peacock feathers', page_text)
|
||||
|
||||
list_page.add_list_item("Buy milk")
|
||||
note_page.add_note_item("Buy milk")
|
||||
|
||||
francis_dash_url = self.browser.current_url
|
||||
self.assertRegex(
|
||||
francis_dash_url,
|
||||
r'/dashboard/list/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/$',
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user