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
WebhooksPagewith{ page, neetoPlaywrightUtilities }, as before. The secret menu and delivery details helpers target the/v2Sheet UI. addWebhook({ webhookSiteURL, event })checks the event with that label, or the first listed event wheneventis omitted, and saves.performTableAction(endpoint, "edit" | "delete")andperformLinkAction("regenerate" | "delete")open a webhook's row or secret menu actions.openMatchingDelivery<Payload>({ matches })opens deliveries untilmatches(payload, headerText)returns true. Pass the product's payload type.verifyHeaders()checks theWEBHOOK_HEADERSsignature headers, andverifyResponse()checks the delivery's response body.getTokenViaAPI()returns{ webhookToken, webhookSiteURL }, andverifyLatestWebhookResponse({ 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, andredeliver(webhookId, deliveryId). Delivery methods take webhook and delivery sid values;deletetakes the webhook's databaseid.redeliverposts to the delivery's/redeliverroute.getWebhookIdViaRequest({ entityId, endpoint })returns the matching webhook's database id, orundefinedif it is absent.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 supplied event labels are checked, saves changes, and verifies the row. If those events are already selected, it closes the unchanged sheet.findDeliveryViaRequest(webhookId, predicate)reads the listed deliveries in order and returns the firstWebhookDeliverywhose parsedrequest_bodysatisfies the predicate, orundefined. It skips deliveries with no body and passes the full parsed body to the predicate. Use the returnedsidfor API requests andidentifierfor the delivery's UI link.verifyWebhookDeliveries({ callback, ...fields })verifies a successful delivery and passes its parsedwebhookpayload to the callback.verifyWebhookDeliveryByEvent({ event, callbackToVerifyDeliveries, ...fields })opens an event's delivery and runs that payload verification.- 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.