Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions playwright/e2e/osweb/test_osweb_homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest
import asyncio

from e2e.ui.pages.home import HomeRex


@pytest.mark.asyncio
async def test_osweb_homepage_loads(chrome_page, base_url):

# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(base_url)
home = HomeRex(chrome_page)

# THEN: Openstax logo and osweb homepage sections are is visible
assert await home.main_menu_and_openstax_logo_is_visible()
assert await home.osweb_homepage_content_sections()
39 changes: 39 additions & 0 deletions playwright/e2e/osweb/test_subjects_books_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest
import asyncio

from e2e.ui.pages.home import HomeRex


@pytest.mark.asyncio
async def test_subjects_books_pages_load(chrome_page, base_url):
# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(base_url)
home = HomeRex(chrome_page)

await home.click_subjects_page_menu()

# THEN: Subjects list shows and subjects pages load
scount = await home.subjects_list.count()

for i in range(scount):
item = home.subjects_list.nth(i)
hrefs = await item.get_attribute("href")
slink = f"{base_url}{hrefs}"

slink_resp = await chrome_page.goto(slink)

assert slink_resp.status == 200

try:
assert await home.subjects_intro()

except AssertionError:
continue

else:
mhrefs = hrefs.replace("/subjects/", "")
mod_hrefs = mhrefs.replace("-", " ")

assert await home.subjects_title() in mod_hrefs
32 changes: 32 additions & 0 deletions playwright/e2e/osweb/test_subjects_footer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
import asyncio

from e2e.ui.pages.home import HomeRex


@pytest.mark.asyncio
async def test_subjects_footer(chrome_page, base_url):

# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(base_url)
home = HomeRex(chrome_page)

await home.click_subjects_page_menu()

await home.click_subjects_homepage_link()

# THEN: Footer section loads
assert await home.footer_section()

assert await home.footer_section_help_is_visible()
assert await home.footer_section_openstax_is_visible()
assert await home.footer_section_policies_is_visible()

assert await home.footer_section_bottom_is_visible()

assert ("Rice University" in await home.footer_section_bottom.inner_text()
and "license" in await home.footer_section_bottom.inner_text())

assert "https://creativecommons.org" in await home.footer_section_license_link()
38 changes: 38 additions & 0 deletions playwright/e2e/osweb/test_subjects_homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pytest
import asyncio

from e2e.ui.pages.home import HomeRex


@pytest.mark.asyncio
async def test_subjects_homepage(chrome_page, base_url):

# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(base_url)
home = HomeRex(chrome_page)

assert await home.subjects_page_menu()

await home.click_subjects_page_menu()

await home.click_subjects_homepage_link()

subjects_list = ["Business", "College Success", "Computer Science", "Humanities", "Math", "Nursing",
"Science", "Social Sciences"]

# THEN: Book subjects homepage opens
assert "English, Spanish, and Polish" in await home.language_selector_section.inner_text()

for subject in subjects_list:
assert subject in await home.subjects_listing_section.inner_text()

about = await home.about_openstax_section.inner_text()
assert "about openstax textbooks" in about.lower()

await home.click_learn_about_openstax_link()

assert f"{base_url}/about" == chrome_page.url
assert ("Who we are" in await home.about_page.inner_text() and "What we do" in await home.about_page.inner_text()
and "Where we're going" in await home.about_page.inner_text())
34 changes: 34 additions & 0 deletions playwright/e2e/osweb/test_subjects_philanthropic_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
import asyncio

from e2e.ui.pages.home import HomeRex


@pytest.mark.asyncio
async def test_subjects_philanthropic_support(chrome_page, base_url):

# GIVEN: Playwright, chromium and the rex_base_url

# WHEN: The Home page is fully loaded
await chrome_page.goto(base_url)
home = HomeRex(chrome_page)

await home.click_subjects_page_menu()

await home.click_subjects_homepage_link()

assert await home.philanthropic_support_section()

# THEN: Philanthropic support section opens
await home.click_our_impact_link()

assert f"{base_url}/impact" == chrome_page.url

assert await home.give_today_link_is_visible()

async with chrome_page.expect_popup() as popup_info:
await home.click_give_today_link()

new_tab = await popup_info.value

assert "riceconnect.rice.edu/donation/support-openstax-" in new_tab.url
85 changes: 60 additions & 25 deletions playwright/e2e/ui/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,31 @@ def __init__(self, page):
async def click_openstax_logo(self):
await self.page.get_by_test_id("navbar").get_by_role("img").click()

# Subjects homepage
@pytest.mark.asyncio
async def main_menu_and_openstax_logo_is_visible(self):
return await self.page.locator("div.menus.desktop > nav.nav").is_visible()

@pytest.mark.asyncio
async def osweb_homepage_content_is_visible(self):
return await self.page.locator("main > section:nth-child(5)").is_visible()

@property
def subjects_page_menu(self):
return self.page.get_by_role("button", name="Subjects")
def osweb_homepage_sections(self):
return self.page.locator("main")

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

# Subjects homepage

@pytest.mark.asyncio
async def subjects_page_menu(self):
return await self.page.get_by_role("button", name="Subjects").is_visible()

@pytest.mark.asyncio
async def click_subjects_page_menu(self):
await self.subjects_page_menu.hover()
await self.page.get_by_role("button", name="Subjects").hover()

@property
def subjects_homepage_link(self):
Expand Down Expand Up @@ -118,6 +134,22 @@ async def click_instructor_resources_tab(self):
async def click_student_resources_tab(self):
await self.page.locator("id=Student resources-tab").click()

@pytest.mark.asyncio
async def click_subjects_science_link(self):
await self.subjects_science_link.click()

@property
def subjects_list(self):
return self.page.locator("#ddId-Subjects > a")

@pytest.mark.asyncio
async def subjects_intro(self):
return await self.page.locator("section.subject-intro").is_visible()

@pytest.mark.asyncio
async def subjects_title(self):
return (await self.page.locator("section.subject-intro > div > h1").inner_text()).lower()

# Highlights and Notes

@property
Expand Down Expand Up @@ -212,9 +244,9 @@ async def close_giving_tuesday_popup(self):

# Philanthropic support

@property
def philanthropic_support_section(self):
return self.page.locator("section.philanthropic-support")
@pytest.mark.asyncio
async def philanthropic_support_section(self):
Copy link
Member

Choose a reason for hiding this comment

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

This one maybe should end in _is_visible

return await self.page.locator("section.philanthropic-support").is_visible()

@property
def our_impact_link(self):
Expand All @@ -224,37 +256,40 @@ def our_impact_link(self):
async def click_our_impact_link(self):
await self.our_impact_link.click()

@property
def give_today_link_is_visible(self):
return self.page.locator("#footer").get_by_role("link", name="Give today")
@pytest.mark.asyncio
async def give_today_link_is_visible(self):
return await self.page.locator("#footer").get_by_role("link", name="Give today").is_visible()

@pytest.mark.asyncio
async def click_give_today_link(self):
await self.give_today_link_is_visible.click()
await self.page.locator("#footer").get_by_role("link", name="Give today").click()

# Subjects page footer section

@property
def footer_section(self):
return self.page.locator("id=footer")
@pytest.mark.asyncio
async def footer_section(self):
Copy link
Member

Choose a reason for hiding this comment

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

same here

return await self.page.locator("id=footer").is_visible()

@property
def footer_section_help_is_visible(self):
return self.page.locator("div.column.col1")
@pytest.mark.asyncio
async def footer_section_help_is_visible(self):
return await self.page.locator("div.column.col1").is_visible()

@property
def footer_section_openstax_is_visible(self):
return self.page.locator("div.column.col2")
@pytest.mark.asyncio
async def footer_section_openstax_is_visible(self):
return await self.page.locator("div.column.col2").is_visible()

@property
def footer_section_policies_is_visible(self):
return self.page.locator("div.column.col3")
@pytest.mark.asyncio
async def footer_section_policies_is_visible(self):
return await self.page.locator("div.column.col3").is_visible()

@pytest.mark.asyncio
async def footer_section_bottom_is_visible(self):
return await self.page.locator("div.bottom").is_visible()

@property
def footer_section_bottom_is_visible(self):
def footer_section_bottom(self):
return self.page.locator("div.bottom")

@property
@pytest.mark.asyncio
async def footer_section_license_link(self):
return await self.page.locator("div.copyrights").get_by_role("link").get_attribute("href")
Expand Down
Loading