Skip to content
14 changes: 12 additions & 2 deletions playwright/e2e/ui/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ def book_toc_slideout_is_visible(self):

@pytest.mark.asyncio
async def click_book_cover_link(self):
await self.page.locator("a").get_by_text("Calculus Volume 1").click()
await self.page.locator("a").get_by_text(
"Principles of Management"
).scroll_into_view_if_needed()
await self.page.locator("a").get_by_text("Principles of Management").click()

@pytest.mark.asyncio
async def click_view_online_link(self):
await self.page.locator("a").get_by_text("View online").click()
await self.page.get_by_role(
"link", name="View online"
).scroll_into_view_if_needed()
await self.page.get_by_role("link", name="View online").click()

@pytest.mark.asyncio
async def click_go_to_your_book_link(self):
Expand Down Expand Up @@ -116,6 +122,10 @@ async def subjects_title(self):
await self.page.locator("section.subject-intro > div > h1").inner_text()
).lower()

@property
def book_title_image(self):
return self.page.get_by_alt_text("Principles of Management")

# Highlights and Notes

@pytest.mark.asyncio
Expand Down
6 changes: 3 additions & 3 deletions playwright/e2e/ui/test_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ async def test_book_title_links_to_books_detail_page(chrome_page, base_url):

await home.click_book_selection()

# THEN: The page navigates to {base_url}/details/books/astronomy-2e
assert "astronomy-2e" in chrome_page.url
# THEN: The page navigates to {base_url}/details/books/astronomy
assert "astronomy" in chrome_page.url.lower()


@pytest.mark.parametrize("book_slug", ["physics"])
Expand Down Expand Up @@ -73,7 +73,7 @@ async def test_order_options_link(chrome_page, base_url, book_slug):
)
@pytest.mark.asyncio
async def test_accessibility_help(chrome_page, base_url, book_slug, page_slug):
# Verifies the hidden 'Go to accessibility page'
"""Verifies the hidden 'Go to accessibility page'"""

# GIVEN: Open osweb book details page

Expand Down
26 changes: 17 additions & 9 deletions playwright/e2e/ui/test_book_opens.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,29 @@ async def test_book_opens(chrome_page, base_url):
# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(f"{base_url}/subjects/math")
await chrome_page.goto(f"{base_url}/subjects/business")
home = HomeRex(chrome_page)

await home.click_book_cover_link()
if "staging" not in chrome_page.url:

# THEN: Book details page opens
# THEN: Book details page opens (openstax prod)
await home.click_book_cover_link()

assert "calculus-volume-1" in chrome_page.url
await home.book_title_image.is_visible()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need assert await ... here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... I fixed that in the meantime. thanks


assert await home.highlight_recommended_popup_is_visible()
assert await home.highlight_recommended_popup_is_visible()

assert await home.order_print_copy_options_box_is_visible()
assert await home.order_print_copy_options_box_is_visible()

await home.click_view_online_link()
await home.click_view_online_link()

await home.click_go_to_your_book_link()
await home.click_go_to_your_book_link()

assert await home.toc_is_visible()
assert await home.toc_is_visible()

else:

# THEN: Book details page opens (openstax staging)
await home.click_book_cover_link()

await home.book_title_image.is_visible()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... I fixed that in the meantime. thanks

Loading