@bigbinary/neeto-api-keys-playwright
v1.0.4
Published
Playwright helpers for the neeto API keys nano.
Readme
API keys Playwright helpers
@bigbinary/neeto-api-keys-playwright contains the API-key POMs, API helper,
selectors, and types owned by this nano. It is versioned and published
independently of @bigbinary/neeto-api-keys-frontend.
Usage
Install it in the consuming product's playwright-tests/ directory:
yarn add -D @bigbinary/neeto-api-keys-playwrightThe 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": {
"@neetoapikeys": ["./node_modules/@bigbinary/neeto-api-keys-playwright"]
}import { ApiKeysApi, ApiKeysPage, API_KEYS_SELECTORS } from "@neetoapikeys";ApiKeysPagedrives the frontend's/v2entry point. It takes the Playwrightpageand the commons utilities fixture, as before. There is no helper for the legacy (non-v2) UI.ApiKeysApi.create(label, type)defaults to a general key and accepts"zapier"as the second argument.- The host's i18next fixture must load the nano translations before a POM is created.
expiryDateisDD/MM/YYYY. Omitting it selects No expiration, since the UI otherwise defaults to 30 days.
Public helpers
ApiKeysApi takes Pick<CustomCommands, "apiRequest"> and provides:
fetch(searchTerm, params = {}): fetch keys matching a label. Extra query parameters use snake_case; passzapier_integrable_type: "Organization"to include organization Zapier keys when the integration is available.create(label, type = "general"): create a non-expiring general or Zapier key.delete(id, type = "general"): delete a key. Pass its returnedtypeso the controller selects the correct general or Zapier record.
ApiKeysPage provides:
getApiTokenViaRequest(label): return the first matching key's token.createApiKeyViaRequest(label, type = "general"): create a key and return its token.deleteApiKeyViaRequest(label): delete every returned match, forwarding each key's type. An empty result is a no-op.fillApiKeyDetails({ label, expiryDate? }): fill and save the open key sheet.verifyApiKey({ targetRow, label, date }): verify a non-expiring active key row.editApiKey({ label, expiryDate? }): select Edit from the open row menu and save the key details.deleteApiKey(targetRow): delete a key through its row menu and confirmation.
The request-based page helpers include organization Zapier keys when available, matching the nano UI's default scope. Searches use the controller's label substring matching; use a unique label when retrieving a token.
API_KEYS_SELECTORS exports the nano's UI test IDs. The exported types are
ApiKey (the id, token and type used by the request helpers), ApiKeyType,
ApiKeyDetails, and VerifyApiKeyProps.
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 publishcd path/to/product/playwright-tests
yalc add --dev @bigbinary/neeto-api-keys-playwrightAfter the first publish, yalc push from playwright/ updates every product
that added the package. Remove it with
yalc remove @bigbinary/neeto-api-keys-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.
