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