use os.environ["TEST_USER"], fix check_if_user_exists
This commit is contained in:
parent
8e926d4e64
commit
6be9fdc535
1 changed files with 15 additions and 12 deletions
|
|
@ -2,15 +2,14 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from playwright.sync_api import BrowserContext, expect
|
from playwright.sync_api import BrowserContext, TimeoutError, expect
|
||||||
|
|
||||||
from pytest_abra import BaseUrl, DirManager
|
from pytest_abra import BaseUrl, DirManager
|
||||||
|
|
||||||
ADMIN_USER = os.environ["ADMIN_USER"]
|
ADMIN_USER = os.environ["ADMIN_USER"]
|
||||||
ADMIN_PASS = os.environ["ADMIN_PASS"]
|
ADMIN_PASS = os.environ["ADMIN_PASS"]
|
||||||
|
TEST_USER = os.environ["TEST_USER"]
|
||||||
|
TEST_PASS = os.environ["TEST_PASS"]
|
||||||
TESTUSER = {"username": "testuser", "name": "Test User", "password": "test123", "email": "test@example.com"}
|
|
||||||
|
|
||||||
|
|
||||||
def setup_admin_state(context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl):
|
def setup_admin_state(context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl):
|
||||||
|
|
@ -42,9 +41,12 @@ def check_if_user_exists(admin_context: BrowserContext, env_config: dict[str, st
|
||||||
nav.click()
|
nav.click()
|
||||||
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
|
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
|
||||||
|
|
||||||
user = page.get_by_text(TESTUSER["username"])
|
user = page.get_by_text(TEST_USER)
|
||||||
user.wait_for(state="visible")
|
try:
|
||||||
return user.is_visible()
|
user.wait_for(state="visible", timeout=5_000)
|
||||||
|
return True
|
||||||
|
except TimeoutError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def create_invite_link(admin_context: BrowserContext, env_config: dict[str, str], URL: BaseUrl):
|
def create_invite_link(admin_context: BrowserContext, env_config: dict[str, str], URL: BaseUrl):
|
||||||
|
|
@ -83,15 +85,16 @@ def create_user(user_context: BrowserContext, invitelink):
|
||||||
page = user_context.new_page()
|
page = user_context.new_page()
|
||||||
page.goto(invitelink)
|
page.goto(invitelink)
|
||||||
page.get_by_placeholder("Benutzername").click()
|
page.get_by_placeholder("Benutzername").click()
|
||||||
page.get_by_placeholder("Benutzername").fill(TESTUSER["username"])
|
page.get_by_placeholder("Benutzername").fill(TEST_USER)
|
||||||
page.locator('input[name="name"]').click()
|
page.locator('input[name="name"]').click()
|
||||||
page.locator('input[name="name"]').fill(TESTUSER["name"])
|
page.locator('input[name="name"]').fill("name")
|
||||||
page.locator('input[name="email"]').click()
|
page.locator('input[name="email"]').click()
|
||||||
page.locator('input[name="email"]').fill(TESTUSER["email"])
|
email = os.environ["IMAP_EMAIL"] if "IMAP_EMAIL" in os.environ else "test@domain.com"
|
||||||
|
page.locator('input[name="email"]').fill(email)
|
||||||
page.get_by_placeholder("Passwort", exact=True).click()
|
page.get_by_placeholder("Passwort", exact=True).click()
|
||||||
page.get_by_placeholder("Passwort", exact=True).fill(TESTUSER["password"])
|
page.get_by_placeholder("Passwort", exact=True).fill(TEST_PASS)
|
||||||
page.get_by_placeholder("Passwort (wiederholen)").click()
|
page.get_by_placeholder("Passwort (wiederholen)").click()
|
||||||
page.get_by_placeholder("Passwort (wiederholen)").fill(TESTUSER["password"])
|
page.get_by_placeholder("Passwort (wiederholen)").fill(TEST_PASS)
|
||||||
page.get_by_role("button", name="Weiter").click()
|
page.get_by_role("button", name="Weiter").click()
|
||||||
expect(page.locator("ak-library")).to_be_visible()
|
expect(page.locator("ak-library")).to_be_visible()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue