From 71651bdc0e5465a222d43e6cf16a9d3635e72404 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Fri, 31 Jan 2025 16:18:59 +0100 Subject: [PATCH] add start of playwright test for audiobookshelf --- test/common.nix | 6 ++-- test/services/audiobookshelf.nix | 51 +++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/test/common.nix b/test/common.nix index 4276166..2f2f750 100644 --- a/test/common.nix +++ b/test/common.nix @@ -155,15 +155,15 @@ in options.test.login = { usernameFieldLabelRegex = mkOption { type = str; - default = "username"; + default = "[Uu]sername"; }; passwordFieldLabelRegex = mkOption { type = str; - default = "password"; + default = "[Pp]assword"; }; loginButtonNameRegex = mkOption { type = str; - default = "login"; + default = "[Ll]ogin"; }; testLoginWith = mkOption { type = listOf (submodule { diff --git a/test/services/audiobookshelf.nix b/test/services/audiobookshelf.nix index 6ee0624..b1baaca 100644 --- a/test/services/audiobookshelf.nix +++ b/test/services/audiobookshelf.nix @@ -17,6 +17,11 @@ let }; basic = { config, ... }: { + imports = [ + testLib.baseModule + ../../modules/services/audiobookshelf.nix + ]; + test = { 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, ... }: { shb.audiobookshelf = { ssl = config.shb.certs.certs.selfsigned.n; @@ -48,10 +83,14 @@ in basic = pkgs.testers.runNixOSTest { name = "audiobookshelf-basic"; + nodes.client = { + imports = [ + # TODO: enable this when declarative user management is possible. + # clientLogin + ]; + }; nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/audiobookshelf.nix basic ]; }; @@ -66,10 +105,8 @@ in nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/audiobookshelf.nix - testLib.certs basic + testLib.certs https ]; }; @@ -84,10 +121,8 @@ in nodes.server = { config, ... }: { imports = [ - testLib.baseModule - ../../modules/services/audiobookshelf.nix - testLib.certs basic + testLib.certs https testLib.ldap (testLib.sso config.shb.certs.certs.selfsigned.n)