mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
tests/playwright-python: init
For some reason, chromium, which is still the nixpkgs version hangs inside the normal test vm, while working fine in .driverInteractive. I suspect that might have to do with the existence of a display in .driverInteractive. Neither vm does run X11 or wayland.
This commit is contained in:
parent
67b5c21b58
commit
01fd62f37a
@ -785,6 +785,7 @@ in {
|
||||
plasma6 = handleTest ./plasma6.nix {};
|
||||
plasma5-systemd-start = handleTest ./plasma5-systemd-start.nix {};
|
||||
plausible = handleTest ./plausible.nix {};
|
||||
playwright-python = handleTest ./playwright-python.nix {};
|
||||
please = handleTest ./please.nix {};
|
||||
pleroma = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./pleroma.nix {};
|
||||
plikd = handleTest ./plikd.nix {};
|
||||
|
58
nixos/tests/playwright-python.nix
Normal file
58
nixos/tests/playwright-python.nix
Normal file
@ -0,0 +1,58 @@
|
||||
import ./make-test-python.nix (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
name = "playwright-python";
|
||||
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [ phaer ];
|
||||
};
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.variables = {
|
||||
NIX_MANUAL_DOCROOT = "file://${pkgs.nix.doc}/share/doc/nix/manual/index.html";
|
||||
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
|
||||
};
|
||||
environment.systemPackages = [
|
||||
(pkgs.writers.writePython3Bin "test_playwright"
|
||||
{
|
||||
libraries = [ pkgs.python3Packages.playwright ];
|
||||
}
|
||||
''
|
||||
import sys
|
||||
from playwright.sync_api import sync_playwright
|
||||
from playwright.sync_api import expect
|
||||
|
||||
browsers = {
|
||||
"chromium": ["--headless", "--disable-gpu"],
|
||||
"firefox": [],
|
||||
"webkit": []
|
||||
}
|
||||
if len(sys.argv) != 3 or sys.argv[1] not in browsers.keys():
|
||||
print(f"usage: {sys.argv[0]} [{'|'.join(browsers.keys())}] <url>")
|
||||
sys.exit(1)
|
||||
browser_name = sys.argv[1]
|
||||
url = sys.argv[2]
|
||||
browser_args = browsers.get(browser_name)
|
||||
print(f"Running test on {browser_name} {' '.join(browser_args)}")
|
||||
with sync_playwright() as p:
|
||||
browser = getattr(p, browser_name).launch(args=browser_args)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.goto(url)
|
||||
expect(page.get_by_text("Nix Reference Manual")).to_be_visible()
|
||||
''
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
# FIXME: Webkit segfaults
|
||||
for browser in ["firefox", "chromium"]:
|
||||
with subtest(f"Render Nix Manual in {browser}"):
|
||||
machine.succeed(f"test_playwright {browser} $NIX_MANUAL_DOCROOT")
|
||||
'';
|
||||
|
||||
}
|
||||
)
|
@ -12,6 +12,7 @@
|
||||
setuptools,
|
||||
setuptools-scm,
|
||||
playwright-driver,
|
||||
nixosTests,
|
||||
nodejs,
|
||||
}:
|
||||
|
||||
@ -93,10 +94,14 @@ buildPythonPackage rec {
|
||||
|
||||
passthru = {
|
||||
inherit driver;
|
||||
tests = {
|
||||
driver = playwright-driver;
|
||||
browsers = playwright-driver.browsers;
|
||||
};
|
||||
tests =
|
||||
{
|
||||
driver = playwright-driver;
|
||||
browsers = playwright-driver.browsers;
|
||||
}
|
||||
// lib.optionalAttrs stdenv.isLinux {
|
||||
inherit (nixosTests) playwright-python;
|
||||
};
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user