From e0d1834ade61ff26819044f4ea108caa2c741f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ott=C3=B3?= Date: Tue, 30 Jul 2024 11:20:57 -0500 Subject: [PATCH] adding cat qa tests --- tests/ui/pages/home.py | 30 ++++++++++++++++++ tests/ui/test_cat_h5p.py | 66 ++++++++++++++++++++++++++++++++++++++++ tests/ui/test_home_ui.py | 1 + 3 files changed, 97 insertions(+) create mode 100644 tests/ui/test_cat_h5p.py diff --git a/tests/ui/pages/home.py b/tests/ui/pages/home.py index 671fe27e..e932bf0a 100644 --- a/tests/ui/pages/home.py +++ b/tests/ui/pages/home.py @@ -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 diff --git a/tests/ui/test_cat_h5p.py b/tests/ui/test_cat_h5p.py new file mode 100644 index 00000000..3171cb46 --- /dev/null +++ b/tests/ui/test_cat_h5p.py @@ -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() diff --git a/tests/ui/test_home_ui.py b/tests/ui/test_home_ui.py index 2284fb62..6b455028 100644 --- a/tests/ui/test_home_ui.py +++ b/tests/ui/test_home_ui.py @@ -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()