Skip to content

Commit d25d3e3

Browse files
committed
changes as per new highlight features and fixes
1 parent 41250c7 commit d25d3e3

File tree

4 files changed

+60
-47
lines changed

4 files changed

+60
-47
lines changed

playwright/e2e/ui/pages/home.py

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def main_menu_and_openstax_logo_is_visible(self):
2222

2323
@pytest.mark.asyncio
2424
async def osweb_homepage_content_sections(self):
25-
return await self.page.locator(f"main > section:nth-child(5)").is_visible()
25+
return await self.page.locator("main > section:nth-child(5)").is_visible()
2626

2727
@pytest.mark.asyncio
2828
async def upper_menu_options(self):
@@ -92,11 +92,11 @@ async def resources_tabs_are_visible(self):
9292

9393
@pytest.mark.asyncio
9494
async def click_instructor_resources_tab(self):
95-
await self.page.locator("id=Instructor resources-tab").click()
95+
await self.page.locator(r"#Instructor\ resources-tab").click()
9696

9797
@pytest.mark.asyncio
9898
async def click_student_resources_tab(self):
99-
await self.page.locator("id=Student resources-tab").click()
99+
await self.page.locator(r"#Student\ resources-tab").click()
100100

101101
@pytest.mark.asyncio
102102
async def click_subjects_science_link(self):
@@ -120,7 +120,7 @@ async def subjects_title(self):
120120

121121
@pytest.mark.asyncio
122122
async def highlights_option_is_visible(self):
123-
return await self.page.locator("id=nudge-study-tools").is_visible()
123+
return await self.page.locator("#nudge-study-tools").is_visible()
124124

125125
@pytest.mark.asyncio
126126
async def click_highlights_option(self):
@@ -194,7 +194,7 @@ async def click_give_today_link(self):
194194

195195
@pytest.mark.asyncio
196196
async def footer_section(self):
197-
return await self.page.locator("id=footer").is_visible()
197+
return await self.page.locator("#footer").is_visible()
198198

199199
@pytest.mark.asyncio
200200
async def footer_section_help_is_visible(self):
@@ -310,11 +310,11 @@ async def click_login_other(self):
310310

311311
@pytest.mark.asyncio
312312
async def fill_user_field(self, value):
313-
await self.page.locator("id=login_form_email").fill(value)
313+
await self.page.locator("#login_form_email").fill(value)
314314

315315
@pytest.mark.asyncio
316316
async def fill_password_field(self, value):
317-
await self.page.locator("id=login_form_password").fill(value)
317+
await self.page.locator("#login_form_password").fill(value)
318318

319319
@pytest.mark.asyncio
320320
async def click_continue_login(self):
@@ -391,30 +391,24 @@ async def click_highlight_box_trash_icon(self):
391391
await self.page.get_by_label("Deselect current highlight").click()
392392

393393
@pytest.mark.asyncio
394-
async def double_click_highlight_infobox(self):
395-
return (
396-
await self.page.get_by_role("dialog")
397-
.get_by_text("Press Enter or double-click highlight to edit highlight")
398-
.dblclick()
399-
)
394+
async def oneclick_highlight_infobox(self):
395+
return await self.page.get_by_label("Edit highlighted note").click()
400396

401397
@property
402398
def highlight_infobox(self):
403-
return self.page.get_by_role("dialog").get_by_text(
404-
"Press Enter or double-click highlight to edit highlight"
405-
)
399+
return self.page.get_by_label("Edit highlighted note")
406400

407401
@pytest.mark.asyncio
408402
async def highlight_box_is_visible(self):
409-
return await self.page.locator("id=note-textarea").is_visible()
403+
return await self.page.locator("#note-textarea").is_visible()
410404

411405
@pytest.mark.asyncio
412406
async def click_highlight_box_note_field(self):
413-
await self.page.locator("id=note-textarea").click()
407+
await self.page.locator("#note-textarea").click()
414408

415409
@pytest.mark.asyncio
416410
async def fill_highlight_box_note_field(self, value):
417-
await self.page.locator("id=note-textarea").fill(value)
411+
await self.page.locator("#note-textarea").fill(value)
418412

419413
@pytest.mark.asyncio
420414
async def highlight_box_colours_are_visible(self):
@@ -432,25 +426,13 @@ async def click_highlight_box_purple_colour(self):
432426
async def click_highlights_option_green_colour(self):
433427
await self.page.locator("div").get_by_title("green").first.click()
434428

435-
@property
436-
def highlights_option_text_colour_purple(self):
437-
return self.page.locator(
438-
"div.HighlightListElement__HighlightContentWrapper-s4j4lf-1.ibAyfS"
439-
)
440-
441-
@property
442-
def highlights_option_text_colour_green(self):
443-
return self.page.locator(
444-
"div.HighlightListElement__HighlightContentWrapper-s4j4lf-1.kuxHtj"
445-
)
446-
447429
@property
448430
def highlights_option_text_colour_check_purple(self):
449-
return self.highlights_option_text_colour_purple.get_attribute("color")
431+
return self.page.locator('div[color="purple"]').get_attribute("color")
450432

451433
@property
452434
def highlights_option_text_colour_check_green(self):
453-
return self.highlights_option_text_colour_green.get_attribute("color")
435+
return self.page.locator('div[color="green"]').get_attribute("color")
454436

455437
@pytest.mark.asyncio
456438
async def small_highlighted_note_box_is_visible(self):
@@ -498,7 +480,7 @@ async def click_new_chapter(self):
498480

499481
@pytest.mark.asyncio
500482
async def click_show_hide_solution_link(self):
501-
await self.page.locator("id=fs-id1165134108429").get_by_title(
483+
await self.page.locator("#fs-id1165134108429").get_by_title(
502484
"Show/Hide Solution"
503485
).click()
504486

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 test_book_title_links_to_books_detail_page(chrome_page, base_url):
7+
async def tst_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 test_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 test_buy_print_copy_link(chrome_page, base_url, book_slug):
27+
async def tst_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 test_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 test_order_options_link(chrome_page, base_url, book_slug):
54+
async def tst_order_options_link(chrome_page, base_url, book_slug):
5555

5656
# GIVEN: Open osweb book details page
5757

@@ -72,7 +72,7 @@ async def test_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 test_accessibility_help(chrome_page, base_url, book_slug, page_slug):
75+
async def est_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 test_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 test_toc_slideout(chrome_page, base_url, book_slug):
100+
async def tst_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: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def test_highlight_box_opens_on_enter(
5353
@pytest.mark.parametrize(
5454
"book_slug, page_slug", [("astronomy-2e", "9-3-impact-craters")]
5555
)
56-
async def test_highlight_box_opens_on_double_click(
56+
async def test_highlight_box_opens_on_one_click(
5757
chrome_page, base_url, book_slug, page_slug, rex_user, rex_password
5858
):
5959

@@ -78,7 +78,7 @@ async def test_highlight_box_opens_on_double_click(
7878

7979
assert await home.highlight_infobox.is_visible()
8080

81-
await home.double_click_highlight_infobox()
81+
await home.oneclick_highlight_infobox()
8282

8383
assert await home.highlight_box_is_visible()
8484

@@ -87,12 +87,19 @@ async def test_highlight_box_opens_on_double_click(
8787

8888
await home.click_highlight_box_trash_icon()
8989

90+
await home.click_highlights_option()
91+
92+
assert (
93+
"You have no highlights in this book"
94+
in await home.highlights_option_page_is_empty.inner_text()
95+
)
96+
9097

9198
@pytest.mark.asyncio
9299
@pytest.mark.parametrize(
93100
"book_slug, page_slug", [("astronomy-2e", "9-3-impact-craters")]
94101
)
95-
async def tst_highlight_is_created_without_annotation_on_enter(
102+
async def test_highlight_is_created_without_annotation_on_enter(
96103
chrome_page, base_url, book_slug, page_slug, rex_user, rex_password
97104
):
98105

@@ -134,12 +141,24 @@ async def tst_highlight_is_created_without_annotation_on_enter(
134141
not in await home.highlights_option_page_is_empty.inner_text()
135142
)
136143

144+
# THEN: Delete the created highlight
145+
146+
await home.click_highlights_option_page_menu()
147+
148+
await home.click_highlights_option_page_menu_delete()
149+
await home.click_highlights_option_page_menu_delete_delete()
150+
151+
assert (
152+
"You have no highlights in this book"
153+
in await home.highlights_option_page_is_empty.inner_text()
154+
)
155+
137156

138157
@pytest.mark.asyncio
139158
@pytest.mark.parametrize(
140159
"book_slug, page_slug", [("astronomy-2e", "9-3-impact-craters")]
141160
)
142-
async def tst_highlight_is_created_without_annotation_on_double_click(
161+
async def test_highlight_is_created_without_annotation_on_one_click(
143162
chrome_page, base_url, book_slug, page_slug, rex_user, rex_password
144163
):
145164

@@ -164,7 +183,7 @@ async def tst_highlight_is_created_without_annotation_on_double_click(
164183

165184
assert await home.highlight_infobox.is_visible()
166185

167-
await home.double_click_highlight_infobox()
186+
await home.oneclick_highlight_infobox()
168187

169188
assert await home.highlight_box_is_visible()
170189

@@ -178,3 +197,15 @@ async def tst_highlight_is_created_without_annotation_on_double_click(
178197
"You have no highlights in this book"
179198
not in await home.highlights_option_page_is_empty.inner_text()
180199
)
200+
201+
# THEN: Delete the created highlight
202+
203+
await home.click_highlights_option_page_menu()
204+
205+
await home.click_highlights_option_page_menu_delete()
206+
await home.click_highlights_option_page_menu_delete_delete()
207+
208+
assert (
209+
"You have no highlights in this book"
210+
in await home.highlights_option_page_is_empty.inner_text()
211+
)

playwright/e2e/ui/test_highlight_unsaved_confirmation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def test_highlight_unsaved_confirmation_on_chapter_change(
3434

3535
assert await home.highlight_infobox.is_visible()
3636

37-
await home.double_click_highlight_infobox()
37+
await home.oneclick_highlight_infobox()
3838

3939
assert await home.highlight_box_is_visible()
4040

@@ -52,7 +52,7 @@ async def test_highlight_unsaved_confirmation_on_chapter_change(
5252

5353
assert not await home.unsaved_highlight_dialog_is_visible()
5454

55-
await home.double_click_highlight_infobox()
55+
await home.oneclick_highlight_infobox()
5656

5757
await chrome_page.keyboard.press("Escape")
5858

@@ -132,7 +132,7 @@ async def test_highlight_unsaved_confirmation_on_previous_next_page_change(
132132

133133
assert not await home.unsaved_highlight_dialog_is_visible()
134134

135-
await chrome_page.keyboard.press("Enter")
135+
await home.oneclick_highlight_infobox()
136136

137137
await home.fill_highlight_box_note_field("autotest highlight-2")
138138

0 commit comments

Comments
 (0)