-
Notifications
You must be signed in to change notification settings - Fork 2
osweb qa tests to complete existing rex tests #2570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
34
playwright/e2e/osweb/test_subjects_philanthropic_support.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
@@ -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 | ||
|
@@ -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): | ||
return await self.page.locator("section.philanthropic-support").is_visible() | ||
|
||
@property | ||
def our_impact_link(self): | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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