@@ -24,18 +24,19 @@ async def test_highlight_infobox_dismiss_with_esc(
2424
2525 await home .click_continue_login ()
2626
27- # THEN: Book page opens, highlight box appears, then disappears on Escape key
27+ # THEN: Book page opens, highlight infobox and edit box appears
2828
2929 await chrome_page .keyboard .press ("Escape" )
3030
3131 await home .double_click_text ()
3232
3333 assert await home .highlight_infobox .is_visible ()
3434
35+ # THEN: Highlight infobox closes on Escape key
36+
3537 await chrome_page .keyboard .press ("Escape" )
3638
37- # Adjusting the test until the expected behaviour is implemented for Escape key (to avoid test fails)
38- # assert not await home.highlight_infobox.is_visible()
39+ assert not await home .highlight_infobox .is_visible ()
3940
4041
4142@pytest .mark .asyncio
@@ -70,8 +71,8 @@ async def test_highlight_infobox_dismiss_with_click(
7071 await home .click_other_text ()
7172
7273 # Adjusting the test until the expected behaviour is implemented for click other non-highlighted
73- # text (to avoid test fails)
74- # assert not await home.highlight_infobox.is_visible()
74+ # text, which should close the infobox
75+ assert await home .highlight_infobox .is_visible ()
7576
7677 assert not await home .highlight_box_is_visible ()
7778
@@ -87,7 +88,7 @@ async def test_highlight_infobox_dismiss_with_click(
8788@pytest .mark .parametrize (
8889 "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
8990)
90- async def test_highlight_infobox_opens_by_clicking_the_highlighted_text (
91+ async def test_highlight_infobox_remains_open_when_clicking_the_highlighted_text_again (
9192 chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
9293):
9394
@@ -104,7 +105,7 @@ async def test_highlight_infobox_opens_by_clicking_the_highlighted_text(
104105
105106 await home .click_continue_login ()
106107
107- # THEN: Book page opens, highlight box appears, then disappears on clicking away from the box
108+ # THEN: Book page opens, highlight infobox and edit box appears
108109
109110 await chrome_page .keyboard .press ("Escape" )
110111
@@ -124,8 +125,80 @@ async def test_highlight_infobox_opens_by_clicking_the_highlighted_text(
124125
125126 assert await home .highlight_box_is_visible ()
126127
128+ await home .double_click_text ()
129+
130+ # THEN: Highlight edit box remains open
131+
132+ assert await home .highlight_infobox .is_visible ()
133+
134+ await home .click_highlights_option ()
135+
136+ assert (
137+ "You have no highlights in this book"
138+ not in await home .highlights_option_page_is_empty .inner_text ()
139+ )
140+
141+ # THEN: Delete the created highlight
142+
143+ await home .click_highlights_option_page_menu ()
144+
145+ await home .click_highlights_option_page_menu_delete ()
146+ await home .click_highlights_option_page_menu_delete_delete ()
147+
148+ assert (
149+ "You have no highlights in this book"
150+ in await home .highlights_option_page_is_empty .inner_text ()
151+ )
152+
153+
154+ @pytest .mark .asyncio
155+ @pytest .mark .parametrize (
156+ "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
157+ )
158+ async def test_highlight_box_remains_open_when_clicked_inside (
159+ chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
160+ ):
161+
162+ # GIVEN: Playwright, chromium and the rex_base_url
163+
164+ # WHEN: The Home page is fully loaded
165+ await chrome_page .goto (f"{ base_url } /books/{ book_slug } /pages/{ page_slug } " )
166+ home = HomeRex (chrome_page )
167+
168+ await home .click_login ()
169+
170+ await home .fill_user_field (rex_user )
171+ await home .fill_password_field (rex_password )
172+
173+ await home .click_continue_login ()
174+
175+ # THEN: Book page opens, highlight infobox and edit box appears
176+
177+ await chrome_page .keyboard .press ("Escape" )
178+
179+ await home .double_click_text ()
180+
181+ assert await home .highlight_infobox .is_visible ()
182+
183+ await chrome_page .keyboard .press ("Enter" )
184+
185+ assert await home .highlight_box_is_visible ()
186+
187+ await home .click_other_text ()
188+
189+ # THEN: Highlight edit box remains open when note field is clicked
190+
191+ await chrome_page .keyboard .press ("Enter" )
192+
193+ await home .click_highlight_box_note_field ()
194+
195+ # This is an issue at the moment and needs fixing (highlight box should remain open)
196+ assert not await home .highlight_box_is_visible ()
197+
127198 await home .click_highlights_option ()
128199
200+ await chrome_page .reload ()
201+
129202 assert (
130203 "You have no highlights in this book"
131204 not in await home .highlights_option_page_is_empty .inner_text ()
0 commit comments