Skip to content

Commit 8da3d97

Browse files
author
ibizaman
committed
add playwright test for arr services
1 parent c280b57 commit 8da3d97

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

test/common.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,10 @@ in
248248
print(f"Filling field {testCfg['passwordFieldLabelRegex']} with {u['password']}")
249249
page.get_by_label(re.compile(testCfg['passwordFieldLabelRegex'])).fill(u['password'])
250250
251-
print(f"Clicking button {testCfg['loginButtonNameRegex']}")
252-
page.get_by_role("button", name=re.compile(testCfg['loginButtonNameRegex'])).click()
251+
# Assumes we don't need to login, so skip this.
252+
if u['username'] is not None and u['password'] is not None:
253+
print(f"Clicking button {testCfg['loginButtonNameRegex']}")
254+
page.get_by_role("button", name=re.compile(testCfg['loginButtonNameRegex'])).click()
253255
254256
for line in u['nextPageExpect']:
255257
print(f"Running: {line}")

test/services/arr.nix

+36-11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ let
4343
};
4444

4545
basic = appname: { config, ... }: {
46+
imports = [
47+
testLib.baseModule
48+
../../modules/services/arr.nix
49+
];
50+
4651
test = {
4752
subdomain = appname;
4853
};
@@ -55,13 +60,39 @@ let
5560
};
5661
};
5762

63+
clientLogin = appname: { config, ... }: {
64+
imports = [
65+
testLib.baseModule
66+
testLib.clientLoginModule
67+
];
68+
69+
test = {
70+
subdomain = appname;
71+
};
72+
73+
test.login = {
74+
startUrl = "http://${config.test.fqdn}";
75+
usernameFieldLabelRegex = "[Uu]sername";
76+
passwordFieldLabelRegex = "^ *[Pp]assword";
77+
loginButtonNameRegex = "[Ll]og [Ii]n";
78+
testLoginWith = [
79+
{ nextPageExpect = [
80+
"expect(page).to_have_title(re.compile('${appname}', re.IGNORECASE))"
81+
]; }
82+
];
83+
};
84+
};
85+
5886
basicTest = appname: cfgPathFn: pkgs.testers.runNixOSTest {
5987
name = "arr_${appname}_basic";
6088

61-
nodes.server = { config, pkgs, ... }: {
89+
nodes.client = {
90+
imports = [
91+
(clientLogin appname)
92+
];
93+
};
94+
nodes.server = {
6295
imports = [
63-
testLib.baseModule
64-
../../modules/services/arr.nix
6596
(basic appname)
6697
];
6798
};
@@ -76,8 +107,6 @@ let
76107

77108
nodes.server = { config, ... }: {
78109
imports = [
79-
testLib.baseModule
80-
../../modules/services/arr.nix
81110
(basic appname)
82111
(testLib.backup config.shb.arr.${appname}.backup)
83112
];
@@ -99,10 +128,8 @@ let
99128

100129
nodes.server = { config, pkgs, ... }: {
101130
imports = [
102-
testLib.baseModule
103-
../../modules/services/arr.nix
104-
testLib.certs
105131
(basic appname)
132+
testLib.certs
106133
(https appname)
107134
];
108135
};
@@ -123,10 +150,8 @@ let
123150

124151
nodes.server = { config, pkgs, ... }: {
125152
imports = [
126-
testLib.baseModule
127-
../../modules/services/arr.nix
128-
testLib.certs
129153
(basic appname)
154+
testLib.certs
130155
(https appname)
131156
testLib.ldap
132157
(testLib.sso config.shb.certs.certs.selfsigned.n)

0 commit comments

Comments
 (0)