Tests / @ogygia/flags

@ogygia/flags

Version 0.14.0 latest
commit 620ddcca
74 test runs (74 tests, each run in Node, the browsers or both)
1.06× lines of test for each line of source (1,119 to 1,060) Only real test code counts: test files and their helpers, not fixtures, sample apps or benches. Blank lines are left out on both sides.
Exactly what is counted non-blank lines of test code across the repo (*.test.ts, *.test-d.ts, *.spec.ts, and the .ts helpers in test/ and e2e/ folders; no fixtures, fixture apps, stubs or benches), over non-blank lines of packages/*/src (no .d.ts or generated files)
93.8% of source lines run by the tests
  • 74Unit
  • 0Browser
  • 0End to end
  • 0Type tests
  • 0Lint rules
  • 0Failing

Coverage

  • 93.8%Lines
  • 82.3%Branches
  • 90.2%Functions
  • 92.0%Statements

Every test

74 tests

TestKindNodeChromiumFirefoxWebKit
packages/flags/test/definitions-reload.test.ts
flags defined by a module, across its dev reloads > a flag removed from the module is gone after its reload; a kept one staysUnitpassnot runnot runnot run
flags defined by a module, across its dev reloads > another module's reload keeps this module's flagsUnitpassnot runnot runnot run
packages/flags/test/exposure-queue.test.ts
the exposure queue > a batch the sink failed is tried again before the batch read after itUnitpassnot runnot runnot run
the exposure queue > a sink that rejects is contained: no unhandled rejection, and a warning with its codeUnitpassnot runnot runnot run
the exposure queue > an exposure read while a send is in flight goes in the next send, and that end waits for itUnitpassnot runnot runnot run
the exposure queue > nothing buffered: the end has nothing to wait forUnitpassnot runnot runnot run
the exposure queue > the age cap sends a buffered batch on its ownUnitpassnot runnot runnot run
the exposure queue > the request's end resolves after the sink's sendUnitpassnot runnot runnot run
packages/flags/test/flags.test.ts
decide — exposure batching > fires once per (request, flag); flushes at max, at the timer, and at flush_exposures()Unitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source value that is a bigint is skipped, never read as offUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source value that is a function is skipped, never read as offUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source value that is a number is skipped, never read as offUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source value that is a symbol is skipped, never read as offUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source value that is another number is skipped, never read as offUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a source variant NOT in the declared set is ignored (falls through to native)Unitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > a throwing source degrades every flag to native, never the requestUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > bare boolean/string source values are sugar for { variant }Unitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > override still beats the sourceUnitpassnot runnot runnot run
decide + source — the OpenFeature seam (any resolver) > source decides a variant; validated against declared variants; primes once per requestUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > an anonymous router visitor (anonymousVisitor()'s `{ vid }`) is read, and hashes like its cookieUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > anonymous → no visitorUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > anonymous carried claims (`{ vid }` from a shell) are readUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > carried claims win over the cookie; a router visitor wins over bothUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > openfeature()'s default context gets the visitor as its targetingKeyUnitpassnot runnot runnot run
decide + source — the source sees the visitor a read hashes on > the og-vid cookie (no router identity above the router) → `{ vid, anonymous }`Unitpassnot runnot runnot run
federation — decided flags auto-carry > a flag never read this request does NOT carryUnitpassnot runnot runnot run
federation — decided flags auto-carry > every flag decided this request self-registers its bucket for signed claimsUnitpassnot runnot runnot run
flag — decision precedence > ?og-exp override beats everything (unknown variants ignored)Unitpassnot runnot runnot run
flag — decision precedence > carried claims (upstream shell) beat the native ruleUnitpassnot runnot runnot run
flag — decision precedence > the override GATE: closed → ?og-exp is inert (prod default); reopened → honoredUnitpassnot runnot runnot run
flag — layers (mutual exclusion, a string group) > a visitor lands in at most ONE memberUnitpassnot runnot runnot run
flag — the four declaration shapes, read by calling > bare = a kill switch, off for everyoneUnitpassnot runnot runnot run
flag — the four declaration shapes, read by calling > function = targeting; true → on, false → definitively off, undefined → fall throughUnitpassnot runnot runnot run
flag — the four declaration shapes, read by calling > number = sticky rollout percent, ~accurate over a populationUnitpassnot runnot runnot run
flag — the four declaration shapes, read by calling > record = weighted variants; anonymous → control (first key)Unitpassnot runnot runnot run
flag — the four declaration shapes, read by calling > weights are RATIOS, not percentages (3:1 ≈ 75/25)Unitpassnot runnot runnot run
flag.pick — one verb, two forms > boolean flag pick maps off/onUnitpassnot runnot runnot run
flag.pick — one verb, two forms > one-arg form = a page slot (ComponentPick), resolved per request, control fallbackUnitpassnot runnot runnot run
flag.pick — one verb, two forms > stamp names the world for analyticsUnitpassnot runnot runnot run
flag.pick — one verb, two forms > two-arg form = pick this visitor a value (numbers, strings, config)Unitpassnot runnot runnot run
flag.value — vendor payloads, schema-validated > an invalid vendor payload is rejected → fallback (trust boundary)Unitpassnot runnot runnot run
flag.value — vendor payloads, schema-validated > no source → fallback, never undefinedUnitpassnot runnot runnot run
flag.value — vendor payloads, schema-validated > returns the validated payload, else the fallbackUnitpassnot runnot runnot run
packages/flags/test/hole-cache.test.ts
a cached hole that reads a flag > answers a visitor who joins another bucket render in flight with their own variantUnitpassnot runnot runnot run
a cached hole that reads a flag > answers two visitors in two buckets with their own variantsUnitpassnot runnot runnot run
packages/flags/test/inventory-build.test.ts
the flag inventory > a root the manifest cannot be written under never fails the buildUnitpassnot runnot runnot run
the flag inventory > with flags() listed, a build writes every flag site, the unused module tooUnitpassnot runnot runnot run
the flag inventory > without flags() there is no manifest, and the build says the plugin is not listedUnitpassnot runnot runnot run
packages/flags/test/inventory.test.ts
collect_flag_sites — AST binding resolution > a dynamic first argument is skipped (not inventoriable)Unitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > a LOCAL function named `flag` is NOT counted (a text sweep would false-positive)Unitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > a module that never imports ogygia yields nothingUnitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > counts calls through named imports, with names and linesUnitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > follows a NAMESPACE import (og.flag)Unitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > follows a RENAMED import (a text sweep would miss this)Unitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > svelte: a script tag in a markup comment or an attribute value is not a scriptUnitpassnot runnot runnot run
collect_flag_sites — AST binding resolution > svelte: flags inside <script> blocks carry FILE line numbersUnitpassnot runnot runnot run
flags_manifest > dedupes the two build legs and sorts stablyUnitpassnot runnot runnot run
packages/flags/test/plugin.test.ts
facts a read reports > a read is a per-visitor read (a stored page never keeps one variant) and an assignmentUnitpassnot runnot runnot run
flags() > is named by its package and names its server realm, the module beside itUnitpassnot runnot runnot run
the server realm > primes the source in `request`, done before the page reads a flag, and drains exposures in `done`Unitpassnot runnot runnot run
the server realm primes the source with the visitor > the event's og-vid cookie reaches the source as `c.visitor`Unitpassnot runnot runnot run
packages/flags/test/prime-twice.test.ts
a second prime of a request while the first waits > returns once the source answered, and reads get its answerUnitpassnot runnot runnot run
a source that throws before it awaits anything > leaves the request resolved (empty), never priming for goodUnitpassnot runnot runnot run
packages/flags/test/source-failed.test.ts
a failing flag source is said > a request where one flag still fails does not end the streak, though the source answered the restUnitpassnot runnot runnot run
a failing flag source is said > a source that never answers holds no request: past its deadline the flags fall to their native rule, and it is saidUnitpassnot runnot runnot run
a failing flag source is said > a source that throws: said once for its failing streak, with the error, again after a request workedUnitpassnot runnot runnot run
a failing flag source is said > an OFREP endpoint that answers 500Unitpassnot runnot runnot run
a failing flag source is said > an OFREP endpoint that cannot be reachedUnitpassnot runnot runnot run
a failing flag source is said > an OpenFeature flag whose evaluation throws: said, and the other flags keep the source's answerUnitpassnot runnot runnot run
packages/flags/test/sources.test.ts
ofrep() > gives up after 800 ms by defaultUnitpassnot runnot runnot run
ofrep() > reads a boolean value as the on or off variantUnitpassnot runnot runnot run
ofrep() > stops asking when the request ends first, and reports no failureUnitpassnot runnot runnot run
ofrep() > throws on an error answer with a JSON body, so the flags fall to their native rule and it is saidUnitpassnot runnot runnot run
openfeature() > asks with off as the default for a boolean flag and the first variant for a variant flagUnitpassnot runnot runnot run