web-push-tests
БесплатноБез исполняемых скриптовНе проверенUse when a PWA ships browser web push and the subscription lifecycle needs release tests: pushManager.subscribe with VAPID keys, pushsubscriptionchange, push…
от testland★ 18 звёзд на GitHubОб этом скилле
web-push-tests
Overview
Per mdn-push, the Push API is "Baseline Widely available"
across browsers since March 2023. Firefox imposes per-app push
quotas; Chrome does not. This skill tests the browser side
(pushManager.subscribe per w3c-push, push event,
pushsubscriptionchange, unsubscribe) plus the server-side push
protocol per rfc8030 and VAPID auth per rfc8292. Cross-channel
push including native APNs / FCM is
push-notification-test-author territory.
When to use
- A PWA implements web-push and needs a subscription-lifecycle test before each release.
- Users report "I subscribed but never got a push" - author the endpoint-expiry test that catches stale subscriptions.
- A VAPID key was rotated and the team needs evidence subscriptions survived (they should, since VAPID identifies the server per rfc8292, not the subscription).
- Compliance audit needs evidence revoked subscriptions are cleaned
up server-side on
410 Goneper rfc8030.
Authoring
Step 1 - Set up the Playwright fixture with notification permission
Web-push subscription requires the notifications permission per
w3c-push userVisibleOnly: true requirement (and per browser UX
gating). Grant it in the fixture:
import { test as base, expect, chromium } from '@playwright/test';
const test = base.extend({
context: async ({ playwright }, use) => {
const ctx = await playwright.chromium.launchPersistentContext(
'./tmp/user-data',
{
permissions: ['notifications'],
headless: false, // SW + push prompt path needs headed mode in some Chromium builds
}
);
await use(ctx);
await ctx.close();
},
page: async ({ context }, use) => {
const page = await context.newPage();
await use(page);
},
});
// Shared: resolve the active service worker - reused across the tests below.
async function swReady(context) {
let [sw] = context.serviceWorkers();
if (!sw) sw = await context.waitForEvent('serviceworker');
return sw;
}
export { test, expect };
Per w3c-push, userVisibleOnly scopes the subscription to user-visible push
messages; most browsers require it to be true.
Step 2 - Test subscription creation
test('pushManager.subscribe returns a PushSubscription with VAPID-bound keys', async ({ page, context }) => {
await page.goto('https://localhost:3000/');
const sw = await swReady(context);
const sub = await page.evaluate(async (vapidPubKey) => {
const reg = await navigator.serviceWorker.ready;
const s = await reg.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: vapidPubKey,
});
return s.toJSON();
}, process.env.VAPID_PUBLIC_KEY_BASE64URL!);
// Per w3c-push: PushSubscription exposes endpoint + keys (p256dh, auth)
expect(sub.endpoint).toMatch(/^https?:\/\//);
expect(sub.keys?.p256dh).toBeTruthy();
expect(sub.keys?.auth).toBeTruthy();
// expirationTime is optional per w3c-push - null is allowed
expect(sub.expirationTime === null || typeof sub.expirationTime === 'number').toBe(true);
});
Per w3c-push, the PushSubscription exposes:
| Property | Per w3c-push |
|---|---|
endpoint |
"URL where the application server sends messages" |
expirationTime |
"Optional timestamp (milliseconds since epoch) indicating when the subscription expires" |
keys.p256dh |
"P-256 ECDH Diffie-Hellman public key" |
keys.auth |
"authentication secret that an application server uses" |
options |
The PushSubscriptionOptions that created it |
Step 3 - Test getSubscription() returns the same endpoint
test('PushManager.getSubscription returns the active subscription', async ({ page }) => {
await page.goto('https://localhost:3000/');
// ... subscribe as Step 2 ...
const same = await page.evaluate(async () => {
const reg = await navigator.serviceWorker.ready;
const s = await reg.pushManager.getSubscription();
return s?.endpoint;
});
expect(same).toBeTruthy();
});
Per mdn-push, PushManager.getSubscription() returns the active
subscription if one exists, else null.
Step 4 - Test the SW push event with PushMessageData
Drive a push event into the registered service worker. In a real test environment, the application server sends to the endpoint; for an isolated unit test of the SW handler, dispatch the event synthetically:
test('SW push event triggers showNotification', async ({ context, page }) => {
await page.goto('https://localhost:3000/');
const sw = await swReady(context);
// Inject a tracker for the call
await sw.evaluate(() => {
(self as any).__showNotificationCalls = [];
const real =
Установить web-push-tests в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл web-push-tests?
Use when a PWA ships browser web push and the subscription lifecycle needs release tests: pushManager.subscribe with VAPID keys, pushsubscriptionchange, push event delivery, push-service responses (201, 410, 413, 429) and unsubscribe. Native APNs and FCM are push-notification-test-author.
Как установить скилл web-push-tests?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл web-push-tests запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic