Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def page():
'''))

screen.open('/')
screen.wait(1.0) # wait for Mermaid to render
screen.should_contain('Mermaid')
screen.wait(1.0) # wait for Mermaid to render
assert screen.find_by_tag('svg').get_attribute('id') == f'{m.html_id}_mermaid_0'
assert screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_A")]]').is_displayed()
_wait_for_xpath_displayed(screen, '//span[p[contains(text(), "Node_A")]]')

screen.click('Set new content')
screen.should_contain('New')
assert screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_C")]]').is_displayed()
_wait_for_xpath_displayed(screen, '//span[p[contains(text(), "Node_C")]]')
screen.should_not_contain('Node_A')


Expand All @@ -68,8 +68,8 @@ def page():

screen.open('/')
screen.click('Create Mermaid')
assert screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_A")]]').is_displayed()
assert screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_B")]]').is_displayed()
_wait_for_xpath_displayed(screen, '//span[p[contains(text(), "Node_A")]]')
_wait_for_xpath_displayed(screen, '//span[p[contains(text(), "Node_B")]]')


def test_strip_indentation(screen: Screen):
Expand Down Expand Up @@ -102,3 +102,15 @@ def replace():
screen.click('Replace')
screen.should_contain('B')
screen.should_not_contain('A')


def _wait_for_xpath_displayed(screen: Screen, xpath: str, attempts: int = 5, delay: float = 0.2):
for _ in range(attempts):
try:
el = screen.selenium.find_element(By.XPATH, xpath)
if el.is_displayed():
return el
except Exception:
pass
screen.wait(delay)
raise AssertionError(f'{xpath} not displayed')
2 changes: 2 additions & 0 deletions tests/test_mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def page():
'''))

screen.open('/')
screen.should_contain('Node_A')
node_a = screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_A")]]')
assert node_a.get_attribute('class') == 'nodeLabel'

screen.click('Set new content')
screen.should_contain('Node_C')
node_c = screen.selenium.find_element(By.XPATH, '//span[p[contains(text(), "Node_C")]]')
assert node_c.get_attribute('class') == 'nodeLabel'
screen.should_not_contain('Node_A')
Expand Down