Skip to content

Commit

Permalink
Merge branch 'main' into fix-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
philschatz authored Dec 1, 2023
2 parents 50dff18 + 3aecaa9 commit 2ed02e1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 29 deletions.
11 changes: 11 additions & 0 deletions tests/ui/content/test_all_repos_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.mark.nondestructive
def test_all_repos_indexes(git_content_repos, headers_data):
# List indexes of each content repo for cases
# when only certain book range requires testing
# with test_content_validation_all_book_repos.py

for repo in git_content_repos:
print(f"REPO: {repo} - LIST INDEX: {git_content_repos.index(repo)}")
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@


@pytest.mark.nondestructive
def test_content_validation_all_repos(
def test_content_validation_all_book_repos(
chrome_page, github_user, github_password, git_content_repos, headers_data
):
# GIVEN: Playwright, chromium and gitpod
# repo url as: https://gitpod.io/#https://github.com/openstax/osbooks-content-repo
# run the test: pytest -k test_content_validation_all_repos.py tests/ui --github_user xxx --github_password yyy
# --github_token zzz > validation.log

# As per github changes, modified on November 30, 2023

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

for repo in git_content_repos:
Expand All @@ -23,19 +25,19 @@ def test_content_validation_all_repos(
chrome_page.goto(gitpod_repo_url)
home = HomePoet(chrome_page)

if not home.github_login_button_is_visible:
if not home.continue_with_github_is_visible:
if home.gitpod_user_dropdown.inner_text() == "0 openstax":
pass

else:
home.click_gitpod_user_dropdown()
home.click_gitpod_user_selector()

if home.private_repo_warning_is_visible:
print(f"SKIPPING! Book repo is private: {repo}")
continue

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

else:
home.click_gitpod_user_dropdown()
home.click_gitpod_user_selector()

home.click_workspace_continue_button()

# THEN: openstax extension launches and icon appears
Expand Down Expand Up @@ -83,27 +85,27 @@ def test_content_validation_all_repos(
home.click_stop_workspace_button()

else:
if home.private_repo_warning_is_visible:
print(f"SKIPPING! Book repo is private: {repo}")
continue
home.click_continue_with_github_button()

else:
# WHEN: login into repo
home.click_github_login_button()
# WHEN: login into repo
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)

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)

github_login_window.click(sign_in_button_selector)
if home.gitpod_user_dropdown.inner_text() == "0 openstax":
pass

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

else:
home.click_gitpod_user_dropdown()
home.click_gitpod_user_selector()
if home.private_repo_warning_is_visible:
print(f"SKIPPING! Book repo is private: {repo}")
continue

else:
home.click_workspace_continue_button()

if not home.openstax_icon_is_visible:
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/fixtures/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def chrome_page():
"""Return playwright chromium browser page - slow flow"""
playwright_sync = sync_playwright().start()
chrome_browser = playwright_sync.chromium.launch(
headless=True, slow_mo=1600, timeout=120000
headless=True, slow_mo=1800, timeout=120000
)
context = chrome_browser.new_context()

Expand Down
27 changes: 23 additions & 4 deletions tests/ui/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def __init__(self, page):

@property
def github_login_button_locator(self):
return self.page.locator(".btn-login")
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(".btn-login")
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()
Expand All @@ -33,7 +33,9 @@ def openstax_icon_is_visible(self):

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

def click_openstax_icon(self):
self.openstax_icon.click()
Expand All @@ -48,7 +50,9 @@ def child_frame(self):

@property
def open_toc_editor_button_is_visible(self):
return self.page.is_visible("div.welcome-view-content > div:nth-child(1)")
return self.page.wait_for_selector(
"div.welcome-view-content > div:nth-child(1)", timeout=90000
)

@property
def open_toc_editor_button_locator(self):
Expand Down Expand Up @@ -391,6 +395,21 @@ def gitpod_user_selector(self):
def click_gitpod_user_selector(self):
self.gitpod_user_selector.click()

@property
def continue_with_github_is_visible(self):
return self.page.is_visible(
"div > div.w-56.mx-auto.flex.flex-col.space-y-3.items-center > button"
)

@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"
)

def click_continue_with_github_button(self):
self.continue_with_github_button.click()

def wait_for_validation_end(
self, condition, timeout_seconds=900, interval_seconds=10
):
Expand Down

0 comments on commit 2ed02e1

Please sign in to comment.