turn check_if_user_exists into a fixture
This commit is contained in:
parent
6be9fdc535
commit
359a18eae5
2 changed files with 35 additions and 22 deletions
|
|
@ -2,7 +2,7 @@ import json
|
|||
import os
|
||||
import re
|
||||
|
||||
from playwright.sync_api import BrowserContext, TimeoutError, expect
|
||||
from playwright.sync_api import BrowserContext, expect
|
||||
|
||||
from pytest_abra import BaseUrl, DirManager
|
||||
|
||||
|
|
@ -32,23 +32,6 @@ def setup_admin_state(context: BrowserContext, env_config: dict[str, str], DIR:
|
|||
context.storage_state(path=DIR.STATES / "authentik_admin_state.json")
|
||||
|
||||
|
||||
def check_if_user_exists(admin_context: BrowserContext, env_config: dict[str, str], URL: BaseUrl):
|
||||
# go to admin page
|
||||
page = admin_context.new_page()
|
||||
page.goto(URL.get())
|
||||
page.get_by_role("link", name="Admin Interface").click()
|
||||
nav = page.locator("ak-sidebar-item", has_text=re.compile(r"Directory|Verzeichnis"))
|
||||
nav.click()
|
||||
nav.get_by_role("link", name=re.compile(r"Users|Benutzer")).click()
|
||||
|
||||
user = page.get_by_text(TEST_USER)
|
||||
try:
|
||||
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):
|
||||
# go to admin page
|
||||
page = admin_context.new_page()
|
||||
|
|
@ -99,7 +82,9 @@ def create_user(user_context: BrowserContext, invitelink):
|
|||
expect(page.locator("ak-library")).to_be_visible()
|
||||
|
||||
|
||||
def setup_user_state(context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl):
|
||||
def setup_user_state(
|
||||
context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl, check_if_user_exists
|
||||
):
|
||||
# load admin cookies to context
|
||||
state_file = DIR.STATES / "authentik_admin_state.json"
|
||||
storage_state = json.loads(state_file.read_bytes())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue