diff --git a/tests/ui/content/test_all_repos_indexes.py b/tests/ui/content/test_all_repos_indexes.py new file mode 100644 index 00000000..aba8ea64 --- /dev/null +++ b/tests/ui/content/test_all_repos_indexes.py @@ -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)}") diff --git a/tests/ui/content/test_content_validation_all_repos.py b/tests/ui/content/test_content_validation_all_book_repos.py similarity index 84% rename from tests/ui/content/test_content_validation_all_repos.py rename to tests/ui/content/test_content_validation_all_book_repos.py index efd6b262..5b26404e 100644 --- a/tests/ui/content/test_content_validation_all_repos.py +++ b/tests/ui/content/test_content_validation_all_book_repos.py @@ -4,7 +4,7 @@ @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 @@ -12,6 +12,8 @@ def test_content_validation_all_repos( # 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: @@ -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 @@ -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: diff --git a/tests/ui/fixtures/ui.py b/tests/ui/fixtures/ui.py index 6bcba415..9e69d462 100644 --- a/tests/ui/fixtures/ui.py +++ b/tests/ui/fixtures/ui.py @@ -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() diff --git a/tests/ui/pages/home.py b/tests/ui/pages/home.py index fe3c7d46..fc7f4138 100644 --- a/tests/ui/pages/home.py +++ b/tests/ui/pages/home.py @@ -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() @@ -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() @@ -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): @@ -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 ):