From 83d8474f17788ccedff876bcdbf47665f37918bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Tue, 17 Sep 2024 12:00:29 +0200 Subject: [PATCH] Some fixes to the Pixelfed/Garage test --- garage.nix | 2 +- tests/pixelfed-garage.nix | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/garage.nix b/garage.nix index b58738d..478443d 100644 --- a/garage.nix +++ b/garage.nix @@ -175,7 +175,7 @@ in { # Give garage time to start up by waiting until somethings speaks HTTP # behind localhost:3900. - until curl -sio /dev/null http://localhost:3900/; do sleep 1; done + until ${pkgs.curl}/bin/curl -sio /dev/null http://localhost:3900/; do sleep 1; done # XXX: this is very sensitive to being a single instance # (doing the bare minimum to get garage up and running) diff --git a/tests/pixelfed-garage.nix b/tests/pixelfed-garage.nix index e084cb0..a08a312 100644 --- a/tests/pixelfed-garage.nix +++ b/tests/pixelfed-garage.nix @@ -29,15 +29,16 @@ let print("Open login page...", file=sys.stderr) driver.get("http://pixelfed.localhost/login") print("Enter email...", file=sys.stderr) - driver.find_element(By.ID, "email").send_keys(${email}) + driver.find_element(By.ID, "email").send_keys("${email}") print("Enter password...", file=sys.stderr) - driver.find_element(By.ID, "password").send_keys(${password}) + driver.find_element(By.ID, "password").send_keys("${password}") # FIXME: This is disgusting. Find instead the input type submit in the form # with action ending in "/login". print("Click “Login” button...", file=sys.stderr) driver.find_element(By.XPATH, "//button[normalize-space()='Login']").click() ''; + ## NOTE: `path` must be a valid python string, either a variable or _quoted_. seleniumTakeScreenshot = path: '' print("Take screenshot...", file=sys.stderr) if not driver.save_screenshot(${path}): @@ -172,7 +173,7 @@ pkgs.nixosTest { server.wait_for_unit("phpfpm-pixelfed.service") with subtest("Account creation"): - server.succeed(f"pixelfed-manage user:create --name=test --username=test --email=${email} --password=${password} --confirm_email=1") + server.succeed("pixelfed-manage user:create --name=test --username=test --email=${email} --password=${password} --confirm_email=1") # NOTE: This could in theory give a false positive if pixelfed changes it's # colorscheme to include pure green. (see same problem in pixelfed-garage.nix). @@ -180,7 +181,7 @@ pkgs.nixosTest { # there, then post a green image and check that the green pixel IS there. with subtest("Image displays"): - server.succeed(f"su - selenium -c 'selenium-script-post-picture ${email} ${password}'") + server.succeed("su - selenium -c 'selenium-script-post-picture ${email} ${password}'") server.copy_from_vm("/home/selenium/screenshot.png", "") displayed_colors = server.succeed("magick /home/selenium/screenshot.png -define histogram:unique-colors=true -format %c histogram:info:") # check that the green image displayed somewhere @@ -193,7 +194,7 @@ pkgs.nixosTest { server.succeed("mc ls garage/pixelfed") with subtest("access image in garage"): - image = server.succeed("mc find garage --regex '\.png' --ignore '*_thumb.png'") + image = server.succeed("mc find garage --regex '\\.png' --ignore '*_thumb.png'") image = image.rstrip() if image == "": raise Exception("image posted to mastodon did not get stored in garage") @@ -204,7 +205,7 @@ pkgs.nixosTest { raise Exception("image stored in garage did not match image uploaded") with subtest("Check that image comes from garage"): - src = server.succeed(f"su - selenium -c 'selenium-script-get-src ${email} ${password}'") + src = server.succeed("su - selenium -c 'selenium-script-get-src ${email} ${password}'") if not src.startswith("http://pixelfed.web.garage.localhost:3902/"): raise Exception("image does not come from garage") '';