From 7dc8b170101cdda1a272d7b6f9d2e0d9900eb90c Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 6 Feb 2026 12:55:41 +0100 Subject: [PATCH 01/23] Tests: Add Playwright as an integration tests dependency Chromium is installed in CI with `playwright install --with-deps` and the docs explain how to install it locally. --- .github/element-docs-words.txt | 1 + .github/workflows/pytest.yml | 3 + DEVELOPERS.md | 3 + tests/README.md | 1 + tests/pyproject.toml | 1 + uv.lock | 110 +++++++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+) diff --git a/.github/element-docs-words.txt b/.github/element-docs-words.txt index a3f4f4af..8f74b957 100644 --- a/.github/element-docs-words.txt +++ b/.github/element-docs-words.txt @@ -36,6 +36,7 @@ newsfragment newsfragments OpenProject passthrough +Playwright postgres PostgreSQL prometheus diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 64c76405..0cb7d3b1 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -75,6 +75,9 @@ jobs: - name: Set up UV environment run: uv sync + - name: Install Playwright browsers + run: uv run playwright install chromium --with-deps + - name: Get current week number and home dir id: cache-input run: | diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 52474373..86f48c63 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -164,6 +164,9 @@ Verifies that the deployed workloads behave as expected and integrates well toge From the project root : `pytest-ess` +Some tests drive Element Web and Element Admin in a headless Chromium with [Playwright](https://playwright.dev/python/). +Install the browser once with `uv run playwright install chromium`. + Pytest caches the namespace name and created user tokens between run. To start a run from scratch, run `pytest-ess -- --cache-clear`. diff --git a/tests/README.md b/tests/README.md index de564d0b..3fb9ac93 100644 --- a/tests/README.md +++ b/tests/README.md @@ -19,6 +19,7 @@ The ESS Community Integration Tests project is designed to facilitate the testin - Docker - [k3d](https://k3d.io/stable/) - [Helm](https://helm.sh/docs/intro/install) +- A Chromium install for [Playwright](https://playwright.dev/python/), for the browser based tests: `playwright install chromium` - Optional: [uv](https://docs.astral.sh/uv/getting-started/installation/) to install from git ## Installation diff --git a/tests/pyproject.toml b/tests/pyproject.toml index 56cacafc..1248d411 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -19,6 +19,7 @@ dependencies = [ "jsonschema>=4.26.0", "lightkube>=1.0.0", "platformdirs>=4.9.2", + "playwright>=1.62.0", "prometheus-client>=0.26.0", "pyhelm3>=0.5.7", "pytest-asyncio-cooperative>=0.40.0", diff --git a/uv.lock b/uv.lock index 6b9aaf71..085813ed 100644 --- a/uv.lock +++ b/uv.lock @@ -919,6 +919,7 @@ dependencies = [ { name = "jsonschema" }, { name = "lightkube" }, { name = "platformdirs" }, + { name = "playwright" }, { name = "prometheus-client" }, { name = "pyhelm3" }, { name = "pytest" }, @@ -942,6 +943,7 @@ requires-dist = [ { name = "jsonschema", specifier = ">=4.26.0" }, { name = "lightkube", specifier = ">=1.0.0" }, { name = "platformdirs", specifier = ">=4.9.2" }, + { name = "playwright", specifier = ">=1.62.0" }, { name = "prometheus-client", specifier = ">=0.26.0" }, { name = "pyhelm3", specifier = ">=0.5.7" }, { name = "pytest", specifier = ">=8.4.2,<9" }, @@ -1115,6 +1117,83 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d6/0b/29d7965215f8ef830a7ca1f42997fe13e5693d85e9edb18f938d063ef5f2/gitpython-3.1.62-py3-none-any.whl", hash = "sha256:7002251225e10e29d2e1f49e6532613fe5d5d9f0b6f1f02997a52b38fe56899e", size = 222753, upload-time = "2026-09-07T02:57:19.762Z" }, ] +[[package]] +name = "greenlet" +version = "3.5.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0b/d8/7cc97c142388aef03f622e001c572c4f84e9252a439549d483f555771970/greenlet-3.5.5.tar.gz", hash = "sha256:adb4bae02e91a8e863e48b177e4014bdcac8a6b5e047ea1df687a61534b85e6c", size = 207585, upload-time = "2026-08-10T15:09:36.136Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/a3/07297917485ee2ca85bc3c8dc6ed85ad3fffcf424047fba62671dba68e97/greenlet-3.5.5-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:be63afcbbccfad3dd95a1ba12ada84dab2ef32031973d80b5b92df67fa763a61", size = 294165, upload-time = "2026-08-10T13:25:17.987Z" }, + { url = "https://files.pythonhosted.org/packages/db/51/6f732f9314cda54c5fd48a7620c7160f4f286967e8045ad94b9d66ce80b7/greenlet-3.5.5-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8a268024ce2d7d2b04694bf1594058981a9fa663d1df4b762dee499211ed7c1c", size = 613610, upload-time = "2026-08-10T14:14:33.829Z" }, + { url = "https://files.pythonhosted.org/packages/d8/c0/b27589e25d220289edcd4d582b2b17b83058d1a56d53d971b6ea1a34f10d/greenlet-3.5.5-cp311-cp311-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:35cbb8bf55ace57fbccb4fb8622c4521713acd8691e77f4696d416ea7ca527da", size = 625481, upload-time = "2026-08-10T14:27:23.647Z" }, + { url = "https://files.pythonhosted.org/packages/39/82/5c873dbb4fb001d22fbbd50e80d4c1b0181ddae106856132160f84b94e88/greenlet-3.5.5-cp311-cp311-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:abc8bc8d9f935cd685457545b6a53863a877fdc12c2c0f5ee9beee18d9db139c", size = 633329, upload-time = "2026-08-10T14:30:06.062Z" }, + { url = "https://files.pythonhosted.org/packages/51/2d/f2c928218ac52f26d7a2c188c171d1b7e728b23782cb3347e7b4fce1493a/greenlet-3.5.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:74cc6df89ec5302337adc9cf096221cbed2510fd444b0e0f1586cf0470740864", size = 624562, upload-time = "2026-08-10T13:40:48.064Z" }, + { url = "https://files.pythonhosted.org/packages/70/12/f7df98e72a8eb4a7edfec5a08d6d1a4ab53a52c95ba0b2ea6c10b8dd9bd0/greenlet-3.5.5-cp311-cp311-manylinux_2_39_riscv64.whl", hash = "sha256:3134291427bb0f3526e9d90311988caf336eb43730e95244997a4fb15f45144f", size = 428145, upload-time = "2026-08-10T14:30:01.071Z" }, + { url = "https://files.pythonhosted.org/packages/3e/4a/92fc51d5d35912f4f06eec037ba347985defd0be47463a010a325634d9d2/greenlet-3.5.5-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6d9b454c5fc48aeaa7c4337813dbf513a6870468e426438a04d922c6d0fe63db", size = 1584909, upload-time = "2026-08-10T14:15:04.343Z" }, + { url = "https://files.pythonhosted.org/packages/ac/58/ed98b80ac5738c149a5258544843c45601ade1fd70f61740cdaead6351b3/greenlet-3.5.5-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:03551ed792cb1b4fc0277a0c60dfd8c343894a0ba06fe60dcd22f568b433da39", size = 1651184, upload-time = "2026-08-10T13:40:28.879Z" }, + { url = "https://files.pythonhosted.org/packages/d8/be/b582ceb80cefdf9d8da34078714e4b12b3d16f509dee0f65e40a5cc8fc7d/greenlet-3.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:ab3df3dffb58bf70564e93a5cec7941e4d9faa5a36cc4234a10d3131afe04f53", size = 323280, upload-time = "2026-08-10T13:26:07.495Z" }, + { url = "https://files.pythonhosted.org/packages/4d/18/5313c4c58598c38b0373c013e4ff2b3e6d258aaaa338f373335ebecdaddd/greenlet-3.5.5-cp311-cp311-win_arm64.whl", hash = "sha256:2b70a766135540c472ac1393d57c2e1b4a2eb85bf526a1e41e6d096173a8cee5", size = 307785, upload-time = "2026-08-10T13:28:34.874Z" }, + { url = "https://files.pythonhosted.org/packages/2e/7e/9ecd0285e3153532ae07aeb88063c43c72b4221cf0d4d123b02f3682e3ff/greenlet-3.5.5-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:49520f0c95a48b42cf55414b8e8479beb274ea70431afc33e3f79903c71f4380", size = 295809, upload-time = "2026-08-10T13:25:34.023Z" }, + { url = "https://files.pythonhosted.org/packages/35/73/60e4bbcc89252037b18087f2ec16405d5b2d5be42dde191bbf3667e96102/greenlet-3.5.5-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:55272212cbc5f43d1d723725ab931f1939969b7e9523882ca58b55061769d053", size = 611910, upload-time = "2026-08-10T14:14:35.18Z" }, + { url = "https://files.pythonhosted.org/packages/a4/17/cd5134be659cd4a443e7a61ae670dabec165a814c51162916d637b6dd38e/greenlet-3.5.5-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:655bca754a2ef4efcb0eb48a94d3f4593536d0f3d48f8ed44343c01d16a92f95", size = 624198, upload-time = "2026-08-10T14:27:25.229Z" }, + { url = "https://files.pythonhosted.org/packages/9b/30/87c212b5c684d0e72974f1063b7a9687631e8985902c06e1016542c874e7/greenlet-3.5.5-cp312-cp312-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:6ca5d6ae0739e5764f2cfcfaa562ac5a990cbdaedca93251c5e3cf07c362371f", size = 629504, upload-time = "2026-08-10T14:30:07.967Z" }, + { url = "https://files.pythonhosted.org/packages/78/ac/5c5b959999b6f09c3026b5dfe171575bc3121c5236ce74f495096f25b203/greenlet-3.5.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:147b25a42e5ca5be3d42356e8f608b37af715a1c196e9bf9d1627f3341adfe1d", size = 621439, upload-time = "2026-08-10T13:40:49.391Z" }, + { url = "https://files.pythonhosted.org/packages/63/2c/eb487fafc9f50ffff2b1e0b697f70fb34bf150821c08ab225aacf5583a7e/greenlet-3.5.5-cp312-cp312-manylinux_2_39_riscv64.whl", hash = "sha256:1b5ed9162c0c098e0bbc2cf88a94f433c1b8926f831745252e099e5d83e17759", size = 432462, upload-time = "2026-08-10T14:30:02.309Z" }, + { url = "https://files.pythonhosted.org/packages/c8/8b/6acf112ed8aee499f25b4d6949820fb02ac950ff9c1f3d793bd5be0599f2/greenlet-3.5.5-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:27493374cff1d1b7919dc8126547f2aea582737e3046147b434b1e12de56389b", size = 1581342, upload-time = "2026-08-10T14:15:05.653Z" }, + { url = "https://files.pythonhosted.org/packages/b8/d7/734e5f198888876b42d7616ff6644c075baf6b8a2412deadd6b0e1b8b20c/greenlet-3.5.5-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:12e2ee66c2aba86133f10fd99d6a8856c6d351ffb7be0e4d52ef2cc5fbb705b2", size = 1645744, upload-time = "2026-08-10T13:40:30.353Z" }, + { url = "https://files.pythonhosted.org/packages/de/30/1f42b88dc587b5899ee50616ad56ee40cafaf225df4fb829f10183c62a5c/greenlet-3.5.5-cp312-cp312-win_amd64.whl", hash = "sha256:49ddacd36af37735fab103846f4ee4d18a492dde72730d1699c0c8ebe30d9f18", size = 324171, upload-time = "2026-08-10T13:28:44.472Z" }, + { url = "https://files.pythonhosted.org/packages/76/e5/4dee4d8d2e603fe5fdd7b444e63219f7b9bd852c60c6214511c7157cbe88/greenlet-3.5.5-cp312-cp312-win_arm64.whl", hash = "sha256:5f1b1ff4828cdc1aba4266aff814085d04a1d07959287219af021b838b265d52", size = 308362, upload-time = "2026-08-10T13:26:46.839Z" }, + { url = "https://files.pythonhosted.org/packages/fb/3d/8cef5f724ec0d4add2af8961d504535ec60c3cca9e464f6d03bdba29d85b/greenlet-3.5.5-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:b79fd2a5bc099b5e744f34c4c9a58954a5f4cb7529fb4b6e8446057d61b6edaa", size = 294730, upload-time = "2026-08-10T13:27:51.206Z" }, + { url = "https://files.pythonhosted.org/packages/88/4b/8e7aa3f514273aecff30a16ab1bac09ff54cfc7e6860fdd8058c37ff2499/greenlet-3.5.5-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:634cf15a233a949136879dd388e25d3296e16f3f1e217d2456797b8579ebc6ed", size = 614536, upload-time = "2026-08-10T14:14:36.589Z" }, + { url = "https://files.pythonhosted.org/packages/85/48/4e95e9dd5a8a397dc6a6345dd7f1935113d0fca4f85e89d3976da9cd988d/greenlet-3.5.5-cp313-cp313-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:499adea519f748407fc6806d20eedabac2884fd73b9f38d81236e190ba20dfef", size = 626924, upload-time = "2026-08-10T14:27:27.048Z" }, + { url = "https://files.pythonhosted.org/packages/0e/84/eaa476d6bf3816828d0d70e80dcc36bf30a058233bd889e707e693f6e860/greenlet-3.5.5-cp313-cp313-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f7278591501941bb2456af102bb9cd59aab48c6cfd6e2dd68fa1290bb0c49a42", size = 632726, upload-time = "2026-08-10T14:30:09.874Z" }, + { url = "https://files.pythonhosted.org/packages/89/5d/398a1c71fa7a277deeb376c999979de6786f08fc2d5747a0b9d6e11738dd/greenlet-3.5.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2eabb980975cba5b93a95f6f69287d05fc05ac955bfd6a320a7c083eeb52c0b0", size = 623906, upload-time = "2026-08-10T13:40:50.501Z" }, + { url = "https://files.pythonhosted.org/packages/d0/f2/0cc2849ede68579291e9c59b3ab6ec1958f98681cca5b14d8fc75bf674a4/greenlet-3.5.5-cp313-cp313-manylinux_2_39_riscv64.whl", hash = "sha256:4dfc7c4470354e7b09184d1a3a985761053a2fd694ddb5b5c80242afc2c8c90b", size = 434966, upload-time = "2026-08-10T14:30:03.729Z" }, + { url = "https://files.pythonhosted.org/packages/04/1b/745450fc5ea9e0cb17d840d248f284db3363de736d362c7d2d883e3eadba/greenlet-3.5.5-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:03115c2e0a371999bf8ae616aa8d653f96641d4705c457aebaa187276e9f7537", size = 1581430, upload-time = "2026-08-10T14:15:06.853Z" }, + { url = "https://files.pythonhosted.org/packages/d4/29/d51b296e3191bb15d3d81ec375af1909e4466c0f395d744ed475801798a9/greenlet-3.5.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4441153ffba21b90d3ca89fe3d31f5c093ae6c0bf0cfdfc98f54cde22f95b62e", size = 1645684, upload-time = "2026-08-10T13:40:32.133Z" }, + { url = "https://files.pythonhosted.org/packages/12/63/369f1a1625e64e9e31df3963c6044056e3fdfa3fa3fdba3c54ffefa6e987/greenlet-3.5.5-cp313-cp313-win_amd64.whl", hash = "sha256:95c5b1f4b3a193f8a0c2de4bfdcb48d119f7f1063941f1de1f2168051b3e52dd", size = 324075, upload-time = "2026-08-10T13:26:58.974Z" }, + { url = "https://files.pythonhosted.org/packages/45/78/649cb5c09d4d81f6dd1444e75474a7206784743283a21d24171562ac4899/greenlet-3.5.5-cp313-cp313-win_arm64.whl", hash = "sha256:1af90aa4bc129883b340cdd6957a3bc74f60528a4993bbd1f53aaebe1d9981cc", size = 308260, upload-time = "2026-08-10T13:27:50.795Z" }, + { url = "https://files.pythonhosted.org/packages/7f/8c/080e881fa2be95ff1ddbd6994b2bab3b1a78df3b3fcab39306011764fcc7/greenlet-3.5.5-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:d4a389a852e392a6366058651a20fa5ba40d979865aa81bea2ccbdc44805070d", size = 295309, upload-time = "2026-08-10T13:26:03.032Z" }, + { url = "https://files.pythonhosted.org/packages/25/cc/0ac614e6586c0e42d4cc281a5819150f4f43685744a4c5ff77139286409d/greenlet-3.5.5-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:70b157cd319873e8b544ddc2de158f55bbd0a9b0218c8ce9332039801518e328", size = 661185, upload-time = "2026-08-10T14:14:37.867Z" }, + { url = "https://files.pythonhosted.org/packages/5e/b9/6808725354be8ad305dfe5172377664fc9642d4fc043be246b3314cf4482/greenlet-3.5.5-cp314-cp314-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8bdfd1424abcf26832961e766570cae79efdb9599d709088c9cb6ef82b194926", size = 673419, upload-time = "2026-08-10T14:27:28.652Z" }, + { url = "https://files.pythonhosted.org/packages/eb/52/f005d579acde46c3d1cc3cab1c9f3d5708c8a3006a4120e8cf5da801afe9/greenlet-3.5.5-cp314-cp314-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d98ef6f92e67c6dbf299dbfd8facc1b0d2d9cedf91e325e73b3d0373fe4309d8", size = 677863, upload-time = "2026-08-10T14:30:11.663Z" }, + { url = "https://files.pythonhosted.org/packages/42/2e/40c509967da7f254680826a2fa0dd22138ec79946c70b97542d74cde8b43/greenlet-3.5.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:182de51c6b572a705f2fafaab2e783bcf7d2760940229dfe73086cbae037af3e", size = 670822, upload-time = "2026-08-10T13:40:51.833Z" }, + { url = "https://files.pythonhosted.org/packages/c4/8a/a75f8a2bdcef3c358a3147cdc9db3aa83755f0a038f766ab0bedb66f512c/greenlet-3.5.5-cp314-cp314-manylinux_2_39_riscv64.whl", hash = "sha256:159df1942d88e8f784cbb38d6f18bdb365cd11319cfbb3e89623de2b97892d53", size = 480554, upload-time = "2026-08-10T14:30:05.171Z" }, + { url = "https://files.pythonhosted.org/packages/2d/22/c3c2eee4a8fe191d6d1d183086c56133d646024e3d70bfd414829f64560b/greenlet-3.5.5-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8fec3f165dfe332e490c3247c0f6c23b0bfc45f06496ad7f00ddb00e3d35e4dc", size = 1628469, upload-time = "2026-08-10T14:15:08.11Z" }, + { url = "https://files.pythonhosted.org/packages/f7/87/25babd09b94cb1f03e71db815fde463f0262e40cfbd953d58a8d77311351/greenlet-3.5.5-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:c6ce25fee6cabc8bf22cb8b52e642cbb821be5b9aec8094d07ff03378141b8e9", size = 1691952, upload-time = "2026-08-10T13:40:33.502Z" }, + { url = "https://files.pythonhosted.org/packages/2e/3d/5cc9701117ea4dc0eb7bf1f4f9b7888a6e2e5277ddfae095805ace50f2b6/greenlet-3.5.5-cp314-cp314-win_amd64.whl", hash = "sha256:7dffc5c859fe6059974df1e37d7923d654a83e2ae18fdd616994270e001115e1", size = 327458, upload-time = "2026-08-10T13:27:02.868Z" }, + { url = "https://files.pythonhosted.org/packages/a7/6b/594fa2de7fae7629168a404a4305d7d7e31a5742c50a801b1839543cb93d/greenlet-3.5.5-cp314-cp314-win_arm64.whl", hash = "sha256:5e2afcfc4d4305dd715809b03da5cbe437c8984f61d8917751eb5fe4aefa3e07", size = 311146, upload-time = "2026-08-10T13:27:25.046Z" }, + { url = "https://files.pythonhosted.org/packages/24/e0/50cd600b469e5734c72709b6b1838b6bc63f307b573c772c3132d6ecfe92/greenlet-3.5.5-cp314-cp314t-macosx_11_0_universal2.whl", hash = "sha256:0e5a7de979d764aea1f5b6e95cf92b5b37741b9823702041f34b126e7f690277", size = 305471, upload-time = "2026-08-10T13:26:20.568Z" }, + { url = "https://files.pythonhosted.org/packages/75/a3/77acd66dfc6387b5219b2080806c0cabb73c10eb1bb44b413c40a62015ba/greenlet-3.5.5-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fef01bd457f11fc158b130ca0027a3c365693280e8e231b65bdaf57999f39f5b", size = 672470, upload-time = "2026-08-10T14:14:39.058Z" }, + { url = "https://files.pythonhosted.org/packages/b9/71/0d178142dca3ec19f46fb2212ae73d30ad53b9d548dc64804086033a7089/greenlet-3.5.5-cp314-cp314t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5173a72310725a74afc82c164f0e52cb8ad0de62f2bb623f24f6c0cc07d80272", size = 679973, upload-time = "2026-08-10T14:27:30.072Z" }, + { url = "https://files.pythonhosted.org/packages/aa/ac/0d7887aa4bbfc9eba075cc428244dfc96f623478454d5ec81180d0d6bd5a/greenlet-3.5.5-cp314-cp314t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5e9ec2e7c98e895fcea0c5cc57b2606cf86ece6d0a56578f3eb225e2af4f0387", size = 681587, upload-time = "2026-08-10T14:30:13.519Z" }, + { url = "https://files.pythonhosted.org/packages/6e/31/46eb8567302eaf787abf88d09df014e14ae3baf460af1b8b0efdbd3efcd5/greenlet-3.5.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44f08341873200ba8a60a8bc14ace3d91f1754f7fa7bc66157714a8cd420a476", size = 676634, upload-time = "2026-08-10T13:40:53.004Z" }, + { url = "https://files.pythonhosted.org/packages/4f/18/8d58ba1c429b0383e3219a3d0e0bba241d0444d8ed05b73349953c7d7c7b/greenlet-3.5.5-cp314-cp314t-manylinux_2_39_riscv64.whl", hash = "sha256:102817506f6090b5176c746a82603341a549b40e5c3d5b72a4c672228a918c41", size = 510175, upload-time = "2026-08-10T14:30:07.047Z" }, + { url = "https://files.pythonhosted.org/packages/a3/e9/b88bbf5b29970cb84172dc2c32aa3e5e579ceb94c808e81c826454138850/greenlet-3.5.5-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:d246c0db9a2513cd45f019ba178ea4d4d4705bd210ee465e2c15d76a1ab13874", size = 1637320, upload-time = "2026-08-10T14:15:09.317Z" }, + { url = "https://files.pythonhosted.org/packages/6d/8c/7631ed29cc6f0392f11830076e172ce4885e70b0bc2c1bce1731176d4b4e/greenlet-3.5.5-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:72507285b5caa1d17904a3f7c322ca780823a54170a0e04ec3f37bcc60d4db71", size = 1697412, upload-time = "2026-08-10T13:40:34.924Z" }, + { url = "https://files.pythonhosted.org/packages/da/0f/f7dd935f9c4cb1be49098770587f54d8a78518e55c89bce86c4fb4109057/greenlet-3.5.5-cp314-cp314t-win_amd64.whl", hash = "sha256:7805655781fb8f28a55d05fe57ed61f5f10f1892fb587673e3bb5264f28041f0", size = 331514, upload-time = "2026-08-10T13:29:20.611Z" }, + { url = "https://files.pythonhosted.org/packages/b7/e5/681b01f8fbc1b55232822f99e8f8afeb78a55a7c76a7bf9dbdc7ccb03a6d/greenlet-3.5.5-cp315-cp315-macosx_11_0_universal2.whl", hash = "sha256:c0db80fcd5b8aece93f66c64f78a786bbb6b96c5fe63ef5a5a4581ecf8bab206", size = 295975, upload-time = "2026-08-10T13:28:45.985Z" }, + { url = "https://files.pythonhosted.org/packages/11/f2/69b488cd9e7267bf4b0fe8cdebf25d8d6df680d21bdf41150d23e23d6652/greenlet-3.5.5-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b241c32f912ada659808d68e308c568baf577eebf757d15471472de0c18cfad", size = 666823, upload-time = "2026-08-10T14:14:40.222Z" }, + { url = "https://files.pythonhosted.org/packages/84/d4/d5bc2fdebbdda0c94555925ba79948b8395d75a7f6a36cc85dce5bab9f11/greenlet-3.5.5-cp315-cp315-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ef6a08349401d8eaf3cb12688ac8557de95788556b8631ef17555a4a173022c0", size = 677613, upload-time = "2026-08-10T14:27:31.543Z" }, + { url = "https://files.pythonhosted.org/packages/65/53/4e13642efc4d7ad6554ecb2242a5be42666b2e1a067323e88dfc0124a04b/greenlet-3.5.5-cp315-cp315-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:37faa97daccb6d9f4c2141ce3118d023c3c5506864a7d8bdf726f665018c1f76", size = 681436, upload-time = "2026-08-10T14:30:14.839Z" }, + { url = "https://files.pythonhosted.org/packages/bd/93/542d8a3a90f3b35c6ad8bf7e56a03010287f2cafa289a5b7985b5207db39/greenlet-3.5.5-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f2e3d061b8e13aec2f0441689b3c71b244a20e5d274a52cb0f7e31bd1d139552", size = 675930, upload-time = "2026-08-10T13:40:54.205Z" }, + { url = "https://files.pythonhosted.org/packages/cd/32/188447c9a468d6977d2989397226b0c6b65ab6f4cf943f931643328512fc/greenlet-3.5.5-cp315-cp315-manylinux_2_39_riscv64.whl", hash = "sha256:b18007dc2473a7942fd157366b55f01da6fed7ce85318591005b419e0a439474", size = 487404, upload-time = "2026-08-10T14:30:08.903Z" }, + { url = "https://files.pythonhosted.org/packages/52/b5/89c9f2e8460d71101037d47a1feed11928615a5edd42370be290e0657eeb/greenlet-3.5.5-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:9ab5f5b93655e77fe0d6c2dfd22b5eac751bb1f876d8ec21761b7c1fb9266007", size = 1633878, upload-time = "2026-08-10T14:15:10.693Z" }, + { url = "https://files.pythonhosted.org/packages/b8/60/297de93f3b02ac78a5e04d32bb8bbe3080f4a73d8ed95016561463b70618/greenlet-3.5.5-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:f0e5a21bd4452a88cf032fc43c4a5b307ab1380eacb63b5988f9c0317885e773", size = 1696597, upload-time = "2026-08-10T13:40:36.252Z" }, + { url = "https://files.pythonhosted.org/packages/18/25/54c6eaff4f337fb670215e89eb2d00d9499487b658e709d4b477be4a342e/greenlet-3.5.5-cp315-cp315-win_amd64.whl", hash = "sha256:469dbb0a78625642f4a626cfd0c6e8bccc0385b5e49189b6308bbe849ec88a8e", size = 327700, upload-time = "2026-08-10T13:28:06.752Z" }, + { url = "https://files.pythonhosted.org/packages/67/67/857e88a36301caa0e029870132c2478bd55d896630321432afab03a3115f/greenlet-3.5.5-cp315-cp315-win_arm64.whl", hash = "sha256:2d57406c3efd32d7a81e17a674314e8bd00792cdab49ea3228a49aa1bfb2e769", size = 311750, upload-time = "2026-08-10T13:34:08.815Z" }, + { url = "https://files.pythonhosted.org/packages/10/e2/3144c0a116067ac1e30457b0139a94d60d1d36a86e015de68e9ac87cb3bc/greenlet-3.5.5-cp315-cp315t-macosx_11_0_universal2.whl", hash = "sha256:68184dfcf50ccaa8e864770fe0633a7e27250ea9329f8192ef47ee9ecfd78e1c", size = 306387, upload-time = "2026-08-10T13:27:00.897Z" }, + { url = "https://files.pythonhosted.org/packages/5c/a1/cb4223a7e9b9f43b8807e8eb212358bfe2dfaa174a9ea2889eb1714dcba2/greenlet-3.5.5-cp315-cp315t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9ec0dc0e59dc9c61af5c47348365ccbbd7addfafe0a93b00336ff3da2907bdc6", size = 676472, upload-time = "2026-08-10T14:14:41.417Z" }, + { url = "https://files.pythonhosted.org/packages/9e/cd/a154b4498e5d8f12ada291cfb3b8d596eadde2177f5bf09a9be699d2a446/greenlet-3.5.5-cp315-cp315t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e604f58e35833fc46ef20302bcb314dddbfd3fcf33a4f936216d51dd678d63ae", size = 684238, upload-time = "2026-08-10T14:27:32.946Z" }, + { url = "https://files.pythonhosted.org/packages/ce/f4/e450a68a152f819491d8c7df6a8254e761d87e6a78759268961f8c5bd4dd/greenlet-3.5.5-cp315-cp315t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2888a3a38bc5ee5bb6c438372197152e815837e4fab7ed7a1f86ef18ffd58ad1", size = 686022, upload-time = "2026-08-10T14:30:15.96Z" }, + { url = "https://files.pythonhosted.org/packages/bf/bb/b0031d260c2968a3c87deebc51d80c64e499377f993aafe06ee3b7488cc2/greenlet-3.5.5-cp315-cp315t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:40239b5384f96da3963585cc6d7eaa9b56f8ae67e8d92cc82dd9e202fc847de3", size = 681246, upload-time = "2026-08-10T13:40:55.402Z" }, + { url = "https://files.pythonhosted.org/packages/18/23/17e63d6bf3b9c9b9dbea981b7f643a71f79603bdfb4f1c3a9cf353e22aed/greenlet-3.5.5-cp315-cp315t-manylinux_2_39_riscv64.whl", hash = "sha256:1e8d9391fe77f15649589a907cef972dbbd6352ef7ff7dc0492f658c0c26495f", size = 516951, upload-time = "2026-08-10T14:30:10.907Z" }, + { url = "https://files.pythonhosted.org/packages/9a/07/da554b71ab88e649da146e1065d86a48a5c5d92e50ab74ef41b504aa7f56/greenlet-3.5.5-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:a1eaccf5c3a1d3e46dead602c72e6836731e8e245c9de6a27764567b6b62d4c0", size = 1642735, upload-time = "2026-08-10T14:15:11.92Z" }, + { url = "https://files.pythonhosted.org/packages/78/76/26a3782a051677668af9d92beaa47cd87ba9dd5072f762961144a03dd4c6/greenlet-3.5.5-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:19e4e026fe20691f333b8eb1a3bc9625eceba8c3f9d62ec5a6f8581afbc6b5a5", size = 1700925, upload-time = "2026-08-10T13:40:37.656Z" }, + { url = "https://files.pythonhosted.org/packages/28/d9/fe7baf4190c2ae71f267efb9de21b3172bb35bc0ed1ef53dd6027d658e33/greenlet-3.5.5-cp315-cp315t-win_amd64.whl", hash = "sha256:712aee154f648bde84634654bb38bb78c69ac640c37a45c9effed800735049d8", size = 331829, upload-time = "2026-08-10T13:26:48.851Z" }, + { url = "https://files.pythonhosted.org/packages/df/af/419a4e383bd600858a9b67e9b280a60fdc383ee3f2fe5b6c0c1ef04e74d1/greenlet-3.5.5-cp315-cp315t-win_arm64.whl", hash = "sha256:7f049911ee81a16a03c33d5450d8d5867d27f596ca5fb201b86f4524e874468b", size = 315093, upload-time = "2026-08-10T13:29:34.949Z" }, +] + [[package]] name = "h11" version = "0.16.0" @@ -1982,6 +2061,25 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/2b/69de6317fbf48865bb12aa56c9cfcfff46b3add0cd45250725d96146dce0/platformdirs-4.11.12-py3-none-any.whl", hash = "sha256:b1ba966ac76153d9985a0787ffab951e7c18416189873d4e4ddb2c8a04a0a254", size = 24976, upload-time = "2026-09-22T01:02:35.742Z" }, ] +[[package]] +name = "playwright" +version = "1.62.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "greenlet" }, + { name = "pyee" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/5b/ca2abcf3aa69f9fb510215e3064f30b57fe57657c8d04ede45bb966d5606/playwright-1.62.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:d8da938f3748841a8754f2e1f0216902c1c8f8ae3720de8b32ccf8e6913a7c4f", size = 43732091, upload-time = "2026-07-31T17:00:44.178Z" }, + { url = "https://files.pythonhosted.org/packages/af/1a/0bfbe9904350961f4dbb713f04342e40d548c5fc26c8157bd13617c81492/playwright-1.62.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:db755ab27db21a04186f1fe8169888e42356086e439b1059b923ef417f0b6034", size = 42510842, upload-time = "2026-07-31T17:00:48.596Z" }, + { url = "https://files.pythonhosted.org/packages/66/dc/c0486b407ad0699a250f6bbe3066fca95344009a99ca66e88ca175c69dc1/playwright-1.62.0-py3-none-macosx_11_0_universal2.whl", hash = "sha256:5108bd5b3e87169ddf269feee097da5893af7f8aea4634dfc840518d64c1f1da", size = 43732093, upload-time = "2026-07-31T17:00:52.218Z" }, + { url = "https://files.pythonhosted.org/packages/43/6b/b24aebc2b04bffcb342bccf96e287c78b363e1615bed5cea97500cc0393a/playwright-1.62.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:ba33bae6a13b3d9d354c751cb618af357d20fe1d57767cbcce52079bbef17ad3", size = 47748926, upload-time = "2026-07-31T17:00:56.438Z" }, + { url = "https://files.pythonhosted.org/packages/36/43/b4b18bdc87e1949568fffdcde3ff9a0456266b2d0c6d4432cc34d89ea6eb/playwright-1.62.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:db2d76613a57ad844362ce42f7d0c2fa26b19a4f7a46d4f76b891c631e6e5aff", size = 47441423, upload-time = "2026-07-31T17:01:00.404Z" }, + { url = "https://files.pythonhosted.org/packages/81/22/af5d926fc2c32a339eec00a443644bc40ab9db1dd2dd9017873c59773c0c/playwright-1.62.0-py3-none-win32.whl", hash = "sha256:e5614fa89355d7081457680324bb219f79f69c423c5cb6fa250e30b0d8aebf1c", size = 38164450, upload-time = "2026-07-31T17:01:04.187Z" }, + { url = "https://files.pythonhosted.org/packages/2b/a9/4160c1033c07af98bf841ad079457dd78408a5ee0dd56cbfe50b8b6a1c22/playwright-1.62.0-py3-none-win_amd64.whl", hash = "sha256:92c0d98ed04eb35af557b709875edba415b1f548bdb22ddb5bb3e1e6c835c2f1", size = 38164458, upload-time = "2026-07-31T17:01:08.459Z" }, + { url = "https://files.pythonhosted.org/packages/6c/ec/06b55d619a7082a766aa04f2c6bb31435c87f02930087d8a0517119408fa/playwright-1.62.0-py3-none-win_arm64.whl", hash = "sha256:ea8d3055aa9d5a9f1832ac82517bd8b42c78fac7ebcbebb0107116735c8cb6a1", size = 34208868, upload-time = "2026-07-31T17:01:11.818Z" }, +] + [[package]] name = "pluggy" version = "1.6.0" @@ -2377,6 +2475,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/4b/2d/69abac8f838090bbecd5df894befb2c2619e7996a98ddb949db9f3b93225/pydantic_core-2.46.4-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:d51026d73fcfd93610abc7b27789c26b313920fcfb20e27462d74a7f8b06e983", size = 2193071, upload-time = "2026-05-06T13:38:08.682Z" }, ] +[[package]] +name = "pyee" +version = "13.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8b/04/e7c1fe4dc78a6fdbfd6c337b1c3732ff543b8a397683ab38378447baa331/pyee-13.0.1.tar.gz", hash = "sha256:0b931f7c14535667ed4c7e0d531716368715e860b988770fc7eb8578d1f67fc8", size = 31655, upload-time = "2026-02-14T21:12:28.044Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/c4/b4d4827c93ef43c01f599ef31453ccc1c132b353284fc6c87d535c233129/pyee-13.0.1-py3-none-any.whl", hash = "sha256:af2f8fede4171ef667dfded53f96e2ed0d6e6bd7ee3bb46437f77e3b57689228", size = 15659, upload-time = "2026-02-14T21:12:26.263Z" }, +] + [[package]] name = "pygments" version = "2.20.0" From c0bb9fdf820e9c69d055fb960bfa3e4bf02302a6 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 6 Feb 2026 12:55:41 +0100 Subject: [PATCH 02/23] Tests: Add Playwright browser fixtures The browser is a headless Chromium shared across the session, with one isolated context per test. Chromium resolves *.localhost to loopback on its own so requests reach the k3d ingress the same way the aiohttp based tests do, and certificate validation is disabled as the test CA isn't in its trust store. --- tests/integration/fixtures/__init__.py | 3 +++ tests/integration/fixtures/playwright.py | 24 +++++++++++++++++++ .../lib/matrix_authentication_service.py | 8 +++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/integration/fixtures/playwright.py diff --git a/tests/integration/fixtures/__init__.py b/tests/integration/fixtures/__init__.py index af117fc8..b8cdc696 100644 --- a/tests/integration/fixtures/__init__.py +++ b/tests/integration/fixtures/__init__.py @@ -8,9 +8,12 @@ from .cluster import cert_manager, cluster, ess_namespace, helm_client, ingress, from .data import ESSData, generated_data from .helm import helm_prerequisites, ingress_ready, matrix_stack, secrets_generated from .matrix_tools import build_matrix_tools, loaded_matrix_tools +from .playwright import browser, browser_page from .users import User, users __all__ = [ + "browser", + "browser_page", "build_matrix_tools", "cert_manager", "cluster", diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py new file mode 100644 index 00000000..c67d5874 --- /dev/null +++ b/tests/integration/fixtures/playwright.py @@ -0,0 +1,24 @@ +# Copyright 2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +import pytest +from playwright.async_api import Browser, async_playwright + + +@pytest.fixture(scope="session") +async def browser(): + async with async_playwright() as playwright: + browser = await playwright.chromium.launch() + yield browser + await browser.close() + + +@pytest.fixture +async def browser_page(browser: Browser): + # The test CA isn't in the browser's trust store, so certificate validation is skipped. + # Chromium resolves *.localhost to the loopback address itself, which is where the ingress listens. + context = await browser.new_context(ignore_https_errors=True) + page = await context.new_page() + yield page + await context.close() diff --git a/tests/integration/lib/matrix_authentication_service.py b/tests/integration/lib/matrix_authentication_service.py index 8e182648..20c39242 100644 --- a/tests/integration/lib/matrix_authentication_service.py +++ b/tests/integration/lib/matrix_authentication_service.py @@ -9,6 +9,7 @@ from urllib.parse import urlparse import aiohttp import pytest from aiohttp_retry import RetryClient +from playwright.async_api import Page from ..fixtures import ESSData from .utils import aiohttp_get_json, aiohttp_post_json, retry_options @@ -135,3 +136,10 @@ async def create_mas_user( ) pytestconfig.cache.set(f"ess-helm/cached-tokens/{username}", response["data"]["createOauth2Session"]["accessToken"]) return response["data"]["createOauth2Session"]["accessToken"] + + +async def login_on_mas_page(page: Page, username: str, password: str): + """Fill and submit the MAS password login form the page is currently showing""" + await page.get_by_role("textbox", name="Username").fill(username) + await page.get_by_role("textbox", name="Password").fill(password) + await page.get_by_role("button", name="Continue").click() From 53400891e154e4c447e7a9d1a5a7f8573350a32a Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 6 Feb 2026 12:55:41 +0100 Subject: [PATCH 03/23] Tests: Add an environment with Element Web, Element Admin and MAS None of the existing environments deploy either client alongside MAS, so browser login tests would be skipped everywhere in CI. Well-known delegation is enabled as Element Admin discovers the homeserver from the server name. --- ...element-web-and-admin-with-mas-values.yaml | 90 +++++++++++++++++++ .../env/element-web-and-admin-with-mas.rc | 5 ++ 2 files changed, 95 insertions(+) create mode 100644 charts/matrix-stack/ci/pytest-element-web-and-admin-with-mas-values.yaml create mode 100644 tests/integration/env/element-web-and-admin-with-mas.rc diff --git a/charts/matrix-stack/ci/pytest-element-web-and-admin-with-mas-values.yaml b/charts/matrix-stack/ci/pytest-element-web-and-admin-with-mas-values.yaml new file mode 100644 index 00000000..5fd7c293 --- /dev/null +++ b/charts/matrix-stack/ci/pytest-element-web-and-admin-with-mas-values.yaml @@ -0,0 +1,90 @@ +# Copyright 2025-2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +# source_fragments: element-admin-minimal.yaml element-admin-pytest-extras.yaml element-web-minimal.yaml element-web-pytest-extras.yaml init-secrets-minimal.yaml init-secrets-pytest-extras.yaml matrix-authentication-service-minimal.yaml matrix-authentication-service-pytest-extras.yaml postgres-minimal.yaml server-name.yaml synapse-minimal.yaml synapse-pytest-base-extras.yaml well-known-minimal.yaml well-known-pytest-base-extras.yaml +# DO NOT EDIT DIRECTLY. Edit the fragment files to add / modify / remove values + +deploymentMarkers: + enabled: false +elementAdmin: + annotations: + has-no-service-monitor: "true" + ingress: + host: admin.{{ $.Values.serverName }} + tlsSecret: "{{ $.Release.Name }}-element-admin-tls" + podSecurityContext: + runAsGroup: 0 + replicas: 2 +elementWeb: + additional: + user-config.json: | + { + "default_server_config": { + "m.homeserver": { + "base_url": "https://synapse.{{ $.Values.serverName }}" + } + }, + "some_key": { + "some_value": "https://test.{{ $.Values.serverName }}" + } + } + annotations: + has-no-service-monitor: "true" + ingress: + host: element.{{ $.Values.serverName }} + tlsSecret: "{{ $.Release.Name }}-element-web-tls" + podSecurityContext: + runAsGroup: 0 + replicas: 2 +haproxy: + podSecurityContext: + runAsGroup: 0 + replicas: 2 +initSecrets: + annotations: + has-no-service-monitor: "true" + podSecurityContext: + runAsGroup: 0 +matrixAuthenticationService: + additional: + 000-pytest-admin: + configSecret: "{{ $.Release.Name }}-pytest-admin" + configSecretKey: "admin.yaml" + extraEnv: + - name: DEBUG_RENDERING + value: "1" + ingress: + host: mas.{{ $.Values.serverName }} + tlsSecret: "{{ $.Release.Name }}-mas-web-tls" + podSecurityContext: + runAsGroup: 0 + replicas: 2 + syn2mas: + extraEnv: + - name: DEBUG_RENDERING + value: "1" +matrixRTC: + enabled: false +postgres: + podSecurityContext: + runAsGroup: 0 +serverName: ess.localhost +synapse: + checkConfigHook: + annotations: + has-no-service-monitor: "true" + extraArgs: + # Validate that any Synapse config that has a _path equivalent uses it + - --no-secrets-in-config + extraEnv: + - name: DEBUG_RENDERING + value: "1" + ingress: + host: synapse.{{ $.Values.serverName }} + tlsSecret: "{{ $.Release.Name }}-synapse-web-tls" + podSecurityContext: + runAsGroup: 0 +wellKnownDelegation: + ingress: + tlsSecret: "{{ $.Release.Name }}-well-known-web-tls" diff --git a/tests/integration/env/element-web-and-admin-with-mas.rc b/tests/integration/env/element-web-and-admin-with-mas.rc new file mode 100644 index 00000000..fd2fa0e0 --- /dev/null +++ b/tests/integration/env/element-web-and-admin-with-mas.rc @@ -0,0 +1,5 @@ +# Copyright 2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +TEST_VALUES_FILE=charts/matrix-stack/ci/pytest-element-web-and-admin-with-mas-values.yaml From 693c088a1203b0a842ee46cbf04da897b6eca933 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 6 Feb 2026 12:55:41 +0100 Subject: [PATCH 04/23] Element Web: Test that it loads and can log in via MAS in a browser --- tests/integration/test_element_web.py | 40 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_element_web.py b/tests/integration/test_element_web.py index 14bd6270..66650b03 100644 --- a/tests/integration/test_element_web.py +++ b/tests/integration/test_element_web.py @@ -1,11 +1,15 @@ # Copyright 2024-2025 New Vector Ltd -# Copyright 2025 Element Creations Ltd +# Copyright 2025-2026 Element Creations Ltd # # SPDX-License-Identifier: AGPL-3.0-only -import pytest +import re -from .fixtures import ESSData +import pytest +from playwright.async_api import Page, expect + +from .fixtures import ESSData, User +from .lib.matrix_authentication_service import login_on_mas_page from .lib.utils import aiohttp_get_json, value_file_has @@ -17,3 +21,33 @@ async def test_element_web_can_access_config_json(ingress_ready, generated_data: json_content = await aiohttp_get_json(f"https://element.{generated_data.server_name}/config.json", {}, ssl_context) assert "some_key" in json_content assert json_content["some_key"]["some_value"] == f"https://test.{generated_data.server_name}" + + +@pytest.mark.skipif(value_file_has("elementWeb.enabled", False), reason="ElementWeb not deployed") +@pytest.mark.asyncio_cooperative +async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSData, browser_page: Page): + await ingress_ready("element-web") + + await browser_page.goto(f"https://element.{generated_data.server_name}/") + + await expect(browser_page).to_have_title(re.compile("Element")) + + +@pytest.mark.skipif(value_file_has("elementWeb.enabled", False), reason="ElementWeb not deployed") +@pytest.mark.skipif(value_file_has("matrixAuthenticationService.enabled", False), reason="MAS not deployed") +@pytest.mark.asyncio_cooperative +@pytest.mark.parametrize("users", [[User("browser-element-web-user")]], indirect=True) +async def test_element_web_login_via_mas(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): + await ingress_ready("element-web") + await ingress_ready("matrix-authentication-service") + + await browser_page.goto(f"https://element.{generated_data.server_name}/") + await browser_page.get_by_role("button", name="Continue").click() + await browser_page.wait_for_url(f"https://mas.{generated_data.server_name}/**") + + await login_on_mas_page(browser_page, users[0].name, generated_data.secrets_random) + + await expect(browser_page.get_by_role("heading")).to_contain_text("Continue to Element") + await browser_page.get_by_role("button", name="Continue").click() + + await browser_page.wait_for_url(f"https://element.{generated_data.server_name}/**") From d62cff743e401cb535ed81fd28e07c00146d13ef Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 6 Feb 2026 12:55:41 +0100 Subject: [PATCH 05/23] Element Admin: Test logging in via MAS in a browser Covers both an admin user reaching the dashboard and a regular user being rejected by the MAS policy. --- tests/integration/test_element_admin.py | 45 +++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_element_admin.py b/tests/integration/test_element_admin.py index cbf9a096..2ad813ff 100644 --- a/tests/integration/test_element_admin.py +++ b/tests/integration/test_element_admin.py @@ -1,12 +1,14 @@ # Copyright 2024-2025 New Vector Ltd -# Copyright 2025 Element Creations Ltd +# Copyright 2025-2026 Element Creations Ltd # # SPDX-License-Identifier: AGPL-3.0-only import pytest +from playwright.async_api import Page, expect -from .fixtures import ESSData +from .fixtures import ESSData, User +from .lib.matrix_authentication_service import login_on_mas_page from .lib.utils import aiohttp_client, value_file_has @@ -24,3 +26,42 @@ async def test_element_admin_can_access_root(ingress_ready, generated_data: ESSD ) as response, ): assert response.status == 200 + + +@pytest.mark.skipif(value_file_has("elementAdmin.enabled", False), reason="elementAdmin not deployed") +@pytest.mark.skipif(value_file_has("matrixAuthenticationService.enabled", False), reason="MAS not deployed") +@pytest.mark.asyncio_cooperative +@pytest.mark.parametrize("users", [[User("browser-admin-user", admin=True)]], indirect=True) +async def test_element_admin_login(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): + await ingress_ready("element-admin") + await ingress_ready("matrix-authentication-service") + + await browser_page.goto(f"https://admin.{generated_data.server_name}/") + await browser_page.get_by_role("button", name="Get started").click() + + await login_on_mas_page(browser_page, users[0].name, generated_data.secrets_random) + + await expect(browser_page.get_by_role("heading")).to_contain_text("Continue to Element Admin") + await browser_page.get_by_role("button", name="Continue").click() + + await expect(browser_page).to_have_title(f"Dashboard • {generated_data.server_name} • Element Admin") + + +@pytest.mark.skipif(value_file_has("elementAdmin.enabled", False), reason="elementAdmin not deployed") +@pytest.mark.skipif(value_file_has("matrixAuthenticationService.enabled", False), reason="MAS not deployed") +@pytest.mark.asyncio_cooperative +@pytest.mark.parametrize("users", [[User("browser-non-admin-user")]], indirect=True) +async def test_element_admin_login_rejects_non_admin( + ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User] +): + await ingress_ready("element-admin") + await ingress_ready("matrix-authentication-service") + + await browser_page.goto(f"https://admin.{generated_data.server_name}/") + await browser_page.get_by_role("button", name="Get started").click() + + await login_on_mas_page(browser_page, users[0].name, generated_data.secrets_random) + + await expect(browser_page.get_by_role("heading")).to_contain_text( + "The authorization request was denied by the policy enforced by this service" + ) From 0f420816978cdfaab7a5fc39bb4131ada461543e Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 25 Aug 2026 17:11:41 +0200 Subject: [PATCH 06/23] Newsfragment. --- newsfragments/1530.internal.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/1530.internal.md diff --git a/newsfragments/1530.internal.md b/newsfragments/1530.internal.md new file mode 100644 index 00000000..ce2585f1 --- /dev/null +++ b/newsfragments/1530.internal.md @@ -0,0 +1 @@ +Introduce basic end-to-end playwright tests. From f19ca2d1a4aae6d25fb294622c9b2d399f25879e Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Tue, 6 Oct 2026 15:51:20 +0000 Subject: [PATCH 07/23] Use a playwright controller -> browser in docker model --- .github/workflows/pytest.yml | 5 +- DEVELOPERS.md | 7 +- .../{1530.internal.md => 1636.internal.md} | 0 pyproject.toml | 6 + scripts/setup_playwright_controller.sh | 103 ++++++++++++++++++ tests/README.md | 6 +- tests/integration/docker/Dockerfile | 21 ++++ tests/integration/fixtures/playwright.py | 96 ++++++++++++++-- .../lib/matrix_authentication_service.py | 9 +- tests/pyproject.toml | 1 - uv.lock | 10 +- 11 files changed, 243 insertions(+), 21 deletions(-) rename newsfragments/{1530.internal.md => 1636.internal.md} (100%) create mode 100755 scripts/setup_playwright_controller.sh create mode 100644 tests/integration/docker/Dockerfile diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 0cb7d3b1..d014f2f9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -73,10 +73,7 @@ jobs: activate-environment: true - name: Set up UV environment - run: uv sync - - - name: Install Playwright browsers - run: uv run playwright install chromium --with-deps + run: uv sync --group browser - name: Get current week number and home dir id: cache-input diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 86f48c63..8497b2a1 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -165,7 +165,12 @@ Verifies that the deployed workloads behave as expected and integrates well toge From the project root : `pytest-ess` Some tests drive Element Web and Element Admin in a headless Chromium with [Playwright](https://playwright.dev/python/). -Install the browser once with `uv run playwright install chromium`. +The Chromium runs in a docker container. The Playwright controller runs on the host and drives it. +No browser needs to be installed locally. The docker image is built on first use. +On glibc hosts, install the controller with `uv sync --group browser`. +On musl hosts (e.g. Alpine Linux), Playwright has no packages. Run +`scripts/setup_playwright_controller.sh` instead: it installs the controller into `.venv`. +A plain `uv sync` removes the controller again: re-run the script afterwards. `uv run` keeps it. Pytest caches the namespace name and created user tokens between run. To start a run from scratch, run `pytest-ess -- --cache-clear`. diff --git a/newsfragments/1530.internal.md b/newsfragments/1636.internal.md similarity index 100% rename from newsfragments/1530.internal.md rename to newsfragments/1636.internal.md diff --git a/pyproject.toml b/pyproject.toml index b89dec56..cfab2715 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,12 @@ dependencies = [] [tool.uv] [dependency-groups] +# Playwright is optional. It publishes no packages for musl hosts (e.g. Alpine Linux), so +# it is not installed there by default. On glibc hosts, install it with +# `uv sync --group browser`. On musl hosts, run scripts/setup_playwright_controller.sh. +browser = [ + "playwright>=1.62.0", +] dev = [ "aiohttp>=3.14.3", "checkov>=3.2.530", diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh new file mode 100755 index 00000000..f8202858 --- /dev/null +++ b/scripts/setup_playwright_controller.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +# Copyright 2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +# Install the Playwright controller in the project's virtual environment (.venv), on musl +# hosts (e.g. Alpine Linux). On glibc hosts this script is not needed: `uv sync +# --group browser` installs playwright there. +# +# Playwright publishes no packages for musl. This script works around it: +# - it installs the playwright package as if the host was a glibc host. The package itself +# is plain Python, so it works anyway; +# - playwright also contains a helper program, the "node driver". This program needs +# glibc. The script copies the glibc files from the official Playwright docker image, +# and uses them to start the helper program. +# +# The browser is never installed on the host. The tests use a browser that runs in a +# docker container (see tests/integration/docker/Dockerfile). +# +# A plain `uv sync` removes playwright again. Re-run this script after it. `uv run` keeps +# playwright. + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT" + +libc_version="$(ldd --version 2>&1 | head -n1 || true)" +if [[ "$libc_version" != *musl* ]]; then + echo "glibc detected: 'uv sync --group browser' installs the playwright controller, nothing to do." + exit 0 +fi + +if [ "$(uname -m)" != "x86_64" ]; then + echo "unsupported architecture: $(uname -m), only x86_64 is supported" >&2 + exit 1 +fi + +uv sync +PYTHON=".venv/bin/python" +PYTHON_VERSION="$("$PYTHON" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" + +# Read the versions from uv.lock. The browser container uses the same playwright version. +lock_version() { + local name="name = \"$1\"" + awk -v want="$name" '$0 == want { getline; if ($1 != "version") exit 1; gsub(/"/, "", $3); print $3; exit }' uv.lock +} +PLAYWRIGHT_VERSION="$(lock_version playwright)" +GREENLET_VERSION="$(lock_version greenlet)" +PYEE_VERSION="$(lock_version pyee)" + +# Install playwright as if the host was a glibc host, with the version from uv.lock. +# Playwright needs two other packages, greenlet and pyee. They are installed after this. +# Playwright is always installed again, even when it is already there. This script changes +# a file inside the package (see below). uv stores packages in a shared cache. If a +# changed package stays in the cache, uv keeps copying it back into .venv. +install_playwright() { + uv pip install --python "$PYTHON" --python-platform x86_64-manylinux_2_40 \ + --python-version "$PYTHON_VERSION" --no-deps --reinstall-package playwright \ + "playwright==$PLAYWRIGHT_VERSION" +} +install_playwright +uv pip install --python "$PYTHON" "greenlet==$GREENLET_VERSION" "pyee==$PYEE_VERSION" + +DRIVER_DIR="$("$PYTHON" -c 'import playwright, pathlib; print(pathlib.Path(playwright.__file__).parent / "driver")')" +if [ "$(head -c 4 "$DRIVER_DIR/node" 2>/dev/null || true)" != $'\x7fELF' ]; then + # A changed file ended up in uv's cache. Empty the cache and install again. + uv cache clean playwright + install_playwright + DRIVER_DIR="$("$PYTHON" -c 'import playwright, pathlib; print(pathlib.Path(playwright.__file__).parent / "driver")')" +fi + +# Copy the glibc files from the official Playwright docker image, of the same playwright +# version. The helper program needs them to run. +GLIBC_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ess-helm/playwright-driver-glibc/$PLAYWRIGHT_VERSION" +if [ ! -f "$GLIBC_DIR/ld-linux-x86-64.so.2" ]; then + rm -rf "$GLIBC_DIR" + mkdir -p "$GLIBC_DIR" + docker run --rm --user "$(id -u):$(id -g)" -v "$GLIBC_DIR:/out" \ + --entrypoint /bin/bash "mcr.microsoft.com/playwright:v$PLAYWRIGHT_VERSION" \ + -c 'cp -L /usr/lib/x86_64-linux-gnu/{ld-linux-x86-64.so.2,libc.so.6,libm.so.6,libdl.so.2,libpthread.so.0,librt.so.1,libstdc++.so.6,libgcc_s.so.1,libresolv.so.2,libutil.so.1} /out/' +fi + +# Replace the helper program with a small script. The script starts the real program +# through the glibc files copied above. Installing playwright again restores the original +# program. Then this script must wrap it again. +# The new script is first written to a temporary file, then moved into place. This way the +# file in uv's cache is never changed. +if [ "$(head -c 4 "$DRIVER_DIR/node" 2>/dev/null || true)" = $'\x7fELF' ]; then + mv "$DRIVER_DIR/node" "$DRIVER_DIR/node.bin" +fi +printf '#!/bin/sh\nexec "%s/ld-linux-x86-64.so.2" --library-path "%s" "%s/node.bin" "$@"\n' \ + "$GLIBC_DIR" "$GLIBC_DIR" "$DRIVER_DIR" >"$DRIVER_DIR/node.wrapper" +mv "$DRIVER_DIR/node.wrapper" "$DRIVER_DIR/node" +chmod +x "$DRIVER_DIR/node" + +# Run the helper program once now. If something is broken, this script fails here with a +# clear error. Otherwise the tests would fail later, with a hard to understand error. +"$DRIVER_DIR/node" --version >/dev/null + +echo "Playwright $PLAYWRIGHT_VERSION controller installed in .venv." +echo "Note that a plain 'uv sync' removes it again: re-run this script afterwards." diff --git a/tests/README.md b/tests/README.md index 3fb9ac93..602b07c6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -19,9 +19,13 @@ The ESS Community Integration Tests project is designed to facilitate the testin - Docker - [k3d](https://k3d.io/stable/) - [Helm](https://helm.sh/docs/intro/install) -- A Chromium install for [Playwright](https://playwright.dev/python/), for the browser based tests: `playwright install chromium` - Optional: [uv](https://docs.astral.sh/uv/getting-started/installation/) to install from git +The browser based tests drive a Chromium running in a docker container, so no browser needs to be +installed locally. They need the optional `browser` dependency group. On glibc hosts, install it +with `uv sync --group browser`. On musl-based hosts (e.g. Alpine Linux), run +`scripts/setup_playwright_controller.sh` instead. Without it, the browser tests are skipped. + ## Installation diff --git a/tests/integration/docker/Dockerfile b/tests/integration/docker/Dockerfile new file mode 100644 index 00000000..16385b11 --- /dev/null +++ b/tests/integration/docker/Dockerfile @@ -0,0 +1,21 @@ +# Copyright 2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +# This image runs a Playwright browser server. The integration tests (fixtures/playwright.py) +# drive the Chromium inside it over a websocket. No browser has to be installed on the +# machine that runs the tests. + +ARG PLAYWRIGHT_VERSION +FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION} + +# The base image already contains the browser files of its own Playwright version. But it +# does not contain the playwright npm package. Install it, so that `launch-server` serves +# exactly those browser files. +# The version must be written again here: an ARG before FROM is only visible to FROM. +ARG PLAYWRIGHT_VERSION +RUN npm install --global playwright@${PLAYWRIGHT_VERSION} + +# The browser server prints its websocket address on stdout, e.g. +# ws://127.0.0.1:xxxx/ +CMD ["playwright", "launch-server", "--browser", "chromium"] diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index c67d5874..9a24f035 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -2,22 +2,102 @@ # # SPDX-License-Identifier: AGPL-3.0-only +import asyncio +import re +import time +from collections.abc import AsyncIterator +from importlib.metadata import version as package_version +from pathlib import Path +from typing import Any, cast + import pytest -from playwright.async_api import Browser, async_playwright +from python_on_whales import Container, docker + +try: + from playwright.async_api import Browser, async_playwright +except ImportError: + # Playwright is only installed in the development environment. `uv sync + # --group browser` installs it on glibc hosts, scripts/setup_playwright_controller.sh + # on musl ones. When it is missing, the browser tests are skipped instead of failing + # with an error. + Browser = None # type: ignore[assignment, misc] + async_playwright = None # type: ignore[assignment, misc] + +TESTS_DIR = Path(__file__).parent.parent.parent +DOCKERFILE = TESTS_DIR / "integration" / "docker" / "Dockerfile" + +# The browser server prints the websocket address it listens on, e.g. ws://127.0.0.1:xxxx/ +_WS_ENDPOINT_PATTERN = re.compile(r"ws://\S+") +_BROWSER_SERVER_STARTUP_TIMEOUT = 60 + + +def _require_controller() -> Any: + if async_playwright is None: + pytest.skip("playwright is not installed: see scripts/setup_playwright_controller.sh") + return async_playwright @pytest.fixture(scope="session") -async def browser(): - async with async_playwright() as playwright: - browser = await playwright.chromium.launch() - yield browser - await browser.close() +async def browser() -> AsyncIterator[Browser]: + """A Chromium running in a docker container. The tests talk to it over a websocket. + + The browser runs in a docker container, so nothing has to be installed on the host. + The tests also work on hosts where Playwright cannot install or run a browser locally + (e.g. Alpine Linux). The container uses the network of the host. So the browser can + reach the ingress on the loopback interface. And the tests can reach the browser + server's websocket address. + """ + controller = _require_controller() + playwright_version = package_version("playwright") + # The browser container must use the same playwright version as the controller. + # Otherwise they cannot talk to each other. + image_tag = f"ess-helm-playwright-browser:v{playwright_version}" + if not docker.image.exists(image_tag): + docker.build( + context_path=DOCKERFILE.parent, + file=DOCKERFILE, + tags=[image_tag], + build_args={"PLAYWRIGHT_VERSION": playwright_version}, + ) + container = docker.run( + image_tag, + detach=True, + init=True, + remove=True, + networks=["host"], + shm_size="1g", + ) + try: + ws_endpoint = await _wait_for_ws_endpoint(container) + async with controller() as playwright: + browser = await playwright.chromium.connect(ws_endpoint) + yield browser + await browser.close() + finally: + docker.container.remove(container, force=True) + + +async def _wait_for_ws_endpoint(container: Container) -> str: + deadline = time.monotonic() + _BROWSER_SERVER_STARTUP_TIMEOUT + while time.monotonic() < deadline: + if match := _WS_ENDPOINT_PATTERN.search(_container_logs(container)): + return match.group(0) + if not docker.container.inspect(container).state.running: + raise RuntimeError(f"browser server container exited:\n{_container_logs(container)}") + await asyncio.sleep(0.5) + raise TimeoutError(f"browser server did not print its websocket endpoint within {_BROWSER_SERVER_STARTUP_TIMEOUT}s") + + +def _container_logs(container: Container) -> str: + # python_on_whales says this function can also return another type. Here it always + # returns a string. + return cast("str", docker.container.logs(container)) @pytest.fixture async def browser_page(browser: Browser): - # The test CA isn't in the browser's trust store, so certificate validation is skipped. - # Chromium resolves *.localhost to the loopback address itself, which is where the ingress listens. + # The browser does not know the test CA. So it does not check the certificates. + # Chromium sends *.localhost names to the loopback address. The ingress listens there. context = await browser.new_context(ignore_https_errors=True) page = await context.new_page() yield page diff --git a/tests/integration/lib/matrix_authentication_service.py b/tests/integration/lib/matrix_authentication_service.py index 20c39242..43d21913 100644 --- a/tests/integration/lib/matrix_authentication_service.py +++ b/tests/integration/lib/matrix_authentication_service.py @@ -4,12 +4,17 @@ # SPDX-License-Identifier: AGPL-3.0-only from ssl import SSLContext +from typing import TYPE_CHECKING from urllib.parse import urlparse import aiohttp import pytest from aiohttp_retry import RetryClient -from playwright.async_api import Page + +# The import is only used in annotations. This way the tests can still be collected when +# playwright is not installed: the browser tests are then skipped. +if TYPE_CHECKING: + from playwright.async_api import Page from ..fixtures import ESSData from .utils import aiohttp_get_json, aiohttp_post_json, retry_options @@ -138,7 +143,7 @@ async def create_mas_user( return response["data"]["createOauth2Session"]["accessToken"] -async def login_on_mas_page(page: Page, username: str, password: str): +async def login_on_mas_page(page: "Page", username: str, password: str): """Fill and submit the MAS password login form the page is currently showing""" await page.get_by_role("textbox", name="Username").fill(username) await page.get_by_role("textbox", name="Password").fill(password) diff --git a/tests/pyproject.toml b/tests/pyproject.toml index 1248d411..56cacafc 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -19,7 +19,6 @@ dependencies = [ "jsonschema>=4.26.0", "lightkube>=1.0.0", "platformdirs>=4.9.2", - "playwright>=1.62.0", "prometheus-client>=0.26.0", "pyhelm3>=0.5.7", "pytest-asyncio-cooperative>=0.40.0", diff --git a/uv.lock b/uv.lock index 085813ed..65ea8948 100644 --- a/uv.lock +++ b/uv.lock @@ -846,6 +846,9 @@ version = "0.1.0" source = { virtual = "." } [package.dev-dependencies] +browser = [ + { name = "playwright" }, +] dev = [ { name = "aiohttp" }, { name = "checkov" }, @@ -878,6 +881,7 @@ dev = [ [package.metadata] [package.metadata.requires-dev] +browser = [{ name = "playwright", specifier = ">=1.62.0" }] dev = [ { name = "aiohttp", specifier = ">=3.14.3" }, { name = "checkov", specifier = ">=3.2.530" }, @@ -919,7 +923,6 @@ dependencies = [ { name = "jsonschema" }, { name = "lightkube" }, { name = "platformdirs" }, - { name = "playwright" }, { name = "prometheus-client" }, { name = "pyhelm3" }, { name = "pytest" }, @@ -943,7 +946,6 @@ requires-dist = [ { name = "jsonschema", specifier = ">=4.26.0" }, { name = "lightkube", specifier = ">=1.0.0" }, { name = "platformdirs", specifier = ">=4.9.2" }, - { name = "playwright", specifier = ">=1.62.0" }, { name = "prometheus-client", specifier = ">=0.26.0" }, { name = "pyhelm3", specifier = ">=0.5.7" }, { name = "pytest", specifier = ">=8.4.2,<9" }, @@ -1243,8 +1245,8 @@ name = "httpcore2" version = "2.12.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "h11" }, - { name = "truststore" }, + { name = "h11", marker = "python_full_version < '3.12' or python_full_version >= '3.14' or sys_platform != 'emscripten'" }, + { name = "truststore", marker = "python_full_version < '3.12' or python_full_version >= '3.14' or sys_platform != 'emscripten'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/be/ad/f4f0e57345f1870f3e8cb624e058d7eca6e5a27d33bcc3311d9b618734cd/httpcore2-2.12.0.tar.gz", hash = "sha256:9293522bba0aa7c4c8e9e3f040c16575bd8868e155a77fa30c7a9085a5eae648", size = 67548, upload-time = "2026-08-18T13:22:08.211Z" } wheels = [ From 7eaee807ad597c0dbf68664cf4f70e18e9705650 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 06:36:06 +0000 Subject: [PATCH 08/23] Fix test to latest element-admin version --- tests/integration/test_element_admin.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integration/test_element_admin.py b/tests/integration/test_element_admin.py index 2ad813ff..118c879f 100644 --- a/tests/integration/test_element_admin.py +++ b/tests/integration/test_element_admin.py @@ -62,6 +62,4 @@ async def test_element_admin_login_rejects_non_admin( await login_on_mas_page(browser_page, users[0].name, generated_data.secrets_random) - await expect(browser_page.get_by_role("heading")).to_contain_text( - "The authorization request was denied by the policy enforced by this service" - ) + await expect(browser_page.get_by_role("heading")).to_contain_text("Administrator access required") From e52100e1514039906060dd383f9d80df3dd1a9ff Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 06:50:46 +0000 Subject: [PATCH 09/23] Build the playwright image and cache in ghcr.io --- .github/workflows/pytest.yml | 68 +++++++++++++++++++ scripts/setup_playwright_controller.sh | 2 +- .../files/playwright}/Dockerfile | 9 +-- tests/integration/fixtures/playwright.py | 58 ++++++++++++---- 4 files changed, 118 insertions(+), 19 deletions(-) rename tests/integration/{docker => fixtures/files/playwright}/Dockerfile (80%) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index d014f2f9..b0f48648 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -46,6 +46,66 @@ jobs: LATEST_TAG=$(git describe --abbrev=0 --tags --match '[0-9]*.[0-9]*.[0-9]*') echo "upgradeFrom=$LATEST_TAG" | tee -a "$GITHUB_OUTPUT" + playwright-image: + runs-on: ubuntu-latest + # Build the playwright browser image and publish it to the registry. The integration + # tests use this image. fixtures/playwright.py computes its name and tag from the + # playwright version and the hash of the Dockerfile. A test run then downloads the image + # built from exactly its dependencies. Docker only uploads the parts that are not in the + # registry already. + # Pull requests from forks are skipped: their token is read-only, it cannot push to the + # registry. + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/ess-helm' }} + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install uv + uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + with: + # No cache. This job builds an image that other CI runs download. A bad cache must + # not break that image. + enable-cache: false + activate-environment: true + + - name: Set up UV environment + run: uv sync --group browser + + - name: Compute the image reference + # The tests and this job compute the image name and tag with the same function. The + # tests then download the image this job publishes + id: compute + run: | + echo "image=$(python -c 'from integration.fixtures.playwright import image_reference; print(image_reference())')" | tee -a "$GITHUB_OUTPUT" + echo "playwright-version=$(python -c 'from importlib.metadata import version; print(version("playwright"))')" | tee -a "$GITHUB_OUTPUT" + + - name: Login to GitHub Container Registry + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ghcr.io + username: ${{ env.GHCR_USERNAME }} + password: ${{ env.GHCR_TOKEN }} + + - name: Build the image + env: + IMAGE: ${{ steps.compute.outputs.image }} + PLAYWRIGHT_VERSION: ${{ steps.compute.outputs.playwright-version }} + run: docker build + --file tests/integration/fixtures/files/playwright/Dockerfile + --build-arg "PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" + --tag "${IMAGE}" + tests/integration/fixtures/files/playwright + + # Docker only uploads the parts that the registry does not have already + - name: Push the image + env: + IMAGE: ${{ steps.compute.outputs.image }} + run: docker push "${IMAGE}" + pytest-integration: runs-on: ubuntu-latest needs: pytest-setup @@ -104,6 +164,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + if: ${{ github.event.pull_request.head.repo.full_name == 'element-hq/ess-helm' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + with: + registry: ghcr.io + username: ${{ env.GHCR_USERNAME }} + password: ${{ env.GHCR_TOKEN }} + - uses: ./.github/actions/asdf-cache with: tool-versions: | diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh index f8202858..91711e8f 100755 --- a/scripts/setup_playwright_controller.sh +++ b/scripts/setup_playwright_controller.sh @@ -16,7 +16,7 @@ # and uses them to start the helper program. # # The browser is never installed on the host. The tests use a browser that runs in a -# docker container (see tests/integration/docker/Dockerfile). +# docker container (see tests/integration/fixtures/playwright.py). # # A plain `uv sync` removes playwright again. Re-run this script after it. `uv run` keeps # playwright. diff --git a/tests/integration/docker/Dockerfile b/tests/integration/fixtures/files/playwright/Dockerfile similarity index 80% rename from tests/integration/docker/Dockerfile rename to tests/integration/fixtures/files/playwright/Dockerfile index 16385b11..d51ffd69 100644 --- a/tests/integration/docker/Dockerfile +++ b/tests/integration/fixtures/files/playwright/Dockerfile @@ -10,12 +10,13 @@ ARG PLAYWRIGHT_VERSION FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION} # The base image already contains the browser files of its own Playwright version. But it -# does not contain the playwright npm package. Install it, so that `launch-server` serves -# exactly those browser files. +# does not contain the playwright npm package. Install it, so that `run-server` serves +# exactly those browser files. And nothing is downloaded through npx each time a container +# starts. # The version must be written again here: an ARG before FROM is only visible to FROM. ARG PLAYWRIGHT_VERSION RUN npm install --global playwright@${PLAYWRIGHT_VERSION} # The browser server prints its websocket address on stdout, e.g. -# ws://127.0.0.1:xxxx/ -CMD ["playwright", "launch-server", "--browser", "chromium"] +# ws://127.0.0.1:xxxx/ +CMD ["playwright", "run-server"] diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 9a24f035..4130e4bd 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only import asyncio +import hashlib import re import time from collections.abc import AsyncIterator @@ -23,14 +24,52 @@ except ImportError: Browser = None # type: ignore[assignment, misc] async_playwright = None # type: ignore[assignment, misc] -TESTS_DIR = Path(__file__).parent.parent.parent -DOCKERFILE = TESTS_DIR / "integration" / "docker" / "Dockerfile" +# The docker image the browser runs in. CI builds it and puts it in the registry under this +# name. The tag is computed by image_reference(). This way the tests can download the image +# instead of building it on every CI run. Hosts that cannot reach the registry build it +# locally, with the same name and tag. +IMAGE_NAME = "ghcr.io/element-hq/ess-helm/playwright-browser" +DOCKERFILE = Path(__file__).parent / "files" / "playwright" / "Dockerfile" # The browser server prints the websocket address it listens on, e.g. ws://127.0.0.1:xxxx/ _WS_ENDPOINT_PATTERN = re.compile(r"ws://\S+") _BROWSER_SERVER_STARTUP_TIMEOUT = 60 +def image_reference() -> str: + """The name and tag of the docker image the browser runs in. + + The tag says exactly what the image is built from: + - the playwright version. It sets the base image and the npm package the Dockerfile + installs on top of it; + - a hash of the Dockerfile. + So any change gives a new tag, and so a new image. + CI uses this same function to name the image it publishes. + """ + playwright_version = package_version("playwright") + dockerfile_hash = hashlib.sha256(DOCKERFILE.read_bytes()).hexdigest()[:12] + return f"{IMAGE_NAME}:v{playwright_version}-{dockerfile_hash}" + + +def _ensure_image() -> str: + """Make sure the browser image is on this machine: download it from the registry, or + build it when the download fails. That can happen when CI has not published the image + yet, or when this machine cannot log in to the registry (e.g. a CI run of a fork).""" + reference = image_reference() + if docker.image.exists(reference): + return reference + try: + docker.pull(reference) + except Exception: + docker.build( + context_path=DOCKERFILE.parent, + file=DOCKERFILE, + tags=[reference], + build_args={"PLAYWRIGHT_VERSION": package_version("playwright")}, + ) + return reference + + def _require_controller() -> Any: if async_playwright is None: pytest.skip("playwright is not installed: see scripts/setup_playwright_controller.sh") @@ -48,19 +87,10 @@ async def browser() -> AsyncIterator[Browser]: server's websocket address. """ controller = _require_controller() - playwright_version = package_version("playwright") - # The browser container must use the same playwright version as the controller. - # Otherwise they cannot talk to each other. - image_tag = f"ess-helm-playwright-browser:v{playwright_version}" - if not docker.image.exists(image_tag): - docker.build( - context_path=DOCKERFILE.parent, - file=DOCKERFILE, - tags=[image_tag], - build_args={"PLAYWRIGHT_VERSION": playwright_version}, - ) container = docker.run( - image_tag, + _ensure_image(), + # The start command of the image starts the browser server. The server prints its + # websocket address. It listens on a random port of the loopback interface. detach=True, init=True, remove=True, From 8e9f1136000f606948a1b879115bc85330c748ef Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 07:06:01 +0000 Subject: [PATCH 10/23] Load CA on image bootstrap --- .../fixtures/files/playwright/Dockerfile | 11 ++- .../files/playwright/start-browser-server.sh | 24 +++++++ tests/integration/fixtures/playwright.py | 69 ++++++++++++------- 3 files changed, 76 insertions(+), 28 deletions(-) create mode 100644 tests/integration/fixtures/files/playwright/start-browser-server.sh diff --git a/tests/integration/fixtures/files/playwright/Dockerfile b/tests/integration/fixtures/files/playwright/Dockerfile index d51ffd69..72c32638 100644 --- a/tests/integration/fixtures/files/playwright/Dockerfile +++ b/tests/integration/fixtures/files/playwright/Dockerfile @@ -17,6 +17,11 @@ FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION} ARG PLAYWRIGHT_VERSION RUN npm install --global playwright@${PLAYWRIGHT_VERSION} -# The browser server prints its websocket address on stdout, e.g. -# ws://127.0.0.1:xxxx/ -CMD ["playwright", "run-server"] +# certutil. The start script below uses it to install the test CA certificate in the browser. +RUN apt-get update \ + && apt-get install -y --no-install-recommends libnss3-tools \ + && rm -rf /var/lib/apt/lists/* + +COPY --chmod=755 start-browser-server.sh /usr/local/bin/start-browser-server + +CMD ["start-browser-server"] diff --git a/tests/integration/fixtures/files/playwright/start-browser-server.sh b/tests/integration/fixtures/files/playwright/start-browser-server.sh new file mode 100644 index 00000000..e1d0c846 --- /dev/null +++ b/tests/integration/fixtures/files/playwright/start-browser-server.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Copyright 2026 Element Creations Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +# Start the browser server. The integration tests (fixtures/playwright.py) drive it over a +# websocket. + +set -e + +# Install the test CA certificate in the browser. The tests mount it at /ess-helm-test-ca.pem. +# Chromium has no option to receive a CA certificate on the command line. And on Linux it does +# not use the certificates of the system: it only uses the certificates of its own database, +# in ~/.pki/nssdb. +# The CA is installed before the browser server starts. A browser that is already running +# may ignore new certificates. +mkdir -p "$HOME/.pki/nssdb" +# certutil -N creates a new database. It fails when the database already exists. That is fine. +certutil -N --empty-password -d "sql:$HOME/.pki/nssdb" || true +certutil -A -t "C,," -n ess-helm-test-ca -d "sql:$HOME/.pki/nssdb" -i /ess-helm-test-ca.pem + +# The browser server prints its websocket address on stdout, e.g. ws://127.0.0.1:xxxx/ +exec playwright run-server diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 4130e4bd..5c23d8e9 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -5,6 +5,7 @@ import asyncio import hashlib import re +import tempfile import time from collections.abc import AsyncIterator from importlib.metadata import version as package_version @@ -14,6 +15,8 @@ from typing import Any, cast import pytest from python_on_whales import Container, docker +from ..artifacts import CertKey + try: from playwright.async_api import Browser, async_playwright except ImportError: @@ -31,6 +34,10 @@ except ImportError: IMAGE_NAME = "ghcr.io/element-hq/ess-helm/playwright-browser" DOCKERFILE = Path(__file__).parent / "files" / "playwright" / "Dockerfile" +# The path where the test CA certificate is mounted in the container. The start script of +# the image installs it in the browser before the browser server starts (see the Dockerfile). +CA_MOUNT_PATH = "/ess-helm-test-ca.pem" + # The browser server prints the websocket address it listens on, e.g. ws://127.0.0.1:xxxx/ _WS_ENDPOINT_PATTERN = re.compile(r"ws://\S+") _BROWSER_SERVER_STARTUP_TIMEOUT = 60 @@ -42,13 +49,15 @@ def image_reference() -> str: The tag says exactly what the image is built from: - the playwright version. It sets the base image and the npm package the Dockerfile installs on top of it; - - a hash of the Dockerfile. + - a hash of the Dockerfile directory (the Dockerfile and the start script it copies). So any change gives a new tag, and so a new image. CI uses this same function to name the image it publishes. """ playwright_version = package_version("playwright") - dockerfile_hash = hashlib.sha256(DOCKERFILE.read_bytes()).hexdigest()[:12] - return f"{IMAGE_NAME}:v{playwright_version}-{dockerfile_hash}" + context_hash = hashlib.sha256( + b"".join(file.read_bytes() for file in sorted(DOCKERFILE.parent.iterdir()) if file.is_file()) + ).hexdigest()[:12] + return f"{IMAGE_NAME}:v{playwright_version}-{context_hash}" def _ensure_image() -> str: @@ -77,7 +86,7 @@ def _require_controller() -> Any: @pytest.fixture(scope="session") -async def browser() -> AsyncIterator[Browser]: +async def browser(root_ca: CertKey) -> AsyncIterator[Browser]: """A Chromium running in a docker container. The tests talk to it over a websocket. The browser runs in a docker container, so nothing has to be installed on the host. @@ -85,26 +94,35 @@ async def browser() -> AsyncIterator[Browser]: (e.g. Alpine Linux). The container uses the network of the host. So the browser can reach the ingress on the loopback interface. And the tests can reach the browser server's websocket address. + + The test CA signs the certificates of the ingress. It is mounted into the container. + The image installs it in the browser before the browser server starts. So the browser + accepts the certificates of the ingress. """ controller = _require_controller() - container = docker.run( - _ensure_image(), - # The start command of the image starts the browser server. The server prints its - # websocket address. It listens on a random port of the loopback interface. - detach=True, - init=True, - remove=True, - networks=["host"], - shm_size="1g", - ) - try: - ws_endpoint = await _wait_for_ws_endpoint(container) - async with controller() as playwright: - browser = await playwright.chromium.connect(ws_endpoint) - yield browser - await browser.close() - finally: - docker.container.remove(container, force=True) + with tempfile.TemporaryDirectory() as ca_dir: + ca_file = Path(ca_dir) / "ess-helm-test-ca.pem" + ca_file.write_text(root_ca.cert_as_pem()) + container = docker.run( + _ensure_image(), + # The start script of the image installs the mounted CA certificate in the + # browser. Then it starts the browser server. The server prints its websocket + # address. It listens on a random port of the loopback interface. + detach=True, + init=True, + remove=True, + networks=["host"], + shm_size="1g", + volumes=[(ca_file, CA_MOUNT_PATH, "ro")], + ) + try: + ws_endpoint = await _wait_for_ws_endpoint(container) + async with controller() as playwright: + browser = await playwright.chromium.connect(ws_endpoint) + yield browser + await browser.close() + finally: + docker.container.remove(container, force=True) async def _wait_for_ws_endpoint(container: Container) -> str: @@ -126,9 +144,10 @@ def _container_logs(container: Container) -> str: @pytest.fixture async def browser_page(browser: Browser): - # The browser does not know the test CA. So it does not check the certificates. - # Chromium sends *.localhost names to the loopback address. The ingress listens there. - context = await browser.new_context(ignore_https_errors=True) + # The browser knows the test CA (see the browser fixture). So it accepts the + # certificates of the ingress. Chromium sends *.localhost names to the loopback + # address. The ingress listens there. + context = await browser.new_context() page = await context.new_page() yield page await context.close() From 031b850c15e9205e2bab4f6c28819fa4bfedfb35 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 07:11:48 +0000 Subject: [PATCH 11/23] Use docker-bake --- .github/workflows/pytest.yml | 11 ++++++----- docker-bake.hcl | 12 +++++++++++- tests/integration/fixtures/playwright.py | 14 +++++++++----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b0f48648..5c05584d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -94,11 +94,12 @@ jobs: env: IMAGE: ${{ steps.compute.outputs.image }} PLAYWRIGHT_VERSION: ${{ steps.compute.outputs.playwright-version }} - run: docker build - --file tests/integration/fixtures/files/playwright/Dockerfile - --build-arg "PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" - --tag "${IMAGE}" - tests/integration/fixtures/files/playwright + run: docker buildx bake + --load + --file docker-bake.hcl + --set "*.tags=${IMAGE}" + --set "*.args.PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" + playwright-browser # Docker only uploads the parts that the registry does not have already - name: Push the image diff --git a/docker-bake.hcl b/docker-bake.hcl index 2aa68a53..9e903bf8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,5 +1,5 @@ // Copyright 2025 New Vector Ltd -// Copyright 2025 Element Creations Ltd +// Copyright 2025-2026 Element Creations Ltd // // SPDX-License-Identifier: AGPL-3.0-only @@ -11,3 +11,13 @@ target "matrix-tools" { dockerfile = "Dockerfile" context = "./matrix-tools" } + +// The image the browser server runs in. The integration tests drive it +// (tests/integration/fixtures/playwright.py). +// Unlike matrix-tools it does not inherit the metadata target: it is not published under +// the regular tags. Its name and tag are computed by image_reference(). The tests and CI +// pass them with --set when they build the image, together with the playwright version. +target "playwright-browser" { + dockerfile = "Dockerfile" + context = "./tests/integration/fixtures/files/playwright" +} diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 5c23d8e9..39222f8e 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -33,6 +33,7 @@ except ImportError: # locally, with the same name and tag. IMAGE_NAME = "ghcr.io/element-hq/ess-helm/playwright-browser" DOCKERFILE = Path(__file__).parent / "files" / "playwright" / "Dockerfile" +REPO_ROOT = Path(__file__).parent.parent.parent.parent.resolve() # The path where the test CA certificate is mounted in the container. The start script of # the image installs it in the browser before the browser server starts (see the Dockerfile). @@ -70,11 +71,14 @@ def _ensure_image() -> str: try: docker.pull(reference) except Exception: - docker.build( - context_path=DOCKERFILE.parent, - file=DOCKERFILE, - tags=[reference], - build_args={"PLAYWRIGHT_VERSION": package_version("playwright")}, + docker.buildx.bake( + files=REPO_ROOT / "docker-bake.hcl", + targets="playwright-browser", + set={ + "*.tags": reference, + "*.args.PLAYWRIGHT_VERSION": package_version("playwright"), + }, + load=True, ) return reference From 7ca5eab331c6e8cf21ef18174611b478286bfff7 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 07:49:42 +0000 Subject: [PATCH 12/23] Fix container logs --- tests/integration/fixtures/playwright.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 39222f8e..f8bbcb6e 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -10,7 +10,7 @@ import time from collections.abc import AsyncIterator from importlib.metadata import version as package_version from pathlib import Path -from typing import Any, cast +from typing import Any import pytest from python_on_whales import Container, docker @@ -132,20 +132,14 @@ async def browser(root_ca: CertKey) -> AsyncIterator[Browser]: async def _wait_for_ws_endpoint(container: Container) -> str: deadline = time.monotonic() + _BROWSER_SERVER_STARTUP_TIMEOUT while time.monotonic() < deadline: - if match := _WS_ENDPOINT_PATTERN.search(_container_logs(container)): + if match := _WS_ENDPOINT_PATTERN.search(container.logs()): return match.group(0) if not docker.container.inspect(container).state.running: - raise RuntimeError(f"browser server container exited:\n{_container_logs(container)}") + raise RuntimeError(f"browser server container exited:\n{container.logs()}") await asyncio.sleep(0.5) raise TimeoutError(f"browser server did not print its websocket endpoint within {_BROWSER_SERVER_STARTUP_TIMEOUT}s") -def _container_logs(container: Container) -> str: - # python_on_whales says this function can also return another type. Here it always - # returns a string. - return cast("str", docker.container.logs(container)) - - @pytest.fixture async def browser_page(browser: Browser): # The browser knows the test CA (see the browser fixture). So it accepts the From 38efa9d582c02723c860a6ab1caf10d79ac11d3b Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 08:04:25 +0000 Subject: [PATCH 13/23] Use the setup_playwright_controller.sh script on every hosts --- .github/workflows/pytest.yml | 4 +++- DEVELOPERS.md | 6 ++---- pyproject.toml | 5 +++-- scripts/setup_playwright_controller.sh | 15 ++++++++++----- tests/README.md | 5 ++--- tests/integration/fixtures/playwright.py | 9 ++++----- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5c05584d..5c51f828 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -134,7 +134,9 @@ jobs: activate-environment: true - name: Set up UV environment - run: uv sync --group browser + run: | + uv sync + scripts/setup_playwright_controller.sh - name: Get current week number and home dir id: cache-input diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 8497b2a1..fcd2000f 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -167,10 +167,8 @@ From the project root : `pytest-ess` Some tests drive Element Web and Element Admin in a headless Chromium with [Playwright](https://playwright.dev/python/). The Chromium runs in a docker container. The Playwright controller runs on the host and drives it. No browser needs to be installed locally. The docker image is built on first use. -On glibc hosts, install the controller with `uv sync --group browser`. -On musl hosts (e.g. Alpine Linux), Playwright has no packages. Run -`scripts/setup_playwright_controller.sh` instead: it installs the controller into `.venv`. -A plain `uv sync` removes the controller again: re-run the script afterwards. `uv run` keeps it. +Install the controller with `scripts/setup_playwright_controller.sh`, on every host (details in the +script). A plain `uv sync` removes the controller again: re-run the script afterwards. `uv run` keeps it. Pytest caches the namespace name and created user tokens between run. To start a run from scratch, run `pytest-ess -- --cache-clear`. diff --git a/pyproject.toml b/pyproject.toml index cfab2715..32cbe918 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,9 @@ dependencies = [] [tool.uv] [dependency-groups] # Playwright is optional. It publishes no packages for musl hosts (e.g. Alpine Linux), so -# it is not installed there by default. On glibc hosts, install it with -# `uv sync --group browser`. On musl hosts, run scripts/setup_playwright_controller.sh. +# it is not installed there by default. Install it with scripts/setup_playwright_controller.sh, +# on every host: on glibc hosts it runs `uv sync --group browser`, on musl hosts it uses a +# workaround (see the script header). browser = [ "playwright>=1.62.0", ] diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh index 91711e8f..4d67723b 100755 --- a/scripts/setup_playwright_controller.sh +++ b/scripts/setup_playwright_controller.sh @@ -4,11 +4,13 @@ # # SPDX-License-Identifier: AGPL-3.0-only -# Install the Playwright controller in the project's virtual environment (.venv), on musl -# hosts (e.g. Alpine Linux). On glibc hosts this script is not needed: `uv sync -# --group browser` installs playwright there. +# Install the Playwright controller in the project's virtual environment (.venv). +# Run this script on every host. # -# Playwright publishes no packages for musl. This script works around it: +# On glibc hosts it is simple: `uv sync --group browser` installs playwright. +# +# On musl hosts (e.g. Alpine Linux) this is not possible. Playwright publishes no packages +# for musl. This script works around it: # - it installs the playwright package as if the host was a glibc host. The package itself # is plain Python, so it works anyway; # - playwright also contains a helper program, the "node driver". This program needs @@ -28,7 +30,10 @@ cd "$ROOT" libc_version="$(ldd --version 2>&1 | head -n1 || true)" if [[ "$libc_version" != *musl* ]]; then - echo "glibc detected: 'uv sync --group browser' installs the playwright controller, nothing to do." + echo "glibc detected: installing the playwright controller with 'uv sync --group browser'." + uv sync --group browser + echo "Playwright controller installed in .venv." + echo "Note that a plain 'uv sync' removes it again: re-run this script afterwards." exit 0 fi diff --git a/tests/README.md b/tests/README.md index 602b07c6..0d26742e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -22,9 +22,8 @@ The ESS Community Integration Tests project is designed to facilitate the testin - Optional: [uv](https://docs.astral.sh/uv/getting-started/installation/) to install from git The browser based tests drive a Chromium running in a docker container, so no browser needs to be -installed locally. They need the optional `browser` dependency group. On glibc hosts, install it -with `uv sync --group browser`. On musl-based hosts (e.g. Alpine Linux), run -`scripts/setup_playwright_controller.sh` instead. Without it, the browser tests are skipped. +installed locally. They need the optional `browser` dependency group. Install it with +`scripts/setup_playwright_controller.sh`, on every host. Without it, the browser tests are skipped. ## Installation diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index f8bbcb6e..603e68cc 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -20,10 +20,9 @@ from ..artifacts import CertKey try: from playwright.async_api import Browser, async_playwright except ImportError: - # Playwright is only installed in the development environment. `uv sync - # --group browser` installs it on glibc hosts, scripts/setup_playwright_controller.sh - # on musl ones. When it is missing, the browser tests are skipped instead of failing - # with an error. + # Playwright is only installed in the development environment, by + # scripts/setup_playwright_controller.sh. When it is missing, the browser tests are + # skipped instead of failing with an error. Browser = None # type: ignore[assignment, misc] async_playwright = None # type: ignore[assignment, misc] @@ -85,7 +84,7 @@ def _ensure_image() -> str: def _require_controller() -> Any: if async_playwright is None: - pytest.skip("playwright is not installed: see scripts/setup_playwright_controller.sh") + pytest.skip("playwright is not installed: run scripts/setup_playwright_controller.sh") return async_playwright From 369696b7b565f5a940786bdeda3c174c1cf48e67 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 08:42:19 +0000 Subject: [PATCH 14/23] Simplify the setup playwright controller script by using system node --- scripts/setup_playwright_controller.sh | 67 +++++++++--------------- tests/integration/fixtures/playwright.py | 25 +++++++++ 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh index 4d67723b..54a83abb 100755 --- a/scripts/setup_playwright_controller.sh +++ b/scripts/setup_playwright_controller.sh @@ -13,9 +13,12 @@ # for musl. This script works around it: # - it installs the playwright package as if the host was a glibc host. The package itself # is plain Python, so it works anyway; -# - playwright also contains a helper program, the "node driver". This program needs -# glibc. The script copies the glibc files from the official Playwright docker image, -# and uses them to start the helper program. +# - playwright also contains a helper program, the "node driver". The package ships it as a +# glibc binary, which musl cannot run. The driver itself is plain JavaScript: the node of +# the system runs it too. The tests point playwright to it with the environment variable +# PLAYWRIGHT_NODEJS_PATH (see tests/integration/fixtures/playwright.py). The system node +# must be version 20 or newer. When it is missing, the script installs the "nodejs" +# package of the system (this needs Alpine Linux and root rights). # # The browser is never installed on the host. The tests use a browser that runs in a # docker container (see tests/integration/fixtures/playwright.py). @@ -42,6 +45,20 @@ if [ "$(uname -m)" != "x86_64" ]; then exit 1 fi +# The node driver needs node 20 or newer. Use the node of the system. Install the system +# package when there is none. +NODE_BIN="$(command -v node || true)" +if [ -z "$NODE_BIN" ]; then + echo "node not found: installing the system package with 'apk add nodejs'." + apk add --no-cache nodejs + NODE_BIN="$(command -v node)" +fi +NODE_MAJOR="$(node --version | sed 's/^v//' | cut -d. -f1)" +if [ "$NODE_MAJOR" -lt 20 ]; then + echo "node $NODE_MAJOR is too old: the playwright node driver needs node 20 or newer" >&2 + exit 1 +fi + uv sync PYTHON=".venv/bin/python" PYTHON_VERSION="$("$PYTHON" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" @@ -57,9 +74,8 @@ PYEE_VERSION="$(lock_version pyee)" # Install playwright as if the host was a glibc host, with the version from uv.lock. # Playwright needs two other packages, greenlet and pyee. They are installed after this. -# Playwright is always installed again, even when it is already there. This script changes -# a file inside the package (see below). uv stores packages in a shared cache. If a -# changed package stays in the cache, uv keeps copying it back into .venv. +# Playwright is always installed again, even when it is already there. This restores the +# original files, in case an older version of this script replaced them. install_playwright() { uv pip install --python "$PYTHON" --python-platform x86_64-manylinux_2_40 \ --python-version "$PYTHON_VERSION" --no-deps --reinstall-package playwright \ @@ -68,41 +84,10 @@ install_playwright() { install_playwright uv pip install --python "$PYTHON" "greenlet==$GREENLET_VERSION" "pyee==$PYEE_VERSION" -DRIVER_DIR="$("$PYTHON" -c 'import playwright, pathlib; print(pathlib.Path(playwright.__file__).parent / "driver")')" -if [ "$(head -c 4 "$DRIVER_DIR/node" 2>/dev/null || true)" != $'\x7fELF' ]; then - # A changed file ended up in uv's cache. Empty the cache and install again. - uv cache clean playwright - install_playwright - DRIVER_DIR="$("$PYTHON" -c 'import playwright, pathlib; print(pathlib.Path(playwright.__file__).parent / "driver")')" -fi - -# Copy the glibc files from the official Playwright docker image, of the same playwright -# version. The helper program needs them to run. -GLIBC_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ess-helm/playwright-driver-glibc/$PLAYWRIGHT_VERSION" -if [ ! -f "$GLIBC_DIR/ld-linux-x86-64.so.2" ]; then - rm -rf "$GLIBC_DIR" - mkdir -p "$GLIBC_DIR" - docker run --rm --user "$(id -u):$(id -g)" -v "$GLIBC_DIR:/out" \ - --entrypoint /bin/bash "mcr.microsoft.com/playwright:v$PLAYWRIGHT_VERSION" \ - -c 'cp -L /usr/lib/x86_64-linux-gnu/{ld-linux-x86-64.so.2,libc.so.6,libm.so.6,libdl.so.2,libpthread.so.0,librt.so.1,libstdc++.so.6,libgcc_s.so.1,libresolv.so.2,libutil.so.1} /out/' -fi - -# Replace the helper program with a small script. The script starts the real program -# through the glibc files copied above. Installing playwright again restores the original -# program. Then this script must wrap it again. -# The new script is first written to a temporary file, then moved into place. This way the -# file in uv's cache is never changed. -if [ "$(head -c 4 "$DRIVER_DIR/node" 2>/dev/null || true)" = $'\x7fELF' ]; then - mv "$DRIVER_DIR/node" "$DRIVER_DIR/node.bin" -fi -printf '#!/bin/sh\nexec "%s/ld-linux-x86-64.so.2" --library-path "%s" "%s/node.bin" "$@"\n' \ - "$GLIBC_DIR" "$GLIBC_DIR" "$DRIVER_DIR" >"$DRIVER_DIR/node.wrapper" -mv "$DRIVER_DIR/node.wrapper" "$DRIVER_DIR/node" -chmod +x "$DRIVER_DIR/node" - -# Run the helper program once now. If something is broken, this script fails here with a -# clear error. Otherwise the tests would fail later, with a hard to understand error. -"$DRIVER_DIR/node" --version >/dev/null +# Run the node driver once now, with the same environment variable as the tests. If +# something is broken, this script fails here with a clear error. Otherwise the tests +# would fail later, with a hard to understand error. +PLAYWRIGHT_NODEJS_PATH="$NODE_BIN" "$PYTHON" -m playwright --version >/dev/null echo "Playwright $PLAYWRIGHT_VERSION controller installed in .venv." echo "Note that a plain 'uv sync' removes it again: re-run this script afterwards." diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 603e68cc..98b7f5d3 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -4,7 +4,10 @@ import asyncio import hashlib +import os import re +import shutil +import sys import tempfile import time from collections.abc import AsyncIterator @@ -82,9 +85,31 @@ def _ensure_image() -> str: return reference +def _set_playwright_node() -> None: + """Configure which node version to use on the controller. + + Playwright ships its node driver as a glibc binary. On musl hosts (e.g. Alpine Linux) + that binary cannot run. The driver itself is plain JavaScript: a node of the system + runs it too. Playwright reads the node path from the PLAYWRIGHT_NODEJS_PATH + environment variable. The setup script checks that the node is new enough. + """ + if sys.platform != "linux" or "PLAYWRIGHT_NODEJS_PATH" in os.environ: + return + try: + os.confstr("CS_GNU_LIBC_VERSION") # works only on a glibc host + except OSError: + pass # musl host: the bundled node cannot run + else: + return # glibc host: the bundled node runs + node = shutil.which("node") + if node is not None: + os.environ["PLAYWRIGHT_NODEJS_PATH"] = node + + def _require_controller() -> Any: if async_playwright is None: pytest.skip("playwright is not installed: run scripts/setup_playwright_controller.sh") + _set_playwright_node() return async_playwright From 7924ae860398816d221bdbc81d30217c6a5de45a Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 08:47:21 +0000 Subject: [PATCH 15/23] Read playwright versions & its dependencies using uv export --- scripts/setup_playwright_controller.sh | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh index 54a83abb..3f9fe8d5 100755 --- a/scripts/setup_playwright_controller.sh +++ b/scripts/setup_playwright_controller.sh @@ -63,26 +63,27 @@ uv sync PYTHON=".venv/bin/python" PYTHON_VERSION="$("$PYTHON" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" -# Read the versions from uv.lock. The browser container uses the same playwright version. -lock_version() { - local name="name = \"$1\"" - awk -v want="$name" '$0 == want { getline; if ($1 != "version") exit 1; gsub(/"/, "", $3); print $3; exit }' uv.lock +# Read the pinned versions from uv.lock with `uv export`. The browser container uses the +# same playwright version. +browser_requirements="$(uv export --only-group browser --locked --no-hashes \ + --no-emit-project --format requirements-txt)" +# uv export prints one "name==version" line per package. +package_version() { + sed -n "s/^$1==//p" <<<"$browser_requirements" } -PLAYWRIGHT_VERSION="$(lock_version playwright)" -GREENLET_VERSION="$(lock_version greenlet)" -PYEE_VERSION="$(lock_version pyee)" +PLAYWRIGHT_VERSION="$(package_version playwright)" +if [ -z "$PLAYWRIGHT_VERSION" ]; then + echo "playwright not found in uv.lock" >&2 + exit 1 +fi -# Install playwright as if the host was a glibc host, with the version from uv.lock. -# Playwright needs two other packages, greenlet and pyee. They are installed after this. +# Install the browser group as if the host was a glibc host, with the versions from +# uv.lock. This also installs the packages playwright needs: greenlet and pyee. # Playwright is always installed again, even when it is already there. This restores the # original files, in case an older version of this script replaced them. -install_playwright() { - uv pip install --python "$PYTHON" --python-platform x86_64-manylinux_2_40 \ - --python-version "$PYTHON_VERSION" --no-deps --reinstall-package playwright \ - "playwright==$PLAYWRIGHT_VERSION" -} -install_playwright -uv pip install --python "$PYTHON" "greenlet==$GREENLET_VERSION" "pyee==$PYEE_VERSION" +uv pip install --python "$PYTHON" --python-platform x86_64-manylinux_2_40 \ + --python-version "$PYTHON_VERSION" --reinstall-package playwright \ + -r <(printf '%s\n' "$browser_requirements") # Run the node driver once now, with the same environment variable as the tests. If # something is broken, this script fails here with a clear error. Otherwise the tests From aabe6694c82f061ed6a64bdfcad1b1b789643768 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 08:57:37 +0000 Subject: [PATCH 16/23] Actively wait for the ws connection to succeed --- tests/integration/fixtures/playwright.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 98b7f5d3..bcd6e223 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -144,24 +144,38 @@ async def browser(root_ca: CertKey) -> AsyncIterator[Browser]: volumes=[(ca_file, CA_MOUNT_PATH, "ro")], ) try: - ws_endpoint = await _wait_for_ws_endpoint(container) async with controller() as playwright: - browser = await playwright.chromium.connect(ws_endpoint) + browser = await _wait_for_browser(playwright, container) yield browser await browser.close() finally: docker.container.remove(container, force=True) -async def _wait_for_ws_endpoint(container: Container) -> str: +async def _wait_for_browser(playwright: Any, container: Container) -> Browser: + """A connection to the browser server in the container. + + The websocket address is read from the container logs. The server prints it, and its + random path is not known otherwise. The printed line alone does not prove that the + server accepts connections. So the connection is the real test: it is retried + until the server accepts it, and the last error is reported when it never does. + """ deadline = time.monotonic() + _BROWSER_SERVER_STARTUP_TIMEOUT + last_error: Exception | None = None while time.monotonic() < deadline: if match := _WS_ENDPOINT_PATTERN.search(container.logs()): - return match.group(0) + try: + return await playwright.chromium.connect(match.group(0), timeout=2000) + except Exception as error: + # The server printed its address but refused the connection. It may + # not be ready yet. Try again until the deadline. + last_error = error if not docker.container.inspect(container).state.running: raise RuntimeError(f"browser server container exited:\n{container.logs()}") await asyncio.sleep(0.5) - raise TimeoutError(f"browser server did not print its websocket endpoint within {_BROWSER_SERVER_STARTUP_TIMEOUT}s") + raise TimeoutError( + f"could not connect to the browser server within {_BROWSER_SERVER_STARTUP_TIMEOUT}s: {last_error}" + ) @pytest.fixture From 6e1de41b7f3ce857ac95be6d933e2be0657775d4 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 09:22:26 +0000 Subject: [PATCH 17/23] Sync playwright in linting steps --- .github/workflows/releasing.yml | 6 ++++-- .github/workflows/scripts-linting.yml | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/releasing.yml b/.github/workflows/releasing.yml index 069e52e2..18f86070 100644 --- a/.github/workflows/releasing.yml +++ b/.github/workflows/releasing.yml @@ -34,7 +34,9 @@ jobs: activate-environment: true - name: Set up UV environment - run: uv sync --all-packages + run: | + uv sync --all-packages + scripts/setup_playwright_controller.sh - name: Set version env: @@ -51,7 +53,7 @@ jobs: # Check that basic features work and we didn't miss to include crucial files - name: Smoke test (source distribution) - run: uv run --isolated --no-project --with dist/*.tar.gz pytest-ess --test-suite synapse -- --setup-plan + run: uv run --isolated --group browser --with dist/*.tar.gz pytest-ess --test-suite synapse -- --setup-plan - name: Dry-run Publish ESS test suite to PyPI run: uv publish --dry-run dist/* diff --git a/.github/workflows/scripts-linting.yml b/.github/workflows/scripts-linting.yml index 4f706a6e..468173c7 100644 --- a/.github/workflows/scripts-linting.yml +++ b/.github/workflows/scripts-linting.yml @@ -43,7 +43,9 @@ jobs: activate-environment: true - name: Set up UV environment - run: uv sync --all-packages + run: | + uv sync + scripts/setup_playwright_controller.sh - name: Run ruff check run: | From b96823489632f4927102fb6e3f1dd610c4f49a02 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 09:40:03 +0000 Subject: [PATCH 18/23] The script should also work on arm64 --- scripts/setup_playwright_controller.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/setup_playwright_controller.sh b/scripts/setup_playwright_controller.sh index 3f9fe8d5..f187ff48 100755 --- a/scripts/setup_playwright_controller.sh +++ b/scripts/setup_playwright_controller.sh @@ -40,10 +40,16 @@ if [[ "$libc_version" != *musl* ]]; then exit 0 fi -if [ "$(uname -m)" != "x86_64" ]; then - echo "unsupported architecture: $(uname -m), only x86_64 is supported" >&2 +# Playwright publishes no musl wheels. This script installs the glibc wheels instead, so +# the platform tag must match the architecture of the host. The glibc version is left +# open: uv then picks the matching wheel, whatever manylinux version it is built for. +# uv names both supported architectures the same as uname -m does. +arch="$(uname -m)" +if [[ "$arch" != "x86_64" && "$arch" != "aarch64" ]]; then + echo "unsupported architecture: $arch, only x86_64 and aarch64 are supported" >&2 exit 1 fi +wheel_platform="${arch}-unknown-linux-gnu" # The node driver needs node 20 or newer. Use the node of the system. Install the system # package when there is none. @@ -81,7 +87,7 @@ fi # uv.lock. This also installs the packages playwright needs: greenlet and pyee. # Playwright is always installed again, even when it is already there. This restores the # original files, in case an older version of this script replaced them. -uv pip install --python "$PYTHON" --python-platform x86_64-manylinux_2_40 \ +uv pip install --python "$PYTHON" --python-platform "$wheel_platform" \ --python-version "$PYTHON_VERSION" --reinstall-package playwright \ -r <(printf '%s\n' "$browser_requirements") From fd4aa52f70a8bd6734faa87dfe209f24489bd964 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 13:31:26 +0000 Subject: [PATCH 19/23] Use GHA High level action for docker bake --- .github/workflows/pytest.yml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5c51f828..2d00f9b0 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -83,6 +83,9 @@ jobs: echo "image=$(python -c 'from integration.fixtures.playwright import image_reference; print(image_reference())')" | tee -a "$GITHUB_OUTPUT" echo "playwright-version=$(python -c 'from importlib.metadata import version; print(version("playwright"))')" | tee -a "$GITHUB_OUTPUT" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + - name: Login to GitHub Container Registry uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: @@ -90,22 +93,15 @@ jobs: username: ${{ env.GHCR_USERNAME }} password: ${{ env.GHCR_TOKEN }} - - name: Build the image - env: - IMAGE: ${{ steps.compute.outputs.image }} - PLAYWRIGHT_VERSION: ${{ steps.compute.outputs.playwright-version }} - run: docker buildx bake - --load - --file docker-bake.hcl - --set "*.tags=${IMAGE}" - --set "*.args.PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" - playwright-browser - - # Docker only uploads the parts that the registry does not have already - - name: Push the image - env: - IMAGE: ${{ steps.compute.outputs.image }} - run: docker push "${IMAGE}" + - name: Build and push the image + uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0 + with: + push: true + files: docker-bake.hcl + targets: playwright-browser + set: | + *.tags=${{ steps.compute.outputs.image }} + *.args.PLAYWRIGHT_VERSION=${{ steps.compute.outputs.playwright-version }} pytest-integration: runs-on: ubuntu-latest From e4a7d342fe65c01f1c49513b124902f7036af981 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 14:20:05 +0000 Subject: [PATCH 20/23] Add back --no-project, dont run playwright tests in external tool call --- .github/workflows/releasing.yml | 11 ++++++----- tests/integration/test_element_admin.py | 10 +++++++++- tests/integration/test_element_web.py | 10 +++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/releasing.yml b/.github/workflows/releasing.yml index 18f86070..6466926e 100644 --- a/.github/workflows/releasing.yml +++ b/.github/workflows/releasing.yml @@ -34,9 +34,7 @@ jobs: activate-environment: true - name: Set up UV environment - run: | - uv sync --all-packages - scripts/setup_playwright_controller.sh + run: uv sync --all-packages - name: Set version env: @@ -51,9 +49,12 @@ jobs: - name: Build run: uv build --package ess-community-integration-tests - # Check that basic features work and we didn't miss to include crucial files + # Check that basic features work and we didn't miss to include crucial files. + # This installs the package the same way a consumer does: from the source + # distribution only, without the development environment and without the optional + # playwright dependency. The browser tests are skipped in that case. - name: Smoke test (source distribution) - run: uv run --isolated --group browser --with dist/*.tar.gz pytest-ess --test-suite synapse -- --setup-plan + run: uv run --isolated --no-project --with dist/*.tar.gz pytest-ess --test-suite synapse -- --setup-plan - name: Dry-run Publish ESS test suite to PyPI run: uv publish --dry-run dist/* diff --git a/tests/integration/test_element_admin.py b/tests/integration/test_element_admin.py index 118c879f..3050766c 100644 --- a/tests/integration/test_element_admin.py +++ b/tests/integration/test_element_admin.py @@ -5,7 +5,15 @@ import pytest -from playwright.async_api import Page, expect + +# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When +# it is missing, the browser tests are skipped by the browser_page fixture. The imports +# must not fail here: otherwise pytest cannot collect the tests of this file at all. +try: + from playwright.async_api import Page, expect +except ImportError: + Page = None # type: ignore[assignment, misc] + expect = None # type: ignore[assignment, misc] from .fixtures import ESSData, User from .lib.matrix_authentication_service import login_on_mas_page diff --git a/tests/integration/test_element_web.py b/tests/integration/test_element_web.py index 66650b03..0346e4f8 100644 --- a/tests/integration/test_element_web.py +++ b/tests/integration/test_element_web.py @@ -6,7 +6,15 @@ import re import pytest -from playwright.async_api import Page, expect + +# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When +# it is missing, the browser tests are skipped by the browser_page fixture. The imports +# must not fail here: otherwise pytest cannot collect the tests of this file at all. +try: + from playwright.async_api import Page, expect +except ImportError: + Page = None # type: ignore[assignment, misc] + expect = None # type: ignore[assignment, misc] from .fixtures import ESSData, User from .lib.matrix_authentication_service import login_on_mas_page From 96911d886bbe764b9bc72eb21e682f3426ae69eb Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Wed, 7 Oct 2026 14:27:51 +0000 Subject: [PATCH 21/23] Allow to install playwright when setting up ess-community-integration-tests externally --- tests/README.md | 15 +++++++++++++-- tests/integration/test_element_admin.py | 25 ++++++++++++++++--------- tests/integration/test_element_web.py | 24 +++++++++++++++--------- tests/pyproject.toml | 9 +++++++++ uv.lock | 7 +++++++ 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/tests/README.md b/tests/README.md index 0d26742e..649fa53d 100644 --- a/tests/README.md +++ b/tests/README.md @@ -22,8 +22,12 @@ The ESS Community Integration Tests project is designed to facilitate the testin - Optional: [uv](https://docs.astral.sh/uv/getting-started/installation/) to install from git The browser based tests drive a Chromium running in a docker container, so no browser needs to be -installed locally. They need the optional `browser` dependency group. Install it with -`scripts/setup_playwright_controller.sh`, on every host. Without it, the browser tests are skipped. +installed locally. They need the optional Playwright controller: +- On glibc hosts, install it with the `browser` extra, e.g. `pipx install ess-community-integration-tests[browser]`. +- On musl hosts (e.g. Alpine Linux), Playwright publishes no packages: install it with + `scripts/setup_playwright_controller.sh` instead. + +Without it, the browser tests are skipped. ## Installation @@ -33,6 +37,13 @@ pipx install ess-community-integration-tests uvx ess-community-integration-tests ``` +To also run the browser based tests, install the `browser` extra: + +```sh +pipx install ess-community-integration-tests[browser] +uvx --from 'ess-community-integration-tests[browser]' pytest-ess +``` + You can also install it from the git repository : ```sh diff --git a/tests/integration/test_element_admin.py b/tests/integration/test_element_admin.py index 3050766c..33b11dc7 100644 --- a/tests/integration/test_element_admin.py +++ b/tests/integration/test_element_admin.py @@ -4,21 +4,24 @@ # SPDX-License-Identifier: AGPL-3.0-only -import pytest +# Annotations are stored as text and not evaluated when this file is imported. +# This allows the type-checking-only `Page` import below, even when playwright is missing. +# Python 3.14 behaves like this by default; this is a backport for older versions. +from __future__ import annotations -# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When -# it is missing, the browser tests are skipped by the browser_page fixture. The imports -# must not fail here: otherwise pytest cannot collect the tests of this file at all. -try: - from playwright.async_api import Page, expect -except ImportError: - Page = None # type: ignore[assignment, misc] - expect = None # type: ignore[assignment, misc] +from typing import TYPE_CHECKING + +import pytest from .fixtures import ESSData, User from .lib.matrix_authentication_service import login_on_mas_page from .lib.utils import aiohttp_client, value_file_has +# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When +# it is missing, the browser tests are skipped by the browser_page fixture. +if TYPE_CHECKING: + from playwright.async_api import Page + @pytest.mark.skipif(value_file_has("elementAdmin.enabled", False), reason="elementAdmin not deployed") @pytest.mark.asyncio_cooperative @@ -41,6 +44,8 @@ async def test_element_admin_can_access_root(ingress_ready, generated_data: ESSD @pytest.mark.asyncio_cooperative @pytest.mark.parametrize("users", [[User("browser-admin-user", admin=True)]], indirect=True) async def test_element_admin_login(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): + from playwright.async_api import expect + await ingress_ready("element-admin") await ingress_ready("matrix-authentication-service") @@ -62,6 +67,8 @@ async def test_element_admin_login(ingress_ready, generated_data: ESSData, brows async def test_element_admin_login_rejects_non_admin( ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User] ): + from playwright.async_api import expect + await ingress_ready("element-admin") await ingress_ready("matrix-authentication-service") diff --git a/tests/integration/test_element_web.py b/tests/integration/test_element_web.py index 0346e4f8..072c5d1d 100644 --- a/tests/integration/test_element_web.py +++ b/tests/integration/test_element_web.py @@ -3,23 +3,25 @@ # # SPDX-License-Identifier: AGPL-3.0-only +# Annotations are stored as text and not evaluated when this file is imported. +# This allows the type-checking-only `Page` import below, even when playwright is missing. +# Python 3.14 behaves like this by default; this is a backport for older versions. +from __future__ import annotations + import re +from typing import TYPE_CHECKING import pytest -# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When -# it is missing, the browser tests are skipped by the browser_page fixture. The imports -# must not fail here: otherwise pytest cannot collect the tests of this file at all. -try: - from playwright.async_api import Page, expect -except ImportError: - Page = None # type: ignore[assignment, misc] - expect = None # type: ignore[assignment, misc] - from .fixtures import ESSData, User from .lib.matrix_authentication_service import login_on_mas_page from .lib.utils import aiohttp_get_json, value_file_has +# Playwright is optional: it is installed by scripts/setup_playwright_controller.sh. When +# it is missing, the browser tests are skipped by the browser_page fixture. +if TYPE_CHECKING: + from playwright.async_api import Page + @pytest.mark.skipif(value_file_has("elementWeb.enabled", False), reason="ElementWeb not deployed") @pytest.mark.asyncio_cooperative @@ -34,6 +36,8 @@ async def test_element_web_can_access_config_json(ingress_ready, generated_data: @pytest.mark.skipif(value_file_has("elementWeb.enabled", False), reason="ElementWeb not deployed") @pytest.mark.asyncio_cooperative async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSData, browser_page: Page): + from playwright.async_api import expect + await ingress_ready("element-web") await browser_page.goto(f"https://element.{generated_data.server_name}/") @@ -46,6 +50,8 @@ async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSDa @pytest.mark.asyncio_cooperative @pytest.mark.parametrize("users", [[User("browser-element-web-user")]], indirect=True) async def test_element_web_login_via_mas(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): + from playwright.async_api import expect + await ingress_ready("element-web") await ingress_ready("matrix-authentication-service") diff --git a/tests/pyproject.toml b/tests/pyproject.toml index 56cacafc..fabe389c 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -33,6 +33,15 @@ dependencies = [ "typer>=0.27.1", ] +# Playwright is optional: it publishes no packages for musl hosts (e.g. Alpine Linux). +# On glibc hosts, consumers can install it with this extra: +# pip install ess-community-integration-tests[browser] +# On musl hosts, use scripts/setup_playwright_controller.sh instead (see its header). +[project.optional-dependencies] +browser = [ + "playwright>=1.62.0", +] + [tool.uv.build-backend] module-name = "integration" diff --git a/uv.lock b/uv.lock index 65ea8948..c8719c61 100644 --- a/uv.lock +++ b/uv.lock @@ -937,6 +937,11 @@ dependencies = [ { name = "typer" }, ] +[package.optional-dependencies] +browser = [ + { name = "playwright" }, +] + [package.metadata] requires-dist = [ { name = "aiohttp", specifier = ">=3.14.3" }, @@ -946,6 +951,7 @@ requires-dist = [ { name = "jsonschema", specifier = ">=4.26.0" }, { name = "lightkube", specifier = ">=1.0.0" }, { name = "platformdirs", specifier = ">=4.9.2" }, + { name = "playwright", marker = "extra == 'browser'", specifier = ">=1.62.0" }, { name = "prometheus-client", specifier = ">=0.26.0" }, { name = "pyhelm3", specifier = ">=0.5.7" }, { name = "pytest", specifier = ">=8.4.2,<9" }, @@ -959,6 +965,7 @@ requires-dist = [ { name = "signedjson", specifier = ">=1.1.4" }, { name = "typer", specifier = ">=0.27.1" }, ] +provides-extras = ["browser"] [[package]] name = "ess-migration-tool" From 0c26946ff4fe2dcd05659f5a49ab72f46fbda989 Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Thu, 8 Oct 2026 09:32:01 +0000 Subject: [PATCH 22/23] Attach the browser container to the k3d network --- .../files/playwright/start-browser-server.sh | 8 +- tests/integration/fixtures/playwright.py | 100 ++++++++++++++---- 2 files changed, 88 insertions(+), 20 deletions(-) diff --git a/tests/integration/fixtures/files/playwright/start-browser-server.sh b/tests/integration/fixtures/files/playwright/start-browser-server.sh index e1d0c846..dc55b7ac 100644 --- a/tests/integration/fixtures/files/playwright/start-browser-server.sh +++ b/tests/integration/fixtures/files/playwright/start-browser-server.sh @@ -20,5 +20,9 @@ mkdir -p "$HOME/.pki/nssdb" certutil -N --empty-password -d "sql:$HOME/.pki/nssdb" || true certutil -A -t "C,," -n ess-helm-test-ca -d "sql:$HOME/.pki/nssdb" -i /ess-helm-test-ca.pem -# The browser server prints its websocket address on stdout, e.g. ws://127.0.0.1:xxxx/ -exec playwright run-server +# Start the browser server with the launch config the tests mount at +# /ess-helm-browser-launch-config.json. The config makes the server listen on all +# interfaces, so the tests can reach the websocket from outside the container. And it maps +# the *.localhost names of the tests to the IP of the ingress on the docker network of +# the cluster (see fixtures/playwright.py for why the mapping is not in /etc/hosts). +exec playwright launch-server --browser chromium --config /ess-helm-browser-launch-config.json diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index bcd6e223..bf9ac8b6 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -4,6 +4,7 @@ import asyncio import hashlib +import json import os import re import shutil @@ -19,6 +20,7 @@ import pytest from python_on_whales import Container, docker from ..artifacts import CertKey +from .cluster import PotentiallyExistingK3dCluster try: from playwright.async_api import Browser, async_playwright @@ -41,8 +43,14 @@ REPO_ROOT = Path(__file__).parent.parent.parent.parent.resolve() # the image installs it in the browser before the browser server starts (see the Dockerfile). CA_MOUNT_PATH = "/ess-helm-test-ca.pem" -# The browser server prints the websocket address it listens on, e.g. ws://127.0.0.1:xxxx/ -_WS_ENDPOINT_PATTERN = re.compile(r"ws://\S+") +# The path where the browser server launch config is mounted in the container. The start +# script of the image reads it when it starts the browser server. +LAUNCH_CONFIG_MOUNT_PATH = "/ess-helm-browser-launch-config.json" + +# The browser server prints the websocket address it listens on, e.g. ws://0.0.0.0:xxxx/. +# The host of the printed address is only meaningful inside the container. The tests connect +# to the IP of the container instead, so the host part is replaced (see _wait_for_browser). +_WS_ENDPOINT_PATTERN = re.compile(r"ws://\S+:(?P\d+)(?P/\S*)") _BROWSER_SERVER_STARTUP_TIMEOUT = 60 @@ -113,59 +121,115 @@ def _require_controller() -> Any: return async_playwright +def _container_ip(container: Container, network: str) -> str: + """The IP of a container on a docker network.""" + networks = docker.container.inspect(container).network_settings.networks + assert networks, f"the container is not attached to the network {network}" + ip = networks[network].ip_address + assert ip, f"the container has no IP on the network {network}" + return ip + + +def _traefik_ingress_ip(cluster: PotentiallyExistingK3dCluster, network: str) -> str: + """The IP of the Traefik ingress controller on the docker network of the cluster. + + The load balancer container of k3d listens on the ports 80 and 443 of the docker + network, and forwards them to Traefik. So this IP is how the ingress is reached from + the containers on that network, e.g. the browser container. + """ + load_balancer = docker.container.inspect(f"k3d-{cluster.cluster_name}-serverlb") + return _container_ip(load_balancer, network) + + +def _launch_config(ingress_ip: str) -> dict[str, Any]: + """The launch config of the browser server, as playwright expects it. + + The server listens on all interfaces, so the tests can reach its websocket through the + docker network of the cluster. + + The browser resolves the *.localhost names of the tests to the IP of the ingress. + Chromium has that built in: it sends them to the loopback address. That is why the + mapping cannot go into /etc/hosts: Chromium never looks there for these names, and + /etc/hosts has no wildcards anyway. The host resolver rules of Chromium override its + built-in loopback mapping. + """ + return { + "host": "0.0.0.0", + "args": [f"--host-resolver-rules=MAP *.localhost {ingress_ip}"], + } + + @pytest.fixture(scope="session") -async def browser(root_ca: CertKey) -> AsyncIterator[Browser]: +async def browser(cluster: PotentiallyExistingK3dCluster, root_ca: CertKey) -> AsyncIterator[Browser]: """A Chromium running in a docker container. The tests talk to it over a websocket. The browser runs in a docker container, so nothing has to be installed on the host. The tests also work on hosts where Playwright cannot install or run a browser locally - (e.g. Alpine Linux). The container uses the network of the host. So the browser can - reach the ingress on the loopback interface. And the tests can reach the browser - server's websocket address. + (e.g. Alpine Linux). + + The container is attached to the docker network of the k3d cluster, not to the network + of the host. So the tests do not rely on host networking, and they also work when they + run inside a container themselves: the websocket address of the browser server is the + IP of the browser container on that network. + + On that network, the ingress is reached at the IP of the k3d load balancer that fronts + Traefik. The browser resolves the *.localhost names of the tests to that IP (see + _launch_config). The test CA signs the certificates of the ingress. It is mounted into the container. The image installs it in the browser before the browser server starts. So the browser accepts the certificates of the ingress. """ controller = _require_controller() + network = f"k3d-{cluster.cluster_name}" with tempfile.TemporaryDirectory() as ca_dir: ca_file = Path(ca_dir) / "ess-helm-test-ca.pem" ca_file.write_text(root_ca.cert_as_pem()) + launch_config_file = Path(ca_dir) / "ess-helm-browser-launch-config.json" + launch_config_file.write_text(json.dumps(_launch_config(_traefik_ingress_ip(cluster, network)))) container = docker.run( _ensure_image(), # The start script of the image installs the mounted CA certificate in the - # browser. Then it starts the browser server. The server prints its websocket - # address. It listens on a random port of the loopback interface. + # browser. Then it starts the browser server with the mounted launch config. + # The server prints its websocket address. It listens on a random port of all + # interfaces. detach=True, init=True, remove=True, - networks=["host"], + networks=[network], shm_size="1g", - volumes=[(ca_file, CA_MOUNT_PATH, "ro")], + volumes=[ + (ca_file, CA_MOUNT_PATH, "ro"), + (launch_config_file, LAUNCH_CONFIG_MOUNT_PATH, "ro"), + ], ) + container_ip = _container_ip(container, network) try: async with controller() as playwright: - browser = await _wait_for_browser(playwright, container) + browser = await _wait_for_browser(playwright, container, container_ip) yield browser await browser.close() finally: docker.container.remove(container, force=True) -async def _wait_for_browser(playwright: Any, container: Container) -> Browser: +async def _wait_for_browser(playwright: Any, container: Container, container_ip: str) -> Browser: """A connection to the browser server in the container. The websocket address is read from the container logs. The server prints it, and its - random path is not known otherwise. The printed line alone does not prove that the - server accepts connections. So the connection is the real test: it is retried - until the server accepts it, and the last error is reported when it never does. + random path is not known otherwise. The printed host is replaced with the IP of the + container on the network of the cluster: the printed one is only reachable inside the + container. The printed line alone does not prove that the server accepts connections. + So the connection is the real test: it is retried until the server accepts it, and the + last error is reported when it never does. """ deadline = time.monotonic() + _BROWSER_SERVER_STARTUP_TIMEOUT last_error: Exception | None = None while time.monotonic() < deadline: if match := _WS_ENDPOINT_PATTERN.search(container.logs()): + endpoint = f"ws://{container_ip}:{match['port']}{match['path']}" try: - return await playwright.chromium.connect(match.group(0), timeout=2000) + return await playwright.chromium.connect(endpoint, timeout=2000) except Exception as error: # The server printed its address but refused the connection. It may # not be ready yet. Try again until the deadline. @@ -181,8 +245,8 @@ async def _wait_for_browser(playwright: Any, container: Container) -> Browser: @pytest.fixture async def browser_page(browser: Browser): # The browser knows the test CA (see the browser fixture). So it accepts the - # certificates of the ingress. Chromium sends *.localhost names to the loopback - # address. The ingress listens there. + # certificates of the ingress. The browser resolves the *.localhost names of the tests + # to the IP of the ingress (see the browser fixture). context = await browser.new_context() page = await context.new_page() yield page From 40030914232ef5cda11e61b15828812bf7e9665a Mon Sep 17 00:00:00 2001 From: Gael Goinvic Date: Thu, 8 Oct 2026 09:58:05 +0000 Subject: [PATCH 23/23] Use explicit quoted types instead of disabling PEP 649 through future statement --- tests/integration/test_element_admin.py | 10 ++-------- tests/integration/test_element_web.py | 11 ++++------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/integration/test_element_admin.py b/tests/integration/test_element_admin.py index 33b11dc7..63b4e2b8 100644 --- a/tests/integration/test_element_admin.py +++ b/tests/integration/test_element_admin.py @@ -3,12 +3,6 @@ # # SPDX-License-Identifier: AGPL-3.0-only - -# Annotations are stored as text and not evaluated when this file is imported. -# This allows the type-checking-only `Page` import below, even when playwright is missing. -# Python 3.14 behaves like this by default; this is a backport for older versions. -from __future__ import annotations - from typing import TYPE_CHECKING import pytest @@ -43,7 +37,7 @@ async def test_element_admin_can_access_root(ingress_ready, generated_data: ESSD @pytest.mark.skipif(value_file_has("matrixAuthenticationService.enabled", False), reason="MAS not deployed") @pytest.mark.asyncio_cooperative @pytest.mark.parametrize("users", [[User("browser-admin-user", admin=True)]], indirect=True) -async def test_element_admin_login(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): +async def test_element_admin_login(ingress_ready, generated_data: ESSData, browser_page: "Page", users: list[User]): from playwright.async_api import expect await ingress_ready("element-admin") @@ -65,7 +59,7 @@ async def test_element_admin_login(ingress_ready, generated_data: ESSData, brows @pytest.mark.asyncio_cooperative @pytest.mark.parametrize("users", [[User("browser-non-admin-user")]], indirect=True) async def test_element_admin_login_rejects_non_admin( - ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User] + ingress_ready, generated_data: ESSData, browser_page: "Page", users: list[User] ): from playwright.async_api import expect diff --git a/tests/integration/test_element_web.py b/tests/integration/test_element_web.py index 072c5d1d..017cd81f 100644 --- a/tests/integration/test_element_web.py +++ b/tests/integration/test_element_web.py @@ -3,11 +3,6 @@ # # SPDX-License-Identifier: AGPL-3.0-only -# Annotations are stored as text and not evaluated when this file is imported. -# This allows the type-checking-only `Page` import below, even when playwright is missing. -# Python 3.14 behaves like this by default; this is a backport for older versions. -from __future__ import annotations - import re from typing import TYPE_CHECKING @@ -35,7 +30,7 @@ async def test_element_web_can_access_config_json(ingress_ready, generated_data: @pytest.mark.skipif(value_file_has("elementWeb.enabled", False), reason="ElementWeb not deployed") @pytest.mark.asyncio_cooperative -async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSData, browser_page: Page): +async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSData, browser_page: "Page"): from playwright.async_api import expect await ingress_ready("element-web") @@ -49,7 +44,9 @@ async def test_element_web_loads_in_browser(ingress_ready, generated_data: ESSDa @pytest.mark.skipif(value_file_has("matrixAuthenticationService.enabled", False), reason="MAS not deployed") @pytest.mark.asyncio_cooperative @pytest.mark.parametrize("users", [[User("browser-element-web-user")]], indirect=True) -async def test_element_web_login_via_mas(ingress_ready, generated_data: ESSData, browser_page: Page, users: list[User]): +async def test_element_web_login_via_mas( + ingress_ready, generated_data: ESSData, browser_page: "Page", users: list[User] +): from playwright.async_api import expect await ingress_ready("element-web")