add start of playwright test for audiobookshelf

This commit is contained in:
ibizaman 2025-01-31 16:18:59 +01:00
parent 6c9f0e50f7
commit e03f5515cb
2 changed files with 46 additions and 11 deletions

View file

@ -155,15 +155,15 @@ in
options.test.login = { options.test.login = {
usernameFieldLabelRegex = mkOption { usernameFieldLabelRegex = mkOption {
type = str; type = str;
default = "username"; default = "[Uu]sername";
}; };
passwordFieldLabelRegex = mkOption { passwordFieldLabelRegex = mkOption {
type = str; type = str;
default = "password"; default = "[Pp]assword";
}; };
loginButtonNameRegex = mkOption { loginButtonNameRegex = mkOption {
type = str; type = str;
default = "login"; default = "[Ll]ogin";
}; };
testLoginWith = mkOption { testLoginWith = mkOption {
type = listOf (submodule { type = listOf (submodule {

View file

@ -17,6 +17,11 @@ let
}; };
basic = { config, ... }: { basic = { config, ... }: {
imports = [
testLib.baseModule
../../modules/services/audiobookshelf.nix
];
test = { test = {
subdomain = "a"; subdomain = "a";
}; };
@ -26,6 +31,36 @@ let
}; };
}; };
clientLogin = { config, ... }: {
imports = [
testLib.baseModule
testLib.clientLoginModule
];
virtualisation.memorySize = 4096;
test = {
subdomain = "a";
};
test.login = {
startUrl = "http://${config.test.fqdn}";
usernameFieldLabelRegex = "[Uu]sername";
passwordFieldLabelRegex = "[Pp]assword";
loginButtonNameRegex = "[Ll]og [Ii]n";
testLoginWith = [
# Failure is after so we're not throttled too much.
{ username = "root"; password = "rootpw"; nextPageExpect = [
"expect(page.get_by_text('Wrong username or password')).to_be_visible()"
]; }
# { username = adminUser; password = adminPass; nextPageExpect = [
# "expect(page.get_by_text('Wrong username or password')).not_to_be_visible()"
# "expect(page.get_by_role('button', name=re.compile('[Ll]og [Ii]n'))).not_to_be_visible()"
# "expect(page).to_have_title(re.compile('Dashboard'))"
# ]; }
];
};
};
https = { config, ... }: { https = { config, ... }: {
shb.audiobookshelf = { shb.audiobookshelf = {
ssl = config.shb.certs.certs.selfsigned.n; ssl = config.shb.certs.certs.selfsigned.n;
@ -48,10 +83,14 @@ in
basic = pkgs.testers.runNixOSTest { basic = pkgs.testers.runNixOSTest {
name = "audiobookshelf-basic"; name = "audiobookshelf-basic";
nodes.client = {
imports = [
# TODO: enable this when declarative user management is possible.
# clientLogin
];
};
nodes.server = { nodes.server = {
imports = [ imports = [
testLib.baseModule
../../modules/services/audiobookshelf.nix
basic basic
]; ];
}; };
@ -66,10 +105,8 @@ in
nodes.server = { nodes.server = {
imports = [ imports = [
testLib.baseModule
../../modules/services/audiobookshelf.nix
testLib.certs
basic basic
testLib.certs
https https
]; ];
}; };
@ -84,10 +121,8 @@ in
nodes.server = { config, ... }: { nodes.server = { config, ... }: {
imports = [ imports = [
testLib.baseModule
../../modules/services/audiobookshelf.nix
testLib.certs
basic basic
testLib.certs
https https
testLib.ldap testLib.ldap
(testLib.sso config.shb.certs.certs.selfsigned.n) (testLib.sso config.shb.certs.certs.selfsigned.n)