77@pytest .mark .parametrize (
88 "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
99)
10- async def test_highlight_box_dismiss_with_esc (
10+ async def test_highlight_box_opens_on_enter (
1111 chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
1212):
1313
@@ -30,23 +30,69 @@ async def test_highlight_box_dismiss_with_esc(
3030
3131 await home .double_click_text ()
3232
33+ assert await home .highlight_infobox .is_visible ()
34+
35+ await chrome_page .keyboard .press ("Enter" )
36+
3337 assert await home .highlight_box_is_visible ()
3438
3539 assert await home .highlight_box_colours_are_visible ()
40+ assert await home .highlight_box_trash_icon_is_visible ()
41+
42+ await home .click_highlight_box_trash_icon ()
43+
44+ await home .click_highlights_option ()
45+
46+ assert (
47+ "You have no highlights in this book"
48+ in await home .highlights_option_page_is_empty .inner_text ()
49+ )
50+
51+
52+ @pytest .mark .asyncio
53+ @pytest .mark .parametrize (
54+ "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
55+ )
56+ async def test_highlight_box_opens_on_double_click (
57+ chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
58+ ):
59+
60+ # GIVEN: Playwright, chromium and the rex_base_url
61+
62+ # WHEN: The Home page is fully loaded
63+ await chrome_page .goto (f"{ base_url } /books/{ book_slug } /pages/{ page_slug } " )
64+ home = HomeRex (chrome_page )
65+
66+ await home .click_login ()
67+
68+ await home .fill_user_field (rex_user )
69+ await home .fill_password_field (rex_password )
70+
71+ await home .click_continue_login ()
72+
73+ # THEN: Book page opens, highlight box appears, then disappears on Escape key
3674
3775 await chrome_page .keyboard .press ("Escape" )
3876
39- # Adjusting the test until the expected behaviour is implemented for Escape key (to avoid test fail)
77+ await home .double_click_text ()
78+
79+ assert await home .highlight_infobox .is_visible ()
80+
81+ await home .double_click_highlight_infobox ()
82+
4083 assert await home .highlight_box_is_visible ()
41- # await home.click_highlights_option()
42- # assert "You have no highlights in this book" not in await home.highlights_option_page_is_empty.inner_text()
84+
85+ assert await home .highlight_box_colours_are_visible ()
86+ assert await home .highlight_box_trash_icon_is_visible ()
87+
88+ await home .click_highlight_box_trash_icon ()
4389
4490
4591@pytest .mark .asyncio
4692@pytest .mark .parametrize (
4793 "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
4894)
49- async def test_highlight_box_dismiss_with_click (
95+ async def tst_highlight_is_created_without_annotation_on_enter (
5096 chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
5197):
5298
@@ -63,31 +109,37 @@ async def test_highlight_box_dismiss_with_click(
63109
64110 await home .click_continue_login ()
65111
66- # THEN: Book page opens, highlight box appears, then disappears on clicking away from the box
112+ # THEN: Book page opens, highlight box appears, then disappears on Escape key
67113
68114 await chrome_page .keyboard .press ("Escape" )
69115
70116 await home .double_click_text ()
71117
118+ assert await home .highlight_infobox .is_visible ()
119+
120+ await chrome_page .keyboard .press ("Enter" )
121+
72122 assert await home .highlight_box_is_visible ()
73123
74- await home . click_other_text ( )
124+ await chrome_page . keyboard . press ( "Escape" )
75125
76126 assert not await home .highlight_box_is_visible ()
77127
128+ await chrome_page .keyboard .press ("Enter" )
129+
78130 await home .click_highlights_option ()
79131
80132 assert (
81133 "You have no highlights in this book"
82- in await home .highlights_option_page_is_empty .inner_text ()
134+ not in await home .highlights_option_page_is_empty .inner_text ()
83135 )
84136
85137
86138@pytest .mark .asyncio
87139@pytest .mark .parametrize (
88140 "book_slug, page_slug" , [("astronomy-2e" , "9-3-impact-craters" )]
89141)
90- async def test_highlight_box_click_highlights_option_after_highlighting_text (
142+ async def tst_highlight_is_created_without_annotation_on_double_click (
91143 chrome_page , base_url , book_slug , page_slug , rex_user , rex_password
92144):
93145
@@ -104,21 +156,25 @@ async def test_highlight_box_click_highlights_option_after_highlighting_text(
104156
105157 await home .click_continue_login ()
106158
107- # THEN: Book page opens, highlight box appears, then disappears on clicking the highlights option page
159+ # THEN: Book page opens, highlight box appears, then disappears on Escape key
108160
109161 await chrome_page .keyboard .press ("Escape" )
110162
111163 await home .double_click_text ()
112164
165+ assert await home .highlight_infobox .is_visible ()
166+
167+ await home .double_click_highlight_infobox ()
168+
113169 assert await home .highlight_box_is_visible ()
114170
171+ await chrome_page .keyboard .press ("Escape" )
172+
173+ assert not await home .highlight_box_is_visible ()
174+
115175 await home .click_highlights_option ()
116176
117177 assert (
118178 "You have no highlights in this book"
119- in await home .highlights_option_page_is_empty .inner_text ()
179+ not in await home .highlights_option_page_is_empty .inner_text ()
120180 )
121-
122- await chrome_page .keyboard .press ("Escape" )
123-
124- assert not await home .highlight_box_is_visible ()
0 commit comments