Skip to content

Signing up for Discord? Some of our domains are accepted there. See which ones on the Domains page.

CyberTemp
All posts

How to Test Notification Preferences Without the Spam

CyberTemp5 min read

Need a disposable inbox right now?

Spin up a temporary email address in seconds — no signup, no spam, no trace.

Get a free inbox

Notification preference centers look simple from the outside: a handful of checkboxes for "order updates," "weekly digest," "product announcements," "security alerts." Under the hood, most of them are a matrix of category flags, frequency settings, and channel toggles that nobody QAs combinatorially, because doing it by hand against your own inbox means either subscribing to everything or missing the bug entirely.

The failure mode is always the same: a user unchecks "marketing" and keeps "security alerts," and three weeks later they're still getting the weekly digest. Or worse, they unsubscribe from everything and still get billing reminders because that category flag was never actually wired to the send logic. These bugs don't show up in a smoke test with one test account. They show up when a real user complains, and by then you're debugging in production against someone else's inbox.

Why preference centers break silently

A notification preference center is rarely a single boolean per category. It's usually category flags combined with a global unsubscribe, a digest-frequency setting, and sometimes a channel split (email vs push vs SMS) that all have to agree before a message goes out. Every one of those is a place where an "and" turns into an "or," or where a new category ships without a corresponding check in the send path.

The bug is invisible in code review because the send logic and the preference logic usually live in different services — a marketing platform reading a synced flag, a transactional service that never checks preferences at all because "security emails always send." That last exception is exactly where the billing-reminder bug above comes from: someone tagged a non-security email as exempt from preferences and never revisited it.

Map every combination before you write a single test

Before touching any test tooling, write out the actual matrix. If you have four categories and a digest-frequency setting with three values, that's not four tests — it's closer to 4×3, plus the "everything off" and "everything on" edges. Most teams never do this step, which is why the coverage gap is discovered by users instead of QA.

  • List every category flag your preference center exposes, including ones marked "always on" like security or billing.

  • List every frequency or channel setting that modifies delivery, not just whether it happens.

  • Flag combinations that should be structurally impossible (e.g. "digest off" but "digest frequency: weekly" still set) — these expose UI/backend state drift.

  • Mark which categories are supposed to be un-optable, and write a test that proves they still arrive even when everything else is off.

Give each combination its own disposable inbox

The reason this testing gets skipped is logistics: nobody wants to create and manage a dozen real email accounts to represent a dozen preference states, then remember to clean them up. A disposable inbox per combination removes that friction — generate the address, set that one user's preferences, trigger the notification events, read the inbox, delete it.

CyberTemp's API is built around exactly this shape. GET /getMail both creates the inbox on first read and returns whatever's arrived, so there's no separate provisioning step:

import httpx

API_KEY = "tk_..."
HEADERS = {"X-API-Key": API_KEY}
BASE = "https://api.cybertemp.xyz"

def read_inbox(address):
    resp = httpx.get(f"{BASE}/getMail", params={"email": address}, headers=HEADERS)
    resp.raise_for_status()
    return resp.json()

def check_categories(address, expected_categories):
    messages = read_inbox(address)
    seen = {m["category"] for m in messages if "category" in m}
    missing = expected_categories - seen
    unexpected = seen - expected_categories
    return missing, unexpected

Name each address after the combination it represents — [email protected], [email protected], [email protected] — so a failing test tells you exactly which state broke without cross-referencing a spreadsheet. That naming discipline is the same pattern covered in OTP test automation, just applied to preference states instead of signup flows.

Script the actual verification

Set the preference state through your app's real API or admin panel — not a database write, since that skips whatever validation logic lives between the toggle and the stored flag. Then trigger every notification event that combination could plausibly touch, wait, and read the inbox once.

  • Trigger every event type in one pass per combination, so a single inbox read tells you both what arrived and what didn't.

  • Assert on the missing set and the unexpected set separately — a category that shouldn't have fired is a different bug than one that should have and didn't.

  • Re-run the "everything off" case on a schedule, not just once. Preference-bypass bugs tend to get reintroduced months later when someone adds a new notification type and forgets the exemption logic.

  • Tear down each inbox after the assertions pass so a failed run next week isn't reading stale mail from this week's test.

If your notification volume per test run is high — several categories fired across a dozen preference combinations, repeated on every CI run — watch your request pacing. Handling rate limits and retries covers the backoff pattern for exactly this kind of polling load.

The one case that matters most

Of every combination in the matrix, the one worth testing on every single deploy is "user opted out of everything except security." It's the case regulators care about, the case that generates support tickets when it breaks, and the case most likely to be exempted from normal QA because "security emails always send" gets treated as an assumption instead of a tested behavior. Give it its own inbox, its own test, and don't let it get lumped into a generic "preferences work" checkbox on a release checklist.


If you're scripting this kind of preference-matrix testing into CI, per-key request limits are what determine whether a dozen-combination test suite runs in one pass or gets rate-limited halfway through. The paid tiers raise those limits, and picking the right plan for a QA workload that fires dozens of throwaway inboxes per run is worth doing before your test suite starts failing on quota instead of on the actual bug. Sign up if that's the workload you're building against.

Share
    How to Test Notification Preferences Without the Spam | CyberTemp Blog