diff --git a/e2e_tests/e2e/osweb/test_osweb_homepage_links.py b/e2e_tests/e2e/osweb/test_osweb_homepage_links.py new file mode 100644 index 0000000000..745e685d02 --- /dev/null +++ b/e2e_tests/e2e/osweb/test_osweb_homepage_links.py @@ -0,0 +1,45 @@ +import pytest + +from e2e_tests.e2e.ui.pages.home import HomeRex + + +@pytest.mark.asyncio +async def test_osweb_homepage_interested_link(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + # THEN: I'm interested page opens + await home.click_interested_link() + + assert "interest" in chrome_page.url + + await home.click_iam_dropdown_in_interested() + + assert await home.iam_dropdown_list_item.is_visible() + + await home.iam_dropdown_list_item.click() + + assert await home.iam_form_page.is_visible() + + +@pytest.mark.asyncio +async def test_osweb_homepage_try_assignable_link(chrome_page, base_url): + + # GIVEN: Playwright, chromium and the rex_base_url + + # WHEN: The Home page is fully loaded + await chrome_page.goto(base_url) + home = HomeRex(chrome_page) + + # THEN: Try OpenStax Assignable page opens + await home.click_try_assignable_link() + + assert "assignable" in chrome_page.url + + if "staging" not in chrome_page.url: + # THEN: Number of books available in assignables is 31 (as of Feb. 2026) + assert await home.available_book_list() >= 31 diff --git a/e2e_tests/e2e/ui/pages/home.py b/e2e_tests/e2e/ui/pages/home.py index 7181376694..ba92241338 100644 --- a/e2e_tests/e2e/ui/pages/home.py +++ b/e2e_tests/e2e/ui/pages/home.py @@ -23,6 +23,38 @@ async def osweb_homepage_content_sections(self): async def upper_menu_options(self): return await self.page.locator("div > nav > menu.container > li").count() + @pytest.mark.asyncio + async def click_interested_link(self): + interested_locator = self.page.get_by_role("link", name="I'm interested!") + await interested_locator.scroll_into_view_if_needed() + await interested_locator.click() + + @pytest.mark.asyncio + async def click_iam_dropdown_in_interested(self): + # I am a... dropdown in Interested page + iam_locator = self.page.get_by_role("combobox") + await iam_locator.scroll_into_view_if_needed() + await iam_locator.click() + + @property + def iam_dropdown_list_item(self): + return self.page.get_by_role("option", name="Administrator") + + @property + def iam_form_page(self): + return self.page.get_by_label("School name") + + @pytest.mark.asyncio + async def click_try_assignable_link(self): + try_locator = self.page.get_by_text("Try OpenStax Assignable") + await try_locator.scroll_into_view_if_needed() + await try_locator.click() + + async def available_book_list(self): + return ( + await self.page.locator(".course-list").first.locator("div > div").count() + ) + # Subjects homepage @pytest.mark.asyncio @@ -385,10 +417,6 @@ async def highlight_box_trash_icon_is_visible(self): async def click_highlight_box_trash_icon(self): await self.page.get_by_label("Deselect current highlight").click() - @pytest.mark.asyncio - async def oneclick_highlight_infobox(self): - await self.page.get_by_label("Edit highlighted note").click() - @property def highlight_infobox(self): return self.page.get_by_label("Edit highlighted note") diff --git a/e2e_tests/e2e/ui/test_book_opens.py b/e2e_tests/e2e/ui/test_book_opens.py index cc3f561b09..3d36919364 100644 --- a/e2e_tests/e2e/ui/test_book_opens.py +++ b/e2e_tests/e2e/ui/test_book_opens.py @@ -84,3 +84,5 @@ async def test_book_content_portal_opens(chrome_page, base_url): assert "404 Not Found - OpenStax" not in await new_tab.title() assert await new_tab.get_by_role("heading", name="Table of contents").is_visible() + + await chrome_page.close() diff --git a/e2e_tests/e2e/ui/test_highlight_box_delete_note.py b/e2e_tests/e2e/ui/test_highlight_box_delete_note.py index 60cd2395a0..89501debf4 100644 --- a/e2e_tests/e2e/ui/test_highlight_box_delete_note.py +++ b/e2e_tests/e2e/ui/test_highlight_box_delete_note.py @@ -25,15 +25,14 @@ async def test_small_highlight_box_delete_note( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is saved, then deleted and box disappears - await chrome_page.keyboard.press("Escape") await home.double_click_text() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") - assert home.highlight_box_is_visible + assert await home.highlight_box_is_visible() await home.fill_highlight_box_note_field("autotest highlight") diff --git a/e2e_tests/e2e/ui/test_highlight_box_save_note.py b/e2e_tests/e2e/ui/test_highlight_box_save_note.py index 7bd34f0d81..438996716f 100644 --- a/e2e_tests/e2e/ui/test_highlight_box_save_note.py +++ b/e2e_tests/e2e/ui/test_highlight_box_save_note.py @@ -27,14 +27,13 @@ async def test_highlight_box_save_note( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is saved - await chrome_page.keyboard.press("Escape") await home.select_text() await home.double_click_text() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -76,8 +75,8 @@ async def test_overlapping_highlights( await home.click_continue_login() - # THEN: Book page opens, a highlight exists and adding another highlight brings up an overlapping warning message - + # THEN: Book page opens, a highlight exists and adding another highlight brings up + # an overlapping warning message await chrome_page.keyboard.press("Escape") await home.select_text() @@ -91,7 +90,6 @@ async def test_overlapping_highlights( ) # THEN: Delete the created highlight - await home.click_highlights_option() await home.click_highlights_option_page_menu() @@ -125,15 +123,15 @@ async def test_highlight_box_note_colours( await home.click_continue_login() - # THEN: Book page opens, highlight box appears with colours and highlighted text can get different colour - + # THEN: Book page opens, highlight box appears with colours and highlighted text + # can get different colour await chrome_page.keyboard.press("Escape") await home.select_text() await home.double_click_text() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -165,7 +163,6 @@ async def test_highlight_box_note_colours( assert "green" in await home.highlights_option_text_colour_check_green # THEN: Delete the created highlight - await chrome_page.keyboard.press("Escape") await home.click_highlights_option_page_menu() diff --git a/e2e_tests/e2e/ui/test_highlight_editbox.py b/e2e_tests/e2e/ui/test_highlight_editbox.py index cf97958453..54c5425c7d 100644 --- a/e2e_tests/e2e/ui/test_highlight_editbox.py +++ b/e2e_tests/e2e/ui/test_highlight_editbox.py @@ -25,15 +25,14 @@ async def test_highlight_editbox_opens_on_one_click( await home.click_continue_login() # THEN: Book page opens, highlight infobox and edit box appears - await chrome_page.keyboard.press("Escape") await home.double_click_text() assert await home.highlight_infobox.is_visible() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -72,20 +71,18 @@ async def test_highlight_editbox_remains_open_when_clicked_inside( await home.click_continue_login() # THEN: Book page opens, highlight infobox and edit box appears - await chrome_page.keyboard.press("Escape") await home.double_click_text() assert await home.highlight_infobox.is_visible() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() # THEN: Highlight edit box remains open when note field is clicked - await home.click_highlight_box_note_field() assert await home.highlight_box_is_visible() @@ -100,7 +97,6 @@ async def test_highlight_editbox_remains_open_when_clicked_inside( ) # THEN: Delete the created highlight - await home.click_highlights_option_page_menu() await home.click_highlights_option_page_menu_delete() diff --git a/e2e_tests/e2e/ui/test_highlight_in_show_hide_solution.py b/e2e_tests/e2e/ui/test_highlight_in_show_hide_solution.py index fb238e8729..278ed9b3db 100644 --- a/e2e_tests/e2e/ui/test_highlight_in_show_hide_solution.py +++ b/e2e_tests/e2e/ui/test_highlight_in_show_hide_solution.py @@ -40,26 +40,8 @@ async def test_highlight_not_saved_in_show_hide_solution( # THEN: Double click text in solution dropdown await chrome_page.locator("#fs-id1165134108431").dblclick() - assert await home.highlight_infobox.is_visible() - - await home.oneclick_highlight_infobox() - - assert await home.highlight_box_is_visible() - - # THEN: Solution dialog closes - await home.click_show_hide_solution_link() - - assert not await home.highlight_box_is_visible() - - # THEN: Solution dialog opens - await home.click_show_hide_solution_link() - - assert not await home.highlight_box_is_visible() - - # THEN: Double click text in solution dropdown - await chrome_page.locator("#fs-id1165134108431").dblclick() - - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -72,6 +54,14 @@ async def test_highlight_not_saved_in_show_hide_solution( assert await home.highlight_infobox.is_visible() + # THEN: Tabbing down to the highlighted text + await chrome_page.keyboard.press("Tab") + await chrome_page.keyboard.press("Tab") + + await chrome_page.keyboard.press("Enter") + + assert await home.highlight_box_is_visible() + # THEN: Delete existing highlight await home.click_highlights_option() @@ -117,7 +107,8 @@ async def test_highlight_saved_in_show_hide_solution( assert await home.highlight_infobox.is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() diff --git a/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation.py b/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation.py index 6132211954..c8fd433e1e 100644 --- a/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation.py +++ b/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation.py @@ -27,14 +27,14 @@ async def test_highlight_unsaved_confirmation_on_chapter_change( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is saved - await chrome_page.keyboard.press("Escape") await home.double_click_text() assert await home.highlight_infobox.is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -43,7 +43,6 @@ async def test_highlight_unsaved_confirmation_on_chapter_change( await home.click_new_chapter() # THEN: Click another chapter with unsaved highlights and confirmation dialog pops up - assert await home.unsaved_highlight_dialog_is_visible() assert await home.unsaved_highlight_dialog_discard_button_is_visible() assert await home.unsaved_highlight_dialog_cancel_button_is_visible() @@ -52,7 +51,8 @@ async def test_highlight_unsaved_confirmation_on_chapter_change( assert not await home.unsaved_highlight_dialog_is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open only with pressing Enter key (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") # THEN: Escape key has to be pressed twice to dismiss both the edit and info boxes await chrome_page.keyboard.press("Escape") @@ -72,7 +72,6 @@ async def test_highlight_unsaved_confirmation_on_chapter_change( assert "Ideas for the Origin of the Moon" in await chrome_page.content() # THEN: Delete any existing highlights - await home.click_highlights_option() await home.click_highlights_option_page_menu() @@ -103,21 +102,21 @@ async def test_highlight_unsaved_confirmation_on_previous_next_page_change( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is saved - await chrome_page.keyboard.press("Escape") await home.double_click_text() assert await home.highlight_infobox.is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() await home.fill_highlight_box_note_field("autotest highlight") - # THEN: Click next page, then click previous page link with unsaved highlights and confirmation dialog pops up - + # THEN: Click next page, then click previous page link with unsaved highlights + # and confirmation dialog pops up await home.click_content_page_next_link() assert await home.unsaved_highlight_dialog_is_visible() @@ -134,7 +133,9 @@ async def test_highlight_unsaved_confirmation_on_previous_next_page_change( assert not await home.unsaved_highlight_dialog_is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Escape") + await chrome_page.keyboard.press("Enter") await home.fill_highlight_box_note_field("autotest highlight-2") @@ -143,7 +144,6 @@ async def test_highlight_unsaved_confirmation_on_previous_next_page_change( assert await home.small_highlighted_note_box_is_visible() # THEN: Delete any existing highlights - await home.click_highlights_option() await home.click_highlights_option_page_menu() @@ -174,14 +174,14 @@ async def test_highlight_unsaved_confirmation_on_small_highlight_dialog( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is saved - await chrome_page.keyboard.press("Escape") await home.double_click_text() assert await home.highlight_infobox.is_visible() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -189,10 +189,10 @@ async def test_highlight_unsaved_confirmation_on_small_highlight_dialog( await home.click_highlight_box_save_button() - assert home.small_highlighted_note_box_is_visible - - # THEN: Click next page, then click previous page link with unsaved highlights and confirmation dialog pops up + assert await home.small_highlighted_note_box_is_visible() + # THEN: Click next page, then click previous page link with unsaved highlights + # and confirmation dialog pops up await home.click_small_highlight_box_dropdown() await home.click_small_highlight_box_edit_button() @@ -229,7 +229,6 @@ async def test_highlight_unsaved_confirmation_on_small_highlight_dialog( assert not await home.highlight_box_is_visible() # THEN: Delete any existing highlights - await home.click_highlights_option() await home.click_highlights_option_page_menu() diff --git a/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation_dialog.py b/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation_dialog.py index 9dca5b29ea..143c78acca 100644 --- a/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation_dialog.py +++ b/e2e_tests/e2e/ui/test_highlight_unsaved_confirmation_dialog.py @@ -27,13 +27,12 @@ async def test_highlight_unsaved_confirmation_dialog( await home.click_continue_login() # THEN: Book page opens, highlight box appears, note is unsaved - await chrome_page.keyboard.press("Escape") await home.double_click_text() - # NOTE!!! For now infobox needs to be clicked twice to have the edit highlight box open - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") assert await home.highlight_box_is_visible() @@ -42,7 +41,6 @@ async def test_highlight_unsaved_confirmation_dialog( await home.fill_highlight_box_note_field("autotest highlight") # THEN: Click search with unsaved highlights and confirmation dialog pops up - await home.click_search() await home.fill_search_field('"about the Sun (88"') @@ -56,26 +54,22 @@ async def test_highlight_unsaved_confirmation_dialog( await home.click_cancel_changes_button() # THEN: Click openstax logo with unsaved highlights and confirmation dialog pops up - await home.click_openstax_logo() assert await home.unsaved_highlight_dialog_is_visible() await home.click_cancel_changes_button() # THEN: Click logout with unsaved highlights and confirmation dialog pops up - await home.click_logged_in_user_dropdown() await home.click_logout_link() assert await home.unsaved_highlight_dialog_is_visible() await home.click_cancel_changes_button() # THEN: Click Highlights option with unsaved highlights and confirmation dialog pops up - await home.click_highlights_option() assert await home.unsaved_highlight_dialog_is_visible() await home.click_cancel_changes_button() # THEN: Delete existing highlight - await chrome_page.keyboard.press("Escape") await home.click_highlights_option() diff --git a/e2e_tests/e2e/ui/test_highlights_page_edit_note.py b/e2e_tests/e2e/ui/test_highlights_page_edit_note.py index a074d312d8..8e099db360 100644 --- a/e2e_tests/e2e/ui/test_highlights_page_edit_note.py +++ b/e2e_tests/e2e/ui/test_highlights_page_edit_note.py @@ -25,15 +25,15 @@ async def test_highlights_page_edit_note( await home.click_continue_login() # THEN: Book page opens, highlight box appears and note can be edited - await chrome_page.keyboard.press("Escape") await home.select_text() await home.double_click_text() - await home.oneclick_highlight_infobox() + # THEN: Highlight infobox can be open by pressing Enter key only (as of Feb. 23, 2026) + await chrome_page.keyboard.press("Enter") - assert home.highlight_box_is_visible + assert await home.highlight_box_is_visible() await home.click_highlight_box_note_field() @@ -72,7 +72,6 @@ async def test_highlights_page_edit_note( await chrome_page.keyboard.press("Escape") # THEN: Delete the created highlight - await home.click_highlights_option() await home.click_highlights_option_page_menu() diff --git a/e2e_tests/e2e/ui/test_login_to_highlight_dialog.py b/e2e_tests/e2e/ui/test_login_to_highlight_dialog.py index 86094b0ab9..02b7afc990 100644 --- a/e2e_tests/e2e/ui/test_login_to_highlight_dialog.py +++ b/e2e_tests/e2e/ui/test_login_to_highlight_dialog.py @@ -28,11 +28,14 @@ async def test_login_to_highlight_dialog( assert not await home.small_login_box.is_visible() - # There is bug for this step. Once fixed, this test will be switched back on - # await home.double_click_text() - # assert await home.small_login_box.is_visible() - # await home.click_small_login_box_cancel() - # assert not await home.small_login_box.is_visible() + await home.double_click_text() + + assert await home.small_login_box.is_visible() + + # THEN: Small login box is dismissed by clicking the Cancel button + await home.click_small_login_box_cancel() + + assert not await home.small_login_box.is_visible() await home.double_click_text() @@ -56,7 +59,6 @@ async def test_login_to_highlight_dialog( assert await home.highlight_box_is_visible() # THEN: Delete existing highlight - await home.click_highlights_option() await home.click_highlights_option_page_menu()