Skip to content

Commit

Permalink
Stabilize oauth test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Jan 3, 2025
1 parent 53c3257 commit c1bcbaa
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/pcloud/tests/test_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from playwright.sync_api import sync_playwright, expect

from urllib.parse import urlparse


folder_for_tests = "integration-test"

Expand All @@ -19,20 +21,25 @@ class PlaywrightTokenHandler(TokenHandler):
"""

def open_browser(self):
parts = urlparse(self.auth_url)
home_url = f"{parts.scheme}://{parts.hostname}/"

with sync_playwright() as p:
# set headless to `False` for debugging purposes
self.browser = p.firefox.launch(headless=True)
self.browser = p.firefox.launch(headless=False)
self.browser.new_context(
locale="de-DE",
timezone_id="Europe/Berlin",
)
page = self.browser.new_page()
log.info(self.auth_url)
page.goto(self.auth_url)
page.goto(home_url)
page.get_by_placeholder("Email").fill(os.environ.get("PCLOUD_USERNAME"))
page.get_by_text("Continue", exact=True).click()
page.locator("[type=submit]").click()
page.get_by_placeholder("Password").fill(os.environ.get("PCLOUD_PASSWORD"))
page.get_by_text("Log in", exact=True).click()
page.locator("[type=submit]").click()
expect(page.get_by_text("[email protected]")).to_be_visible()
log.info(self.auth_url)
page.goto(self.auth_url)
expect(page.get_by_text("You may now close this window.")).to_be_visible()


Expand Down

0 comments on commit c1bcbaa

Please sign in to comment.