Skip to content

Commit 408ea77

Browse files
committed
adjustments as per reviews
1 parent d25d3e3 commit 408ea77

File tree

4 files changed

+90
-26
lines changed

4 files changed

+90
-26
lines changed

playwright/e2e/ui/pages/home.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import asyncio
21
import pytest
32

4-
from playwright.async_api import expect
5-
6-
import re
7-
83

94
class HomeRex:
105
def __init__(self, page):
@@ -392,7 +387,7 @@ async def click_highlight_box_trash_icon(self):
392387

393388
@pytest.mark.asyncio
394389
async def oneclick_highlight_infobox(self):
395-
return await self.page.get_by_label("Edit highlighted note").click()
390+
await self.page.get_by_label("Edit highlighted note").click()
396391

397392
@property
398393
def highlight_infobox(self):
@@ -520,10 +515,6 @@ async def unsaved_highlight_dialog_cancel_button_is_visible(self):
520515
async def click_cancel_changes_button(self):
521516
await self.page.locator("div").get_by_test_id("cancel-discard").click()
522517

523-
@pytest.mark.asyncio
524-
async def click_discard_changes_button(self):
525-
await self.page.locator("div").get_by_test_id("discard-changes").click()
526-
527518
# Error states and pages
528519

529520
@pytest.mark.asyncio

playwright/e2e/ui/test_book.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
@pytest.mark.asyncio
7-
async def tst_book_title_links_to_books_detail_page(chrome_page, base_url):
7+
async def test_book_title_links_to_books_detail_page(chrome_page, base_url):
88

99
# GIVEN: Playwright, chromium and the rex_base_url
1010

@@ -24,7 +24,7 @@ async def tst_book_title_links_to_books_detail_page(chrome_page, base_url):
2424

2525
@pytest.mark.parametrize("book_slug", ["physics"])
2626
@pytest.mark.asyncio
27-
async def tst_buy_print_copy_link(chrome_page, base_url, book_slug):
27+
async def test_buy_print_copy_link(chrome_page, base_url, book_slug):
2828

2929
# GIVEN: Open osweb book details page
3030

@@ -51,7 +51,7 @@ async def tst_buy_print_copy_link(chrome_page, base_url, book_slug):
5151

5252
@pytest.mark.parametrize("book_slug", ["statistics"])
5353
@pytest.mark.asyncio
54-
async def tst_order_options_link(chrome_page, base_url, book_slug):
54+
async def test_order_options_link(chrome_page, base_url, book_slug):
5555

5656
# GIVEN: Open osweb book details page
5757

@@ -72,7 +72,7 @@ async def tst_order_options_link(chrome_page, base_url, book_slug):
7272
"book_slug, page_slug", [("astronomy-2e", "1-3-the-laws-of-nature")]
7373
)
7474
@pytest.mark.asyncio
75-
async def est_accessibility_help(chrome_page, base_url, book_slug, page_slug):
75+
async def test_accessibility_help(chrome_page, base_url, book_slug, page_slug):
7676
# Verifies the hidden 'Go to accessibility page'
7777

7878
# GIVEN: Open osweb book details page
@@ -97,7 +97,7 @@ async def est_accessibility_help(chrome_page, base_url, book_slug, page_slug):
9797

9898
@pytest.mark.parametrize("book_slug", ["algebra-and-trigonometry-2e"])
9999
@pytest.mark.asyncio
100-
async def tst_toc_slideout(chrome_page, base_url, book_slug):
100+
async def test_toc_slideout(chrome_page, base_url, book_slug):
101101

102102
# GIVEN: Open osweb book details page
103103

playwright/e2e/ui/test_highlight_box.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def test_highlight_box_opens_on_enter(
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

@@ -70,7 +70,7 @@ async def test_highlight_box_opens_on_one_click(
7070

7171
await home.click_continue_login()
7272

73-
# THEN: Book page opens, highlight box appears, then disappears on Escape key
73+
# THEN: Book page opens, highlight infobox and edit box appears
7474

7575
await chrome_page.keyboard.press("Escape")
7676

@@ -116,7 +116,7 @@ async def test_highlight_is_created_without_annotation_on_enter(
116116

117117
await home.click_continue_login()
118118

119-
# THEN: Book page opens, highlight box appears, then disappears on Escape key
119+
# THEN: Book page opens, highlight infobox and edit box appears
120120

121121
await chrome_page.keyboard.press("Escape")
122122

@@ -175,7 +175,7 @@ async def test_highlight_is_created_without_annotation_on_one_click(
175175

176176
await home.click_continue_login()
177177

178-
# THEN: Book page opens, highlight box appears, then disappears on Escape key
178+
# THEN: Book page opens, highlight infobox and edit box appears
179179

180180
await chrome_page.keyboard.press("Escape")
181181

playwright/e2e/ui/test_highlight_infobox.py

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)