authentik setup and tracing (#2)

* authentik sessions created successfully during setup without breaking tracing

* setup works on EN and DE localization by using regex patterns

* automated tracing with pytest --trace option, manual hook no longer needed

Reviewed-on: local-it-infrastructure/e2e_tests#2
Co-authored-by: Daniel <d.brummerloh@gmail.com>
Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
Daniel 2023-11-27 17:01:45 +01:00 committed by dan
parent 97ed87c79f
commit d2cd6ba47f
22 changed files with 519 additions and 304 deletions

View file

@ -1,28 +1 @@
# this conftest cannot be executed directly if there is a second conftest
# on a higher level. might work if other tests are executed though
# -> at least bad for debugging
import json
from pathlib import Path
import pytest
from playwright.sync_api import Browser, Locator, expect, sync_playwright
# playwright = sync_playwright().start()
# browser = playwright.chromium.launch(headless=False)
cred_file = Path("../credentials.json")
with open(cred_file, "r") as f:
CREDENTIALS = json.load(f)
print(CREDENTIALS)
RECORDS = Path("records")
RECORDS.mkdir(exist_ok=True)
STATES = Path("states")
STATES.mkdir(exist_ok=True)
def test_dummy():
assert 1 + 1 == 2
from src.tests_authentik.fixtures_authentik import admin_session, user_session

View file

@ -1,6 +1,6 @@
from pathlib import Path
from runner import Runner, SubTest
from src.runner import Runner, SubTest
def condition_always_true(dotenv_path: Path) -> bool:
@ -12,9 +12,10 @@ def condition_always_false(dotenv_path: Path) -> bool:
class RunnerWordpress(Runner):
name = "wordpress"
test_dir_name = "tests_wordpress"
# main_test_name = "test_wordpress.py"
sub_tests = [
SubTest(condition=condition_always_false, test_file="test_wordpress_feature1.py"),
SubTest(condition=condition_always_true, test_file="conftest.py"),
SubTest(condition=condition_always_true, test_file="test_wordpress_feature1.py"),
]
dependencies: list[str] = ["authentik"]

View file

@ -1,26 +1,31 @@
import re
from icecream import ic
from playwright.sync_api import Page, expect
from playwright.sync_api import BrowserContext, Page, expect
def test_one(config):
ic(config)
def test_demo(admin_session: BrowserContext):
admin_session.new_page()
assert 1 + 1 == 2
def test_has_title(page: Page):
page.goto("https://playwright.dev/")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
# def test_one(config):
# ic(config)
# assert 1 + 1 == 2
def test_get_started_link(page: Page):
page.goto("https://playwright.dev/")
# def test_has_title(page: Page):
# page.goto("https://playwright.dev/")
# Click the get started link.
page.get_by_role("link", name="Get started").click()
# # Expect a title "to contain" a substring.
# expect(page).to_have_title(re.compile("Playwright"))
# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()
# def test_get_started_link(page: Page):
# page.goto("https://playwright.dev/")
# # Click the get started link.
# page.get_by_role("link", name="Get started").click()
# # Expects page to have a heading with the name of Installation.
# expect(page.get_by_role("heading", name="Installation")).to_be_visible()