You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.9 KiB
65 lines
1.9 KiB
from time import sleep
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
INDEX_URL = "http://localhost:8050"
|
|
|
|
|
|
def _launch():
|
|
options = Options()
|
|
options.add_argument("--headless")
|
|
options.add_argument("window-size=1920,1080")
|
|
browser = webdriver.Chrome(options=options)
|
|
return browser
|
|
|
|
|
|
def test_index_should_redirect_to_edit():
|
|
browser = _launch()
|
|
browser.get(INDEX_URL)
|
|
assert "/edit" in browser.current_url
|
|
browser.close()
|
|
|
|
|
|
def test_should_edit():
|
|
browser = _launch()
|
|
browser.get(INDEX_URL)
|
|
|
|
# Type a new note
|
|
user_input = browser.find_element_by_id("userInput")
|
|
user_input.clear()
|
|
user_input.send_keys(
|
|
"# Hello world\n\n"
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec feugiat "
|
|
"euismod nibh, ac scelerisque erat laoreet quis. Nullam dignissim varius "
|
|
"enim. Aenean interdum et elit eu gravida. Cras eleifend eget tortor sit amet "
|
|
"tincidunt. Praesent eu interdum turpis. Nullam et massa massa. Maecenas "
|
|
"maximus turpis id egestas rhoncus. Morbi eget bibendum leo. "
|
|
)
|
|
sleep(1)
|
|
|
|
# Should render the preview
|
|
h1 = browser.find_element_by_css_selector("h1")
|
|
assert h1.text == "Hello world"
|
|
|
|
# Refresh should not delete the content
|
|
browser.refresh()
|
|
assert "Lorem ipsum" in browser.page_source
|
|
|
|
# Click view and verify content
|
|
browser.find_element_by_link_text("View").click()
|
|
assert "/view" in browser.current_url
|
|
h1 = browser.find_element_by_css_selector("h1")
|
|
assert h1.text == "Hello world"
|
|
assert "Lorem ipsum" in browser.page_source
|
|
assert "Hello world" in browser.title
|
|
|
|
# Click publish and verify content
|
|
browser.find_element_by_link_text("Publish").click()
|
|
h1 = browser.find_element_by_css_selector("h1")
|
|
assert h1.text == "Hello world"
|
|
assert "Hello world" in browser.title
|
|
|
|
# End session
|
|
browser.close()
|