Webhooks Playwright helpers
@bigbinary/neeto-webhooks-playwright contains the webhook POM, selectors, and
types owned by this nano. It is versioned and published independently of
@bigbinary/neeto-webhooks-frontend.
The generic webhook.site API (WebhookSiteApi) and constants
(DEFAULT_WEBHOOKS_RESPONSE_TEXT) stay in
@bigbinary/neeto-playwright-commons; WebhooksPage uses commons'
WebhookSiteApi.
Usage
Install it in the consuming product's playwright-tests/ directory:
yarn add -D @bigbinary/neeto-webhooks-playwright
The product supplies the peer dependencies listed in package.json, including
@bigbinary/neeto-playwright-commons. The frontend package is not required.
Like commons, the package is ES-module only, and Playwright loads specs as
CommonJS. Add a path alias next to @neetoplaywright in the product's
playwright-tests/tsconfig.json, and import through it.
"paths": {
"@neetowebhooks": ["./node_modules/@bigbinary/neeto-webhooks-playwright"]
}
import {
WebhooksApi,
WebhooksPage,
WEBHOOK_HEADERS,
WEBHOOK_SELECTORS,
} from "@neetowebhooks";
- Construct
WebhooksPage with { page, neetoPlaywrightUtilities }, as before.
The secret menu and delivery details helpers target the /v2 Sheet UI.
addWebhook({ webhookSiteURL, event }) checks the event whose test ID prefix
is event (its event_data_testids slug), or the first listed event when
event is omitted, and saves.
performTableAction(endpoint, "edit" | "delete") and
performLinkAction("regenerate" | "delete") open a webhook's row or secret
menu actions.
openMatchingDelivery<Payload>({ matches }) opens deliveries until
matches(payload, headerText) returns true. Pass the product's payload type.
verifyHeaders() checks the WEBHOOK_HEADERS signature headers, and
verifyResponse() checks the delivery's response body.
getTokenViaAPI() returns { webhookToken, webhookSiteURL }, and
verifyLatestWebhookResponse({ webhookToken, callback }) checks the latest
request webhook.site received.
new WebhooksApi(neetoPlaywrightUtilities) wraps the nano's REST API:
fetch, create({ entityType, entityId, endpoint, events }), delete,
fetchDeliveries, showDelivery, and redeliver(webhookSid, deliverySid).
Delivery methods take webhook and delivery sid values; delete takes the
webhook's database id. redeliver posts to the delivery's /redeliver
route.
getWebhookIdViaRequest({ entityId, endpoint }) returns the matching
webhook's database id, or undefined if it is absent. Pass it to delete.
getWebhookSidViaRequest({ entityId, endpoint }) returns the matching
webhook's sid, or undefined if it is absent. Pass it to the delivery
helpers.
deleteWebhookViaRequest({ entityId, endpoint }) deletes the matching
webhook; an absent endpoint is a no-op.
deleteWebhookViaUI(endpoint) deletes a row on the current webhook page,
confirms the alert, verifies the toast, and waits for the row to disappear.
setWebhookEvents(endpoint, events) edits a webhook so only the events with
the supplied test ID prefixes (event_data_testids slugs) are checked and
saves changes. If those events are already selected, it closes the unchanged
sheet.
findDeliveryViaRequest(webhookSid, predicate) reads the listed deliveries in
order and returns the first WebhookDelivery whose parsed request_body
satisfies the predicate, or undefined. It skips deliveries with no body and
passes the full parsed body to the predicate. Use the returned sid for API
requests and identifier for the delivery's UI link.
verifyWebhookDeliveries({ callback, ...fields }) verifies a successful
delivery and passes its parsed webhook payload to the callback.
verifyWebhookDeliveryByEvent({ event, callbackToVerifyDeliveries, ...fields })
opens the delivery whose event cell exactly matches event and runs that
payload verification. Pass the translated label, e.g.
railsT("webhooks.events.<identifier>").
- The host's i18next fixture must load the nano translations before a POM is
created.
The package explicitly exports FindWebhookParams, WebhookRecord, and
WebhookDelivery along with its existing argument and callback types.
Local development
To try unreleased changes in a product, publish with yalc from this directory,
then add the package in the product's playwright-tests/ directory. Remove the
yalc link before committing so the product's manifest and lockfile stay
unchanged:
yarn build && yalc publish
cd path/to/product/playwright-tests
yalc add --dev @bigbinary/neeto-webhooks-playwright
After the first publish, yalc push from playwright/ updates every product
that added the package. Remove it with
yalc remove @bigbinary/neeto-webhooks-playwright.
Releasing
Merge a PR with the playwright label and a patch, minor, or major label.
The existing NeetoCI bump workflow publishes this package and opens the
Bump version PR.