From bf31c08079d372df482bea3a4f127dc1ad0bb3fb Mon Sep 17 00:00:00 2001 From: Otto Mehes Date: Thu, 30 Nov 2023 14:32:29 -0600 Subject: [PATCH 1/2] amending validation test as per gitpod changes --- tests/ui/content/test_all_repos_indexes.py | 11 ++ .../test_content_validation_all_book_repos.py | 153 ++++++++++++++++++ tests/ui/fixtures/ui.py | 2 +- tests/ui/pages/home.py | 27 +++- 4 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 tests/ui/content/test_all_repos_indexes.py create mode 100644 tests/ui/content/test_content_validation_all_book_repos.py 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_book_repos.py b/tests/ui/content/test_content_validation_all_book_repos.py new file mode 100644 index 00000000..5b26404e --- /dev/null +++ b/tests/ui/content/test_content_validation_all_book_repos.py @@ -0,0 +1,153 @@ +import pytest + +from tests.ui.pages.home import HomePoet + + +@pytest.mark.nondestructive +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: + gitpod_repo_url = "https://gitpod.io/#https://github.com/openstax/" + repo + + print(f"VERIFYING: {gitpod_repo_url}") + + # WHEN: gitpod launches + chrome_page.goto(gitpod_repo_url) + home = HomePoet(chrome_page) + + 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: + home.click_workspace_continue_button() + + # THEN: openstax extension launches and icon appears + if not home.openstax_icon_is_visible: + print("No openstax icon") + else: + home.click_openstax_icon() + + # THEN: TOC Editor and book list dropdown is visible + if not home.open_toc_editor_button_is_visible: + print(">>>TOC Editor button not loaded, skipping") + continue + + else: + if home.cannot_activate_poet_dialog_box_is_visible: + print(f"POET install issues: {repo}") + continue + + # THEN content validation launches + home.click_validate_content_button() + home.click_validate_content_all_content_option() + + home.wait_for_validation_end( + lambda: home.validation_notification_dialog_box_is_visible + ) + + # THEN Problems tab is checked for any validation problems + chrome_page.keyboard.press("Escape") + home.click_problems_tab() + + try: + assert ( + "No problems have been detected in the workspace." + in home.problems_tab_message.inner_text() + ) + + except AssertionError: + print(f"!!! Problems detected under Problems tab: {repo}") + print(f"{home.problems_tab_message.inner_text()}") + + else: + print(f"NO PROBLEMS IN {repo}") + + home.click_gitpod_menubar() + home.click_stop_workspace_button() + + else: + home.click_continue_with_github_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) + + github_login_window.click(sign_in_button_selector) + + 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: + home.click_workspace_continue_button() + + if not home.openstax_icon_is_visible: + print("No openstax icon") + else: + # THEN: openstax extension launches and icon appears + home.click_openstax_icon() + + # THEN: TOC Editor and book list dropdown is visible + if not home.open_toc_editor_button_is_visible: + print(">>> TOC Editor button not loaded, skipping") + continue + + else: + if home.cannot_activate_poet_dialog_box_is_visible: + print(f"POET install issues: {repo}") + continue + + # THEN content validation launches + home.click_validate_content_button() + home.click_validate_content_all_content_option() + + home.wait_for_validation_end( + lambda: home.validation_notification_dialog_box_is_visible + ) + + # THEN Problems tab is checked for any validation problems + chrome_page.keyboard.press("Escape") + home.click_problems_tab() + + try: + assert ( + "No problems have been detected in the workspace." + in home.problems_tab_message.inner_text() + ) + + except AssertionError: + print(f"!!! Problems detected under Problems tab: {repo}") + print(f"{home.problems_tab_message.inner_text()}") + + else: + print(f"NO PROBLEMS IN {repo}") + + home.click_gitpod_menubar() + home.click_stop_workspace_button() 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 ): From 8e7274cb9dda5c427b1b271518893e594b24ad8e Mon Sep 17 00:00:00 2001 From: Otto Mehes Date: Thu, 30 Nov 2023 15:06:45 -0600 Subject: [PATCH 2/2] removed the old validation test --- .../test_content_validation_all_repos.py | 151 ------------------ 1 file changed, 151 deletions(-) delete mode 100644 tests/ui/content/test_content_validation_all_repos.py diff --git a/tests/ui/content/test_content_validation_all_repos.py b/tests/ui/content/test_content_validation_all_repos.py deleted file mode 100644 index efd6b262..00000000 --- a/tests/ui/content/test_content_validation_all_repos.py +++ /dev/null @@ -1,151 +0,0 @@ -import pytest - -from tests.ui.pages.home import HomePoet - - -@pytest.mark.nondestructive -def test_content_validation_all_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 - - sign_in_button_selector = "input.btn.btn-primary.btn-block.js-sign-in-button" - - for repo in git_content_repos: - gitpod_repo_url = "https://gitpod.io/#https://github.com/openstax/" + repo - - print(f"VERIFYING: {gitpod_repo_url}") - - # WHEN: gitpod launches - chrome_page.goto(gitpod_repo_url) - home = HomePoet(chrome_page) - - if not home.github_login_button_is_visible: - 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 - if not home.openstax_icon_is_visible: - print("No openstax icon") - else: - home.click_openstax_icon() - - # THEN: TOC Editor and book list dropdown is visible - if not home.open_toc_editor_button_is_visible: - print(">>>TOC Editor button not loaded, skipping") - continue - - else: - if home.cannot_activate_poet_dialog_box_is_visible: - print(f"POET install issues: {repo}") - continue - - # THEN content validation launches - home.click_validate_content_button() - home.click_validate_content_all_content_option() - - home.wait_for_validation_end( - lambda: home.validation_notification_dialog_box_is_visible - ) - - # THEN Problems tab is checked for any validation problems - chrome_page.keyboard.press("Escape") - home.click_problems_tab() - - try: - assert ( - "No problems have been detected in the workspace." - in home.problems_tab_message.inner_text() - ) - - except AssertionError: - print(f"!!! Problems detected under Problems tab: {repo}") - print(f"{home.problems_tab_message.inner_text()}") - - else: - print(f"NO PROBLEMS IN {repo}") - - home.click_gitpod_menubar() - home.click_stop_workspace_button() - - else: - if home.private_repo_warning_is_visible: - print(f"SKIPPING! Book repo is private: {repo}") - continue - - else: - # WHEN: login into repo - home.click_github_login_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.gitpod_user_dropdown.inner_text() == "0 openstax": - pass - - else: - home.click_gitpod_user_dropdown() - home.click_gitpod_user_selector() - - home.click_workspace_continue_button() - - if not home.openstax_icon_is_visible: - print("No openstax icon") - else: - # THEN: openstax extension launches and icon appears - home.click_openstax_icon() - - # THEN: TOC Editor and book list dropdown is visible - if not home.open_toc_editor_button_is_visible: - print(">>> TOC Editor button not loaded, skipping") - continue - - else: - if home.cannot_activate_poet_dialog_box_is_visible: - print(f"POET install issues: {repo}") - continue - - # THEN content validation launches - home.click_validate_content_button() - home.click_validate_content_all_content_option() - - home.wait_for_validation_end( - lambda: home.validation_notification_dialog_box_is_visible - ) - - # THEN Problems tab is checked for any validation problems - chrome_page.keyboard.press("Escape") - home.click_problems_tab() - - try: - assert ( - "No problems have been detected in the workspace." - in home.problems_tab_message.inner_text() - ) - - except AssertionError: - print(f"!!! Problems detected under Problems tab: {repo}") - print(f"{home.problems_tab_message.inner_text()}") - - else: - print(f"NO PROBLEMS IN {repo}") - - home.click_gitpod_menubar() - home.click_stop_workspace_button()