1{ lib, pkgs, ... }:
2
3{
4 name = "qownnotes";
5 meta.maintainers = [ lib.maintainers.pbek ];
6
7 nodes.machine =
8 { ... }:
9
10 {
11 imports = [
12 ./common/user-account.nix
13 ./common/x11.nix
14 ];
15
16 test-support.displayManager.auto.user = "alice";
17 environment.systemPackages = [
18 pkgs.qownnotes
19 pkgs.xdotool
20 ];
21 };
22
23 enableOCR = true;
24
25 # https://nixos.org/manual/nixos/stable/#ssec-machine-objects
26 testScript =
27 { nodes, ... }:
28 let
29 aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
30 in
31 ''
32 with subtest("Ensure X starts"):
33 start_all()
34 machine.wait_for_x()
35
36 with subtest("Check QOwnNotes version on CLI"):
37 ${aliceDo "qownnotes --version"}
38
39 machine.wait_for_console_text("QOwnNotes ${pkgs.qownnotes.version}")
40
41 with subtest("Ensure QOwnNotes starts"):
42 # start QOwnNotes window
43 ${aliceDo "qownnotes"}
44
45 machine.wait_for_text("Welcome to QOwnNotes")
46 machine.screenshot("QOwnNotes-Welcome")
47
48 with subtest("Finish first-run wizard"):
49 # The wizard should show up now
50 machine.wait_for_text("Note folder")
51 machine.send_key("ret")
52 machine.wait_for_console_text("Note path '/home/alice/Notes' was now created.")
53 machine.wait_for_text("Panel layout")
54 machine.send_key("ret")
55 machine.wait_for_text("Nextcloud")
56 machine.send_key("ret")
57
58 # OCR can't detect "App metric" anymore, so we will wait for another text
59 machine.wait_for_text("Open network settings")
60 machine.send_key("ret")
61
62 # Doesn't work for non-root
63 #machine.wait_for_window("QOwnNotes - ${pkgs.qownnotes.version}")
64
65 # OCR doesn't seem to be able any more to handle the main window
66 #machine.wait_for_text("QOwnNotes - ${pkgs.qownnotes.version}")
67
68 # The main window should now show up
69 machine.wait_for_open_port(22222)
70 machine.wait_for_console_text("QOwnNotes server listening on port 22222")
71
72 machine.screenshot("QOwnNotes-DemoNote")
73
74 with subtest("Create a new note"):
75 machine.send_key("ctrl-n")
76 machine.sleep(1)
77 machine.send_chars("This is a NixOS test!\n")
78 machine.wait_until_succeeds("find /home/alice/Notes -type f | grep -qi 'Note 2'")
79
80 # OCR doesn't seem to be able any more to handle the main window
81 #machine.wait_for_text("This is a NixOS test!")
82
83 # Doesn't work for non-root
84 #machine.wait_for_window("- QOwnNotes - ${pkgs.qownnotes.version}")
85
86 machine.screenshot("QOwnNotes-NewNote")
87 '';
88}