Files
remark42/compose-e2e-test.yml
T
Dmitry VerkhoturovandGitHub ff77f41a3a Move the e2e suite to Go and playwright-go (#2180)
* Move the e2e suite to Go and playwright-go

The seven playwright tests in `frontend/e2e` become twenty in `e2e/`, a
separate Go module driving the same browsers through playwright-go. The
npm project, its lockfile entries, its prettier config and
`Dockerfile.e2e` go with it, leaving `frontend/` a single-member
workspace.

The suite covers posting with markdown, replying and the nesting that
implies, editing inside the deadline and the backend refusing one outside
it, deleting, voting with the optimistic score observed mid-flight and
rolled back on failure, changing the sort, collapse persistence across a
reload, dev, anonymous and email sign-in end to end, the profile iframe,
and the two scripts that render into the host page rather than the
widget's own frame.

The rendering tests run in chromium, firefox and webkit. The rest sign in,
sign-in needs the dev oauth2 provider, and reaching that by name from the
host is chromium-only, so they run there alone.

`compose-e2e-test.yml` runs remark42, a second instance with a short edit
window so that path does not need a five-minute test, and mailpit, which
catches the email verification message the suite reads back. Everything
binds to the loopback interface: the stack holds a known secret and an
admin shared id, and `go test` can start it unattended. The tests run on
the host rather than in a container.

Three settings there exist for the tests rather than for realism.
`REMARK_URL` uses a hostname because the dev oauth2 server binds whatever
host it reads out of it, and a loopback bind inside a container cannot be
published. `UPDATE_LIMIT` is raised because the default of 0.5/sec rejects
any test posting twice in a row. The suite also paces its own `/auth/`
calls, which are capped at 2/sec by a bare literal in `rest.go` rather
than by a setting.

Each test gets its own comment thread from a query string on the demo
page, so nothing has to reset the database between runs.

CI gains a vet and lint job for the module, since the build tag keeps it
out of a plain `go test ./...`, and uploads a browser trace for any test
that fails.

`e2e/README.md` carries the rest: how to run it, what the stack is for,
and the widget behaviour the assertions have to work around.

* Update golangci-lint to 2.13.1 in the backend workflow

The pin sat three minors behind what the linter installs locally, so CI
checked the backend with an older set of rules than anyone running it by
hand. 2.10.1 also fetches its config schema over the network on every
`config verify`, which is a failure mode with no bearing on the code.

Both targets are clean on 2.13.1, `backend/app` and the memory_store
example.
2026-08-21 17:53:12 -05:00

110 lines
4.0 KiB
YAML

# compose for the e2e suite; the tests themselves run on the host, see e2e/
#
# every port is bound to the loopback interface on purpose. this stack runs with a known
# secret, dev oauth2 and an admin shared id, and `go test` can start it unattended, so it
# must not be reachable from the network. the suite only ever talks to 127.0.0.1.
services:
remark42:
build:
context: .
dockerfile: Dockerfile
args:
- SKIP_BACKEND_TEST=true
- SKIP_FRONTEND_TEST=true
image: ghcr.io/umputun/remark42:dev
container_name: "remark42-e2e"
ports:
- "127.0.0.1:8080:8080"
# dev oauth2 provider, registered from the REMARK_URL hostname
- "127.0.0.1:8084:8084"
# the hostname has to be a name rather than 127.0.0.1: the dev oauth2 server binds the
# host it reads out of REMARK_URL, and a loopback bind inside the container cannot be
# published. the suite maps the name back to 127.0.0.1 in the browser, see e2e/
environment:
- REMARK_URL=http://remark42:8080
- SECRET=12345
- DEBUG=true
- ADMIN_PASSWD=password
- AUTH_DEV=true # local oauth2 "dev" provider, bound to the REMARK_URL host on :8084
# ADMIN_EDIT stays off: it gives admins an infinite edit window, which removes the
# countdown TestComment_EditWithinTheDeadline asserts on
- ADMIN_SHARED_ID=dev_user # set admin flag for default user on local oauth2
- AUTH_ANON=true
- AUTH_EMAIL_ENABLE=true
# the auth sender reads AUTH_EMAIL_FROM; NOTIFY_EMAIL_FROM feeds the notify module,
# which this stack does not enable
- AUTH_EMAIL_FROM=remark42@example.com
- SMTP_HOST=mailpit
- SMTP_PORT=1025
# default is 0.5/sec, which the suite exceeds whenever a test posts twice in a row
- UPDATE_LIMIT=100
volumes:
- remark42-e2e-var:/srv/var
depends_on:
mailpit:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/ping"]
interval: 2s
timeout: 3s
retries: 30
# a second instance whose edit window expires almost immediately, so the expired-edit
# path can be exercised without holding a test open for the default five minutes
remark42-shortedit:
image: ghcr.io/umputun/remark42:dev
container_name: "remark42-e2e-shortedit"
# this service has no build of its own, so without this a pull could substitute the
# published image for the one built from this checkout
pull_policy: never
# only needs the image the first service builds, not a running one
depends_on:
remark42:
condition: service_started
ports:
- "127.0.0.1:8081:8080"
# anonymous only: the dev oauth2 provider's port is hardcoded to 8084 against the
# REMARK_URL hostname, so a second instance on the same host would register the
# first one's provider
environment:
- REMARK_URL=http://remark42-shortedit:8081
- SECRET=12345
- AUTH_ANON=true
# long enough that the post round trip and the first assertion comfortably fit inside
# the window, short enough that waiting it out costs a few seconds
- EDIT_TIME=15s
- UPDATE_LIMIT=100
volumes:
- remark42-e2e-shortedit-var:/srv/var
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/ping"]
interval: 2s
timeout: 3s
retries: 30
# catches the email-auth verification message; the suite reads it back over the HTTP API
mailpit:
image: axllent/mailpit:v1.30.7
container_name: "remark42-e2e-mailpit"
ports:
- "127.0.0.1:8025:8025"
# without this `--wait` returns as soon as the container starts, and remark42 can be
# healthy before anything is listening on 1025
healthcheck:
test: ["CMD", "/mailpit", "readyz"]
interval: 2s
timeout: 3s
retries: 30
# named rather than bind mounts, so `docker compose down -v` really does discard the
# databases and a run can start from an empty site
volumes:
remark42-e2e-var:
remark42-e2e-shortedit-var: