Skip to content

Commit

Permalink
add playwright test for arr services
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored and ibizaman committed Jan 31, 2025
1 parent c280b57 commit 6c9f0e5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
6 changes: 4 additions & 2 deletions test/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ in
print(f"Filling field {testCfg['passwordFieldLabelRegex']} with {u['password']}")
page.get_by_label(re.compile(testCfg['passwordFieldLabelRegex'])).fill(u['password'])
print(f"Clicking button {testCfg['loginButtonNameRegex']}")
page.get_by_role("button", name=re.compile(testCfg['loginButtonNameRegex'])).click()
# Assumes we don't need to login, so skip this.
if u['username'] is not None or u['password'] is not None:
print(f"Clicking button {testCfg['loginButtonNameRegex']}")
page.get_by_role("button", name=re.compile(testCfg['loginButtonNameRegex'])).click()
for line in u['nextPageExpect']:
print(f"Running: {line}")
Expand Down
47 changes: 36 additions & 11 deletions test/services/arr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ let
};

basic = appname: { config, ... }: {
imports = [
testLib.baseModule
../../modules/services/arr.nix
];

test = {
subdomain = appname;
};
Expand All @@ -55,13 +60,39 @@ let
};
};

clientLogin = appname: { config, ... }: {
imports = [
testLib.baseModule
testLib.clientLoginModule
];

test = {
subdomain = appname;
};

test.login = {
startUrl = "http://${config.test.fqdn}";
usernameFieldLabelRegex = "[Uu]sername";
passwordFieldLabelRegex = "^ *[Pp]assword";
loginButtonNameRegex = "[Ll]og [Ii]n";
testLoginWith = [
{ nextPageExpect = [
"expect(page).to_have_title(re.compile('${appname}', re.IGNORECASE))"
]; }
];
};
};

basicTest = appname: cfgPathFn: pkgs.testers.runNixOSTest {
name = "arr_${appname}_basic";

nodes.server = { config, pkgs, ... }: {
nodes.client = {
imports = [
(clientLogin appname)
];
};
nodes.server = {
imports = [
testLib.baseModule
../../modules/services/arr.nix
(basic appname)
];
};
Expand All @@ -76,8 +107,6 @@ let

nodes.server = { config, ... }: {
imports = [
testLib.baseModule
../../modules/services/arr.nix
(basic appname)
(testLib.backup config.shb.arr.${appname}.backup)
];
Expand All @@ -99,10 +128,8 @@ let

nodes.server = { config, pkgs, ... }: {
imports = [
testLib.baseModule
../../modules/services/arr.nix
testLib.certs
(basic appname)
testLib.certs
(https appname)
];
};
Expand All @@ -123,10 +150,8 @@ let

nodes.server = { config, pkgs, ... }: {
imports = [
testLib.baseModule
../../modules/services/arr.nix
testLib.certs
(basic appname)
testLib.certs
(https appname)
testLib.ldap
(testLib.sso config.shb.certs.certs.selfsigned.n)
Expand Down

0 comments on commit 6c9f0e5

Please sign in to comment.