Skip to content

Commit

Permalink
add playwright test for grocy
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored and ibizaman committed Jan 31, 2025
1 parent 3473117 commit 82426a4
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build
run: |
nix build --print-build-logs --show-trace .#checks.x86_64-linux.${{ matrix.check }}
nix build --print-build-logs --show-trace --keep-outputs --keep-failed .#checks.x86_64-linux.${{ matrix.check }}
echo "resultPath=$(nix eval .#checks.x86_64-linux.vm_grocy_basic --raw)" >> $GITHUB_ENV
- name: Upload Build Result
uses: actions/upload-artifact@v4
Expand Down
19 changes: 19 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@
"dotnet-sdk-6.0.428"
];
};

overlays = [
(final: prev: {
exiftool = prev.exiftool.overrideAttrs (f: p: {
version = "12.70";
src = pkgs.fetchurl {
url = "https://exiftool.org/Image-ExifTool-12.70.tar.gz";
hash = "sha256-TLJSJEXMPj870TkExq6uraX8Wl4kmNerrSlX3LQsr/4=";
};
});
})
(final: prev: {
grocy = prev.grocy.overrideAttrs (f: p: {
patches = p.patches ++ [
./patches/grocy.patch
];
});
})
];
};

allModules = [
Expand Down
1 change: 0 additions & 1 deletion modules/services/grocy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ in
};

config = lib.mkIf cfg.enable (lib.mkMerge [{

services.grocy = {
enable = true;
hostName = fqdn;
Expand Down
12 changes: 0 additions & 12 deletions modules/services/nextcloud-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1187,18 +1187,6 @@ in
path = [ pkgs.perl ];
};

nixpkgs.overlays = [
(final: prev: {
exiftool = prev.exiftool.overrideAttrs (f: p: {
version = "12.70";
src = pkgs.fetchurl {
url = "https://exiftool.org/Image-ExifTool-12.70.tar.gz";
hash = "sha256-TLJSJEXMPj870TkExq6uraX8Wl4kmNerrSlX3LQsr/4=";
};
});
})
];

services.nextcloud = {
# See all options at https://memories.gallery/system-config/
settings = {
Expand Down
31 changes: 31 additions & 0 deletions patches/grocy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From b09d31578f4091c81ec2352bd334a007a093d6df Mon Sep 17 00:00:00 2001
From: ibizaman <[email protected]>
Date: Fri, 31 Jan 2025 20:52:40 +0100
Subject: [PATCH] Make labels on login form point to correct inputs

---
views/login.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/views/login.blade.php b/views/login.blade.php
index 89538c3ea..ef708a657 100644
--- a/views/login.blade.php
+++ b/views/login.blade.php
@@ -15,7 +15,7 @@
novalidate>

<div class="form-group">
- <label for="name">{{ $__t('Username') }}</label>
+ <label for="username">{{ $__t('Username') }}</label>
<input type="text"
class="form-control"
required
@@ -24,7 +24,7 @@ class="form-control"
</div>

<div class="form-group">
- <label for="name">{{ $__t('Password') }}</label>
+ <label for="password">{{ $__t('Password') }}</label>
<input type="password"
class="form-control"
required
48 changes: 40 additions & 8 deletions test/services/grocy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ let
waitForUnixSocket = { node, ... }: [
node.config.services.phpfpm.pools.grocy.socket
];
# TODO: Test login
# extraScript = { ... }: ''
# '';
};

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

test = {
subdomain = "g";
};
Expand All @@ -27,6 +29,35 @@ let
};
};

clientLogin = { config, ... }: {
imports = [
testLib.baseModule
testLib.clientLoginModule
];
virtualisation.memorySize = 4096;

test = {
subdomain = "g";
};

test.login = {
startUrl = "http://${config.test.fqdn}";
usernameFieldLabelRegex = "Username";
passwordFieldLabelRegex = "Password";
loginButtonNameRegex = "OK";
testLoginWith = [
{ username = "admin"; password = "admin oops"; nextPageExpect = [
"expect(page.get_by_text('Invalid credentials, please try again')).to_be_visible()"
]; }
{ username = "admin"; password = "admin"; nextPageExpect = [
"expect(page.get_by_text('Invalid credentials, please try again')).not_to_be_visible()"
"expect(page.get_by_role('button', name=re.compile('OK'))).not_to_be_visible()"
"expect(page).to_have_title(re.compile('Grocy'))"
]; }
];
};
};

https = { config, ...}: {
shb.grocy = {
ssl = config.shb.certs.certs.selfsigned.n;
Expand All @@ -37,10 +68,13 @@ in
basic = pkgs.testers.runNixOSTest {
name = "grocy_basic";

nodes.client = {
imports = [
clientLogin
];
};
nodes.server = {
imports = [
testLib.baseModule
../../modules/services/grocy.nix
basic
];
};
Expand All @@ -55,10 +89,8 @@ in

nodes.server = {
imports = [
testLib.baseModule
../../modules/services/grocy.nix
testLib.certs
basic
testLib.certs
https
];
};
Expand Down

0 comments on commit 82426a4

Please sign in to comment.