Skip to content

Commit

Permalink
adjusted poet ui tests as per gitpod changes + simplified some selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
omehes committed Dec 5, 2023
1 parent 3aecaa9 commit e045fe1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 51 deletions.
59 changes: 14 additions & 45 deletions tests/ui/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,21 @@ class HomePoet:
def __init__(self, page):
self.page = page

@property
def github_login_button_locator(self):
return self.page.locator("input.btn.btn-primary.btn-block.js-sign-in-button")

@property
def github_login_button_is_visible(self):
return self.page.is_visible("input.btn.btn-primary.btn-block.js-sign-in-button")

def click_github_login_button(self):
self.github_login_button_locator.click()

@property
def workspace_continue_button(self):
return self.page.locator(
"div.w-full.flex.justify-end.mt-3.space-x-2.px-6 > button"
)
return self.page.locator("button").get_by_text("Continue")

def click_workspace_continue_button(self):
self.workspace_continue_button.click()

@property
def openstax_icon_is_visible(self):
return self.page.wait_for_selector(
"div.composite-bar > div > ul > li:nth-child(7)", timeout=210000
)

@property
def openstax_icon(self):
return self.page.wait_for_selector(
"div.composite-bar > div > ul > li:nth-child(7)", timeout=90000
"div.composite-bar > div > ul > li:nth-child(7)", timeout=120000
)

def click_openstax_icon(self):
self.openstax_icon.click()
self.openstax_icon_is_visible.click()

@property
def parent_frame(self):
Expand All @@ -56,7 +37,7 @@ def open_toc_editor_button_is_visible(self):

@property
def open_toc_editor_button_locator(self):
return self.page.locator("div.welcome-view-content > div:nth-child(1)")
return self.page.get_by_text("Open ToC Editor", exact=True)

def click_open_toc_editor_button(self):
return self.open_toc_editor_button_locator.click()
Expand All @@ -67,7 +48,7 @@ def push_content_button_is_visible(self):

@property
def push_content_button(self):
return self.page.locator("div.welcome-view-content > div:nth-child(2)")
return self.page.get_by_text("Push Content", exact=True)

def click_push_content_button(self):
return self.push_content_button.click()
Expand Down Expand Up @@ -97,7 +78,7 @@ def generate_readme_button_is_visible(self):

@property
def generate_readme_button(self):
return self.page.locator("div.welcome-view-content > div:nth-child(3)")
return self.page.get_by_text("Generate README")

def click_generate_readme_button(self):
return self.generate_readme_button.click()
Expand Down Expand Up @@ -126,12 +107,8 @@ def toc_tree_dropdown_list_is_visible(self):
"div.split-view-container > div:nth-child(2) > div > div.pane-header.expanded > h3"
)

@property
def validate_content_button(self):
return self.page.locator("div.welcome-view-content > div:nth-child(4)")

def click_validate_content_button(self):
return self.validate_content_button.click()
return self.page.get_by_text("Validate Content").click()

@property
def validate_content_all_content_option(self):
Expand Down Expand Up @@ -233,7 +210,10 @@ def add_subcollection_input_box_locator(self):

@property
def add_subcollection_input_box_is_visible(self):
return self.page.locator("div.quick-input-widget.show-file-icons")
return self.page.get_by_text(
"Title of new Book Section (Press 'Enter' to confirm or 'Escape' to cancel)",
exact=True,
)

def fill_add_subcollection_input_box(self, value):
self.add_subcollection_input_box_locator.fill(value)
Expand Down Expand Up @@ -316,9 +296,7 @@ def click_gitpod_menubar(self):

@property
def stop_workspace_button_locator(self):
return self.page.locator(
"div.monaco-menu > div > ul > li:nth-child(15) > a > span.action-label"
)
return self.page.get_by_text("Gitpod: Stop Workspace", exact=True)

def click_stop_workspace_button(self):
self.stop_workspace_button_locator.click()
Expand Down Expand Up @@ -357,15 +335,8 @@ def explorer_index_file_locator(self):
def click_explorer_index_file(self):
self.explorer_index_file_locator.click()

@property
def problems_tab_locator(self):
return self.page.wait_for_selector(
"div.composite-bar-container > div > div > ul > li:nth-child(2)",
timeout=90000,
)

def click_problems_tab(self):
self.problems_tab_locator.click()
return self.page.get_by_text("Problems", exact=True).click()

@property
def problems_tab_message(self):
Expand Down Expand Up @@ -403,9 +374,7 @@ def continue_with_github_is_visible(self):

@property
def continue_with_github_button(self):
return self.page.locator(
"div > div.w-56.mx-auto.flex.flex-col.space-y-3.items-center > button"
)
return self.page.locator("button").get_by_text("Continue with GitHub")

def click_continue_with_github_button(self):
self.continue_with_github_button.click()
Expand Down
9 changes: 7 additions & 2 deletions tests/ui/test_home_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ def test_home_ui(chrome_page, github_user, github_password, gitpod_repo_url):
# GIVEN: Playwright, chromium and a gitpod repo url
# (https://gitpod.io/#https://github.com/openstax/osbooks-otto-book)

sign_in_button_selector = "input.btn.btn-primary.btn-block.js-sign-in-button"

# WHEN: gitpod launches
chrome_page.goto(gitpod_repo_url)
home = HomePoet(chrome_page)

home.click_github_login_button()
if not home.continue_with_github_is_visible:
pass

home.click_continue_with_github_button()

with chrome_page.context.pages[1] as github_login_window:
github_login_window.fill("#login_field", github_user)
github_login_window.fill("#password", github_password)

github_login_window.click("input.btn.btn-primary.btn-block.js-sign-in-button")
github_login_window.click(sign_in_button_selector)

if home.gitpod_user_dropdown.inner_text() == "0 openstax":
pass
Expand Down
9 changes: 7 additions & 2 deletions tests/ui/test_readme_validate_other_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ def test_readme_validate_other_features(
# GIVEN: Playwright, chromium and a gitpod repo url
# (https://gitpod.io/#https://github.com/openstax/osbooks-otto-book)

sign_in_button_selector = "input.btn.btn-primary.btn-block.js-sign-in-button"

# WHEN: gitpod launches
chrome_page.goto(gitpod_repo_url)
home = HomePoet(chrome_page)

home.click_github_login_button()
if not home.continue_with_github_is_visible:
pass

home.click_continue_with_github_button()

with chrome_page.context.pages[1] as github_login_window:
github_login_window.fill("#login_field", github_user)
github_login_window.fill("#password", github_password)

github_login_window.click("input.btn.btn-primary.btn-block.js-sign-in-button")
github_login_window.click(sign_in_button_selector)

if home.gitpod_user_dropdown.inner_text() == "0 openstax":
pass
Expand Down
9 changes: 7 additions & 2 deletions tests/ui/test_toc_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ def test_toc_editor(chrome_page, github_user, github_password, gitpod_repo_url):
# GIVEN: Playwright, chromium and a gitpod repo url
# (https://gitpod.io/#https://github.com/openstax/osbooks-otto-book)

sign_in_button_selector = "input.btn.btn-primary.btn-block.js-sign-in-button"

# WHEN: gitpod launches
chrome_page.goto(gitpod_repo_url)
home = HomePoet(chrome_page)

# WHEN: login into openstax/osbooks-otto-book repo
home.click_github_login_button()
if not home.continue_with_github_is_visible:
pass

home.click_continue_with_github_button()

with chrome_page.context.pages[1] as github_login_window:
github_login_window.fill("#login_field", github_user)
github_login_window.fill("#password", github_password)

github_login_window.click("input.btn.btn-primary.btn-block.js-sign-in-button")
github_login_window.click(sign_in_button_selector)

if home.gitpod_user_dropdown.inner_text() == "0 openstax":
pass
Expand Down

0 comments on commit e045fe1

Please sign in to comment.