Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding cat qa tests #209

Merged
merged 2 commits into from
Aug 6, 2024
Merged
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
30 changes: 30 additions & 0 deletions tests/ui/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,36 @@ def openstax_icon_is_visible(self):
def click_openstax_icon(self):
self.openstax_icon_is_visible.click()

@property
def cat_icon_is_visible(self):
return self.page.wait_for_selector("ul > li:nth-child(8)", timeout=90000)

def click_cat_icon(self):
self.cat_icon_is_visible.click()

@property
def cat_tab_is_visible(self):
return self.page.locator("div.tabs-container > div:nth-child(2)").get_by_text(
"H5P Editor"
)

@property
def openstax_tab_is_visible(self):
return self.page.locator("div.tabs-container > div:nth-child(3)").get_by_text(
"Table of Contents Editor"
)

@property
def open_h5p_editor_button_is_visible(self):
return self.page.get_by_text("Open H5P Editor", exact=True)

def click_open_h5p_editor_button(self):
return self.open_h5p_editor_button_is_visible.click()

@property
def h5p_editor_create_new_content_button_is_visible(self):
return self.page.get_by_text("Create new content", exact=True)

@property
def parent_frame(self):
return self.page.frame_locator("iframe").last
Expand Down
66 changes: 66 additions & 0 deletions tests/ui/test_cat_h5p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pytest

from tests.ui.pages.home import HomePoet


@pytest.mark.nondestructive
def test_cat_h5p(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)

if home.continue_with_github_is_visible:
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(sign_in_button_selector)

if home.continue_with_github_is_visible:
home.click_continue_with_github_button()

if home.gitpod_user_dropdown.inner_text() != "0 openstax":
home.click_gitpod_user_dropdown()
home.click_gitpod_user_selector()

if home.continue_with_github_is_visible:
home.click_continue_with_github_button()

if home.continue_with_workspace_is_visible:
home.click_workspace_continue_button()

# THEN: openstax and cat extension launches and both icons appear
assert home.openstax_icon_is_visible
assert home.cat_icon_is_visible

home.click_openstax_icon()

# THEN: POET UI launches and is visible
assert home.open_toc_editor_button_is_visible

home.click_cat_icon()

# THEN: CAT UI launches and is visible
assert home.open_h5p_editor_button_is_visible

home.click_open_h5p_editor_button()

assert home.cat_tab_is_visible
assert home.h5p_editor_create_new_content_button_is_visible

home.click_openstax_icon()
home.click_open_toc_editor_button()

# THEN: Both POET and CAT tabs are visible
assert home.openstax_tab_is_visible
assert home.cat_icon_is_visible

home.click_gitpod_menubar()
home.click_stop_workspace_button()
1 change: 1 addition & 0 deletions tests/ui/test_home_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_home_ui(chrome_page, github_user, github_password, gitpod_repo_url):

# THEN: openstax extension launches and icon appears
assert home.openstax_icon_is_visible
assert home.cat_icon_is_visible

home.click_openstax_icon()

Expand Down
Loading