Skip to content

test(compact): cover the Do-Not-Sell row, the one compact rule nothing asserted - #313

Merged
fabiodalez-dev merged 1 commit into
mainfrom
test/compact-donotsell-coverage
Oct 6, 2026
Merged

fabiodalez-dev merged 1 commit into
mainfrom
test/compact-donotsell-coverage

Conversation

@fabiodalez-dev

Copy link
Copy Markdown
Owner

What was missing

test-mobile-compact-css-php.php asserts every rule the compact phone layout emits — flex basis, the 44px tap target, wrapping, the order reset, the classic chevron padding — except the Do-Not-Sell control, which had no unit assertion at all. Only mobile-compact-layout.spec.ts covered it, and that does not run in npm run test:unit.

That control is the fourth item in the wrapper and the one the compared-pair rules do not describe, so each property is load-bearing. Without a full basis it shares the row with accept and reject, and at 360px their 40% bases leave it almost nothing to grow into: it collapses to a few pixels while its label spills across Accept.

It is reached in ordinary operation, not only by hand — Geo_Runtime turns donotSell on for a US visitor while applicableLaw stays gdpr, and class-template.php keeps the button precisely because its status is true. For that visitor, this row is the opt-out.

Added

Six assertions per banner type (61 → 97 overall):

assertion what breaks without it
the rule exists the control is undescribed
flex:1 1 100% + width:100% shares the pair's row and collapses
white-space:normal the statutory label overflows its own box
display:block loses the template's left-aligned link look
selector matches the attribute, not the class the bare <a> variant is silently dropped
rule comes after the generic .faz-btn rule both are 1-1-0, so source order alone decides

Control runs

Each assertion was verified to fail when its property is removed:

control assertions turned red
flex:1 1 100% → flex:1 1 0 4
selector narrowed to .faz-btn-do-not-sell 28
white-space:normal dropped 4
rule moved above the generic one 4 — and only that assertion

The last one matters most: it catches a reorder that changes no rule text.

197/197 unit suites pass; production files are byte-identical to main after every control.

Two fixes deliberately left untested

Rather than add assertions that would pass regardless:

  • clearstatcache() in Geolocation::database_fingerprint() — removing it keeps every test green, because the premise does not reproduce here: on PHP 8.4 filesize() returns the new length after file_put_contents() and even after an external writer, so the stale-stat condition is not observable. Worth recording that the existing "database replaced → different fingerprint" assertion does not prove that line either — it writes through a helper that clears the stat cache itself, so it would stay green with the production line gone.
  • the degraded copy that distinguishes probe_failed from key_without_database — the reason code it branches on already has three unit assertions. Reaching the state from a browser needs a fake MaxMind licence key and a deliberately broken database planted on the test site, which is a poor trade for one if on a string.

…g asserted

test-mobile-compact-css-php.php asserts every rule the compact phone layout
emits — the flex basis, the 44px tap target, the wrapping, the order reset, the
classic chevron padding — except the Do-Not-Sell control, which had no unit
assertion at all. Only the E2E spec covered it, and that does not run in
`npm run test:unit`.

That control is the fourth item in the wrapper and the one the compared-pair
rules do not describe, so each property is load-bearing: without a full basis
it shares the row with accept and reject, and at 360px their 40% bases leave it
almost nothing to grow into — it collapsed to a few pixels while its label
spilled across Accept. It is reached in ordinary operation, not only by hand:
Geo_Runtime turns donotSell on for a US visitor while applicableLaw stays
'gdpr', so for that visitor this row IS the opt-out.

Six assertions per banner type (+36 overall, 61 -> 97):

- the rule exists at all;
- flex:1 1 100% and width:100%, so it takes a row instead of a share of one;
- white-space:normal, because "Do Not Sell or Share My Personal Information" is
  statutory wording that cannot be shortened and does not fit one phone line;
- display:block, which keeps the template's left-aligned link look rather than
  the centred flex box the compared buttons use;
- the selector matches the data attribute and NOT the class, because the
  shortcode emits either `.faz-btn.faz-btn-do-not-sell` or a bare <a> with no
  class, and narrowing it would silently drop the link variant;
- the rule comes AFTER the generic `.faz-btn` rule it overrides. Both selectors
  are 1-1-0, so source order alone decides the winner — a reorder that changes
  no rule text would restore the collapse invisibly.

Each one was control-run: a full basis swapped back to `flex:1 1 0`, the
selector narrowed to the class, white-space dropped, and the rule moved above
the generic one each turn the matching assertion red (4, 28, 4 and 4
respectively), and the source-order control turns red on that assertion alone.

Two further fixes were examined and deliberately left untested, rather than
covered with assertions that would pass regardless:

- clearstatcache() in Geolocation::database_fingerprint(). Removing it keeps
  every test green because the premise does not reproduce here: on PHP 8.4
  filesize() returns the new length after file_put_contents() and even after an
  external writer, so the stale-stat condition the line defends against is not
  observable. Worth knowing that the existing "database replaced -> different
  fingerprint" assertion does not prove that line either: it writes through a
  helper that clears the stat cache itself.
- the `degraded` copy that distinguishes probe_failed from
  key_without_database. The reason code it branches on already has three unit
  assertions; reaching the state from the browser needs a fake MaxMind licence
  key and a deliberately broken database planted on the test site, which is a
  poor trade for one `if` on a string.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: fabiodalez-dev/FAZ-Cookie-Manager/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c331f154-d7b4-4ec4-8013-44cbff46b17f
📥 Commits

Reviewing files that changed from the base of the PR and between be73426 and d452bad.

📒 Files selected for processing (1)
  • tests/unit/test-mobile-compact-css-php.php
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues. Two small rough edges, both in the new test.

Reviewed changes

I reviewed the new unit coverage for the compact-layout Do-Not-Sell rule against the production rule at frontend/class-frontend.php ([data-faz-tag="donotsell-button"]{flex:1 1 100%;width:100%;display:block;white-space:normal;}). The suite passes locally (97/97).

  • Do-Not-Sell rule pinned per banner type: the new checks cover the rule's existence, its four declarations, the attribute-based selector, and that it comes after the generic .faz-btn rule in source order.

ℹ️ Nitpicks

  • tests/unit/test-mobile-compact-css-php.php:191 — the comment calls both selectors 1-1-0, but #faz-consent .faz-notice-btn-wrapper .faz-btn is one id plus two classes, so it is 1-2-0. The attribute selector also counts as a class, so the DNS rule is 1-2-0 as well. The conclusion still holds because the two are tied and source order decides, and line 145 of the same file already uses 1-2-0 for the equivalent selector.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread tests/unit/test-mobile-compact-css-php.php
@fabiodalez-dev
fabiodalez-dev merged commit 8f5c505 into main Oct 6, 2026
10 checks passed
@fabiodalez-dev
fabiodalez-dev deleted the test/compact-donotsell-coverage branch October 6, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant