Skip to content

Snapshots: formatting that hides changes (HTML, JSON-LD, JSON numbers) #116

Open

Description

@temp

Part of #101. Line numbers refer to branch chore/php-8.4-dependabot (#98). Verified = reproduced, suspected = from reading the code.

Fixing these changes snapshot contents. Users run UPDATE_SNAPSHOTS=1 once and review the content diffs. Do this separately from the name migration. Alternatively, make the stricter formatting opt-in.

  • snapshotFormatHtml() (SnapshotTrait.php:299) runs tidy with its defaults. Verified.
    • drop-empty-elements removes <i class="icon-warning"></i>, and the test still passes.
    • Broken markup is repaired, so <p>a<p>b matches <p>a</p><p>b</p>.
    • Fragments are wrapped in <!DOCTYPE html><html><head><title></title>….
  • JSON-LD turns {} into [], because snapshotFormatJsonLd() (:264) decodes with json_decode($string, true), so {"a":[]} matches a snapshot of {"a":{}}. Verified.
  • JSON numbers lose precision or type, because snapshotFormatJson() (:253) has no JSON_BIGINT_AS_STRING / JSON_PRESERVE_ZERO_FRACTION. 12345678901234567890 is stored as 1.2345678901234567e+19, and 1.0 equals 1. Verified.

Breaking: snapshot contents change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions