forked from Fediversity/simple-nixos-fediverse
Some fixes to the Pixelfed/Garage test
This commit is contained in:
parent
bc47154895
commit
83d8474f17
|
@ -175,7 +175,7 @@ in {
|
||||||
|
|
||||||
# Give garage time to start up by waiting until somethings speaks HTTP
|
# Give garage time to start up by waiting until somethings speaks HTTP
|
||||||
# behind localhost:3900.
|
# 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
|
# XXX: this is very sensitive to being a single instance
|
||||||
# (doing the bare minimum to get garage up and running)
|
# (doing the bare minimum to get garage up and running)
|
||||||
|
|
|
@ -29,15 +29,16 @@ let
|
||||||
print("Open login page...", file=sys.stderr)
|
print("Open login page...", file=sys.stderr)
|
||||||
driver.get("http://pixelfed.localhost/login")
|
driver.get("http://pixelfed.localhost/login")
|
||||||
print("Enter email...", file=sys.stderr)
|
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)
|
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
|
# FIXME: This is disgusting. Find instead the input type submit in the form
|
||||||
# with action ending in "/login".
|
# with action ending in "/login".
|
||||||
print("Click “Login” button...", file=sys.stderr)
|
print("Click “Login” button...", file=sys.stderr)
|
||||||
driver.find_element(By.XPATH, "//button[normalize-space()='Login']").click()
|
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: ''
|
seleniumTakeScreenshot = path: ''
|
||||||
print("Take screenshot...", file=sys.stderr)
|
print("Take screenshot...", file=sys.stderr)
|
||||||
if not driver.save_screenshot(${path}):
|
if not driver.save_screenshot(${path}):
|
||||||
|
@ -172,7 +173,7 @@ pkgs.nixosTest {
|
||||||
server.wait_for_unit("phpfpm-pixelfed.service")
|
server.wait_for_unit("phpfpm-pixelfed.service")
|
||||||
|
|
||||||
with subtest("Account creation"):
|
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
|
# 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).
|
# 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.
|
# there, then post a green image and check that the green pixel IS there.
|
||||||
|
|
||||||
with subtest("Image displays"):
|
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", "")
|
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:")
|
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
|
# check that the green image displayed somewhere
|
||||||
|
@ -193,7 +194,7 @@ pkgs.nixosTest {
|
||||||
server.succeed("mc ls garage/pixelfed")
|
server.succeed("mc ls garage/pixelfed")
|
||||||
|
|
||||||
with subtest("access image in garage"):
|
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()
|
image = image.rstrip()
|
||||||
if image == "":
|
if image == "":
|
||||||
raise Exception("image posted to mastodon did not get stored in garage")
|
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")
|
raise Exception("image stored in garage did not match image uploaded")
|
||||||
|
|
||||||
with subtest("Check that image comes from garage"):
|
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/"):
|
if not src.startswith("http://pixelfed.web.garage.localhost:3902/"):
|
||||||
raise Exception("image does not come from garage")
|
raise Exception("image does not come from garage")
|
||||||
'';
|
'';
|
||||||
|
|
Reference in a new issue