cleanup (#18)
- remove demo runner - improve docs - rename all tests to test_* (previously, also setup_* and cleanup_* existed) to improve stability as it is not guaranteed that pytest.ini is loaded. - improve logging formatting - improve full integration test Reviewed-on: local-it-infrastructure/e2e_tests#18 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
8b9dd47f9e
commit
0fafa22272
18 changed files with 58 additions and 81 deletions
|
|
@ -27,7 +27,7 @@ def remove_user(admin_context: BrowserContext, URL: BaseUrl):
|
|||
page.get_by_role("dialog").get_by_role("button", name=re.compile(r"Löschen|Delete")).click()
|
||||
|
||||
|
||||
def cleanup_delete_user(
|
||||
def test_cleanup_delete_user(
|
||||
context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl, check_if_user_exists
|
||||
):
|
||||
# load admin cookies to context
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ TEST_USER = os.environ["TEST_USER"]
|
|||
TEST_PASS = os.environ["TEST_PASS"]
|
||||
|
||||
|
||||
def setup_admin_state(context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl):
|
||||
def test_setup_admin_state(context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl):
|
||||
# go to page
|
||||
page = context.new_page()
|
||||
page.goto(URL.get())
|
||||
|
|
@ -50,7 +50,8 @@ def create_invite_link(admin_context: BrowserContext, env_config: dict[str, str]
|
|||
page.locator('input[name="name"]').click()
|
||||
linkname = "test_link_123"
|
||||
page.locator('input[name="name"]').fill(linkname)
|
||||
page.get_by_placeholder("Wählen Sie ein Objekt aus.").click()
|
||||
placeholder_pattern = re.compile(r"Wählen Sie ein|Select an")
|
||||
page.get_by_placeholder(placeholder_pattern).click()
|
||||
page.get_by_role("option", name=re.compile(r"invitation-enrollment-flow")).click()
|
||||
|
||||
# force, because else we get "intercepts pointer events"
|
||||
|
|
@ -82,7 +83,7 @@ def create_user(user_context: BrowserContext, invitelink):
|
|||
expect(page.locator("ak-library")).to_be_visible()
|
||||
|
||||
|
||||
def setup_user_state(
|
||||
def test_setup_user_state(
|
||||
context: BrowserContext, env_config: dict[str, str], DIR: DirManager, URL: BaseUrl, check_if_user_exists
|
||||
):
|
||||
# load admin cookies to context
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
"""
|
||||
This file can be used to define fixtures thate are then used by other tests which
|
||||
depend on [demo]. For this to work
|
||||
|
||||
1. the Runner class of the other test needs to define the depencency as seen
|
||||
by referencing RunnerDemo in the dependencies list:
|
||||
|
||||
from pytest_abra.tests_demo.runner_demo import RunnerDemo
|
||||
|
||||
class RunnerOther(Runner):
|
||||
dependencies = [RunnerDemo]
|
||||
|
||||
|
||||
2. the specific tests that rely on these fixtures need to import the fixtures.
|
||||
To globally import for all tests in 'other', the import should be done in conftest:
|
||||
|
||||
in 'conftest.py' in 'test_other' dir:
|
||||
from pytest_abra.tests_demo.fixtures_demo import demo_fixture
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def demo_fixture():
|
||||
return ""
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
from pytest_abra.runner import Runner, Test
|
||||
|
||||
|
||||
class RunnerDemo(Runner):
|
||||
"""Every env file has a corresponding runner class"""
|
||||
|
||||
env_type = "demo" # name of the test, used for logging / output naming
|
||||
|
||||
# this indicates that tests from RunnerDemo depend on the setup from RunnerAuthentik.
|
||||
# RunnerDemo will only execute, when setup_authentik.py has finished successfully.
|
||||
# For example, setup_authentik.py generates session states, that can be used as fixtures
|
||||
# that can be loaded from fixtures_authentik.py
|
||||
dependencies: list[str] = ["authentik"]
|
||||
|
||||
# todo: update these comments
|
||||
# Filename of Demo setup. If defined, it will run 1st by executing pytest
|
||||
# Filename of Demo test. This file contains unconditional tests that will be run in any
|
||||
# case. If defined, it will run 2nd by executing pytest
|
||||
# this list can hold many more tests from RunnerDemo that run conditional. The condition
|
||||
# and the test file can be defined by creating a ConditionalTest instance:
|
||||
# ConditionalTest(condition: Callable, test_file: str)
|
||||
setups: list[Test] = []
|
||||
tests: list[Test] = []
|
||||
cleanups: list[Test] = []
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Define functions here that are specifically meant for setup, not for testing. This means
|
||||
# all actions that simply are required for other tests from 'demo' to run. Runs before all
|
||||
# tests from 'demo'.
|
||||
|
|
@ -6,7 +6,7 @@ class RunnerNextcloud(Runner):
|
|||
dependencies = ["authentik"]
|
||||
setups = [Test(test_file="setup_nextcloud.py", prevent_skip=False)]
|
||||
tests = [
|
||||
Test(test_file="tests_nextcloud.py", prevent_skip=True),
|
||||
Test(test_file="tests_nextcloud.py"),
|
||||
# Test(condition=condition_always_false, test_file="tests_nextcloud_onlyoffice.py"),
|
||||
]
|
||||
# cleanups = [Test(test_file="cleanup_nextcloud.py")]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from pytest_abra import BaseUrl, DirManager
|
|||
# https://files.test.dev.local-it.cloud/apps/files/
|
||||
|
||||
|
||||
def setup_nextcloud_admin_session(authentik_admin_page: Page, DIR: DirManager, URL: BaseUrl):
|
||||
def test_setup_nextcloud_admin_session(authentik_admin_page: Page, DIR: DirManager, URL: BaseUrl):
|
||||
"""visit nextcloud from authentik with admin_session to create wordpress_admin_session"""
|
||||
with authentik_admin_page.expect_popup() as event_context:
|
||||
authentik_admin_page.get_by_role("link", name="Nextcloud").click()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def test_visit_from_domain(authentik_admin_context: BrowserContext, URL: BaseUrl
|
|||
expect(page.locator("#wpadminbar")).to_be_visible(timeout=3_000)
|
||||
|
||||
|
||||
def setup_wordpress_admin_session(authentik_admin_page: Page, DIR: DirManager):
|
||||
def test_setup_wordpress_admin_session(authentik_admin_page: Page, DIR: DirManager):
|
||||
"""visit wordpress from authentik with admin_session to create wordpress_admin_session"""
|
||||
with authentik_admin_page.expect_popup() as event_context:
|
||||
authentik_admin_page.get_by_role("link", name="Wordpress").click()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from playwright.sync_api import Page, expect
|
|||
from pytest_abra import BaseUrl
|
||||
|
||||
|
||||
def setup_trigger_email(wordpress_admin_page: Page, URL: BaseUrl):
|
||||
def test_setup_trigger_email(wordpress_admin_page: Page, URL: BaseUrl):
|
||||
"""change profile email to EMAIL to trigger email"""
|
||||
page = wordpress_admin_page
|
||||
page.goto(URL.get("wp-admin/profile.php"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue