Skip to content

Commit 77fb7b3

Browse files
author
ibizaman
committed
add playwright test for grocy
1 parent 50cd401 commit 77fb7b3

File tree

5 files changed

+90
-21
lines changed

5 files changed

+90
-21
lines changed

flake.nix

+19
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@
4141
"dotnet-sdk-6.0.428"
4242
];
4343
};
44+
45+
overlays = [
46+
(final: prev: {
47+
exiftool = prev.exiftool.overrideAttrs (f: p: {
48+
version = "12.70";
49+
src = pkgs.fetchurl {
50+
url = "https://exiftool.org/Image-ExifTool-12.70.tar.gz";
51+
hash = "sha256-TLJSJEXMPj870TkExq6uraX8Wl4kmNerrSlX3LQsr/4=";
52+
};
53+
});
54+
})
55+
(final: prev: {
56+
grocy = prev.grocy.overrideAttrs (f: p: {
57+
patches = p.patches ++ [
58+
./patches/grocy.patch
59+
];
60+
});
61+
})
62+
];
4463
};
4564

4665
allModules = [

modules/services/grocy.nix

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ in
8686
};
8787

8888
config = lib.mkIf cfg.enable (lib.mkMerge [{
89-
9089
services.grocy = {
9190
enable = true;
9291
hostName = fqdn;

modules/services/nextcloud-server.nix

-12
Original file line numberDiff line numberDiff line change
@@ -1187,18 +1187,6 @@ in
11871187
path = [ pkgs.perl ];
11881188
};
11891189

1190-
nixpkgs.overlays = [
1191-
(final: prev: {
1192-
exiftool = prev.exiftool.overrideAttrs (f: p: {
1193-
version = "12.70";
1194-
src = pkgs.fetchurl {
1195-
url = "https://exiftool.org/Image-ExifTool-12.70.tar.gz";
1196-
hash = "sha256-TLJSJEXMPj870TkExq6uraX8Wl4kmNerrSlX3LQsr/4=";
1197-
};
1198-
});
1199-
})
1200-
];
1201-
12021190
services.nextcloud = {
12031191
# See all options at https://memories.gallery/system-config/
12041192
settings = {

patches/grocy.patch

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From b09d31578f4091c81ec2352bd334a007a093d6df Mon Sep 17 00:00:00 2001
2+
From: ibizaman <[email protected]>
3+
Date: Fri, 31 Jan 2025 20:52:40 +0100
4+
Subject: [PATCH] Make labels on login form point to correct inputs
5+
6+
---
7+
views/login.blade.php | 4 ++--
8+
1 file changed, 2 insertions(+), 2 deletions(-)
9+
10+
diff --git a/views/login.blade.php b/views/login.blade.php
11+
index 89538c3ea..ef708a657 100644
12+
--- a/views/login.blade.php
13+
+++ b/views/login.blade.php
14+
@@ -15,7 +15,7 @@
15+
novalidate>
16+
17+
<div class="form-group">
18+
- <label for="name">{{ $__t('Username') }}</label>
19+
+ <label for="username">{{ $__t('Username') }}</label>
20+
<input type="text"
21+
class="form-control"
22+
required
23+
@@ -24,7 +24,7 @@ class="form-control"
24+
</div>
25+
26+
<div class="form-group">
27+
- <label for="name">{{ $__t('Password') }}</label>
28+
+ <label for="password">{{ $__t('Password') }}</label>
29+
<input type="password"
30+
class="form-control"
31+
required

test/services/grocy.nix

+40-8
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ let
1111
waitForUnixSocket = { node, ... }: [
1212
node.config.services.phpfpm.pools.grocy.socket
1313
];
14-
# TODO: Test login
15-
# extraScript = { ... }: ''
16-
# '';
1714
};
1815

1916
basic = { config, ... }: {
17+
imports = [
18+
testLib.baseModule
19+
../../modules/services/grocy.nix
20+
];
21+
2022
test = {
2123
subdomain = "g";
2224
};
@@ -27,6 +29,35 @@ let
2729
};
2830
};
2931

32+
clientLogin = { config, ... }: {
33+
imports = [
34+
testLib.baseModule
35+
testLib.clientLoginModule
36+
];
37+
virtualisation.memorySize = 4096;
38+
39+
test = {
40+
subdomain = "g";
41+
};
42+
43+
test.login = {
44+
startUrl = "http://${config.test.fqdn}";
45+
usernameFieldLabelRegex = "Username";
46+
passwordFieldLabelRegex = "Password";
47+
loginButtonNameRegex = "OK";
48+
testLoginWith = [
49+
{ username = "admin"; password = "admin oops"; nextPageExpect = [
50+
"expect(page.get_by_text('Invalid credentials, please try again')).to_be_visible()"
51+
]; }
52+
{ username = "admin"; password = "admin"; nextPageExpect = [
53+
"expect(page.get_by_text('Invalid credentials, please try again')).not_to_be_visible()"
54+
"expect(page.get_by_role('button', name=re.compile('OK'))).not_to_be_visible()"
55+
"expect(page).to_have_title(re.compile('Grocy'))"
56+
]; }
57+
];
58+
};
59+
};
60+
3061
https = { config, ...}: {
3162
shb.grocy = {
3263
ssl = config.shb.certs.certs.selfsigned.n;
@@ -37,10 +68,13 @@ in
3768
basic = pkgs.testers.runNixOSTest {
3869
name = "grocy_basic";
3970

71+
nodes.client = {
72+
imports = [
73+
clientLogin
74+
];
75+
};
4076
nodes.server = {
4177
imports = [
42-
testLib.baseModule
43-
../../modules/services/grocy.nix
4478
basic
4579
];
4680
};
@@ -55,10 +89,8 @@ in
5589

5690
nodes.server = {
5791
imports = [
58-
testLib.baseModule
59-
../../modules/services/grocy.nix
60-
testLib.certs
6192
basic
93+
testLib.certs
6294
https
6395
];
6496
};

0 commit comments

Comments
 (0)