test: add beforeHook option

This commit is contained in:
ibizaman 2025-08-22 23:10:17 +02:00
parent 04cd072cd7
commit b02ec03f19
2 changed files with 11 additions and 0 deletions

View file

@ -254,6 +254,10 @@ in
type = str; type = str;
default = "http://${config.test.fqdn}"; default = "http://${config.test.fqdn}";
}; };
beforeHook = mkOption {
type = str;
default = "";
};
}; };
config = { config = {
networking.hosts = { networking.hosts = {
@ -307,6 +311,9 @@ in
print(f"Going to {testCfg['startUrl']}") print(f"Going to {testCfg['startUrl']}")
page.goto(testCfg['startUrl']) page.goto(testCfg['startUrl'])
if testCfg.get("beforeHook") is not None:
exec(testCfg.get("beforeHook"))
if u['username'] is not None: if u['username'] is not None:
print(f"Filling field username with {u['username']}") print(f"Filling field username with {u['username']}")
page.${cfg.usernameFieldSelector}.fill(u['username']) page.${cfg.usernameFieldSelector}.fill(u['username'])

View file

@ -205,6 +205,10 @@ let
test.login = { test.login = {
startUrl = "http://${config.test.fqdn}"; startUrl = "http://${config.test.fqdn}";
# No need since Nextcloud is auto-redirecting to the SSO sign in page.
# beforeHook = ''
# page.get_by_role("link", name="Sign in with SHB-Authelia").click()
# '';
usernameFieldLabelRegex = "Username"; usernameFieldLabelRegex = "Username";
passwordFieldSelector = "get_by_label(\"Password *\")"; passwordFieldSelector = "get_by_label(\"Password *\")";
loginButtonNameRegex = "[sS]ign [iI]n"; loginButtonNameRegex = "[sS]ign [iI]n";