capybara-simulated 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d70e169d98f5ead094c27e37f8f19fa01a3ea84aa7d808cf62a5d6dcbe3bf811
4
- data.tar.gz: 50c9c13da2f7dfcc558fd7b92617bcf39ac45db930965e7152b632951bfc3770
3
+ metadata.gz: b21cf25ccc5ea5f71a58a5f90574e5eef7c3d4aa1c98130903a8544e909ae8c3
4
+ data.tar.gz: df8dee2d6b76a7d1169528be7bea9e7388c5cdd53d72c5132fd1b3202bc2a301
5
5
  SHA512:
6
- metadata.gz: c7856b38b6376c6d5ac68065757f4beccac1b13a1bfd97c4453d2c8f1597ba0c82de66ec5e227ee703a185ca76758f8484e6e5b7ac72a5f90f493bb8d30f5049
7
- data.tar.gz: b66c174eca3a6f89bdbc0df104cf302e212a0f3a63d72872b41a11b44d9fcd0b5d18c77d17ce0cb8f99b7bab24b01a4c81085942835deed19b66084a3d7a961b
6
+ metadata.gz: bb4a36189857d7415215ccf693b9a9cb14432a2dc8ed2bc48c229bdbea935ef686b05335e72fdec1c9293b552818193f9c201b8a73ed8f6f745b00094e6ae902
7
+ data.tar.gz: 289fb6ab851e0e300df8f558777e18822b3f5478730c35e37095504e86e479091b8c1bdb08c5e7440fb03ff08c4c4a68532538e6c74976f8053099a11b24c8d6
data/README.md CHANGED
@@ -20,7 +20,7 @@ capybara-simulated is not a complete replacement for real-browser testing. But i
20
20
  - **Deterministic** — a virtual clock and synchronous in-process execution remove the wall-clock timing, network, and rendering races that make headless-browser suites flaky.
21
21
  - **Real front-end JS runs**: inline `<script>` + event handlers, MutationObserver, custom elements, `<template>`, Shadow DOM, ES modules importmap, **Hotwire (Stimulus + Turbo)**, Trix.
22
22
  - **Drop-in**: the Capybara DSL is unchanged — register `:simulated` and go. Just this gem plus one JS-engine gem.
23
- - **Held to spec**: a vendored [web-platform-tests](https://github.com/web-platform-tests/wpt) conformance gate (the same DOM / HTML tests Chromium and Firefox hold themselves to), plus the full system suites of five real apps — Redmine / Forem / Avo / Mastodon / Discourse — run against the driver in [capybara-simulated-vs-world](https://github.com/ursm/capybara-simulated-vs-world).
23
+ - **Held to spec**: a vendored [web-platform-tests](https://github.com/web-platform-tests/wpt) conformance gate the same DOM / HTML tests Chromium and Firefox hold themselves to, their reference tests included (the driver renders both the test and its reference and compares the two images) — plus the full system suites of five real apps — Redmine / Forem / Avo / Mastodon / Discourse — run against the driver in [capybara-simulated-vs-world](https://github.com/ursm/capybara-simulated-vs-world).
24
24
 
25
25
  **Reach for a real browser** (Selenium / Cuprite) **when** your tests need what this driver doesn't simulate **by design** — there's no rendering engine, so **pixel-accurate rendering** (glyph shaping — kerning, ligatures, bidi — the real line-breaking algorithm, multi-line `flex-wrap`) is out. `save_screenshot` does paint a real PNG, but it paints what the layout engine believes — enough to see what a test saw, not a visual-regression baseline. There *is* a coarse box-layout engine — enough that `getBoundingClientRect()`, `elementFromPoint()`, `obscured?`, the spatial selectors, scrolling, and drag-and-drop all work against real boxes — but it answers "where is this, roughly, and what's on top", not "how would this render".
26
26
 
@@ -42,7 +42,9 @@ module Capybara
42
42
  # racing reader sees is a partial `stored_at`/`max_age` pair on `refresh`: freshness
43
43
  # computed against a transient mix, never a corrupted structure.
44
44
  class AssetCache
45
- Entry = Struct.new(:status, :headers, :body, :stored_at, :max_age, :no_cache, :immutable, keyword_init: true) do
45
+ # `encoded`: the body's size on the wire before a Content-Encoding was undone — what a
46
+ # cache hit's Resource Timing entry reports as `encodedBodySize`.
47
+ Entry = Struct.new(:status, :headers, :body, :stored_at, :max_age, :no_cache, :immutable, :encoded, keyword_init: true) do
46
48
  # `must-revalidate` (RFC 9111 §5.2.2.2) only forbids reusing a
47
49
  # response *once it has become stale* without revalidation — it
48
50
  # does NOT force revalidation while the entry is still fresh, and
@@ -111,7 +113,7 @@ module Capybara
111
113
  @entries.select! {|_, e| e.immutable }
112
114
  end
113
115
 
114
- def store(url, status, headers, body)
116
+ def store(url, status, headers, body, encoded: nil)
115
117
  return unless CACHEABLE_STATUSES.include?(status)
116
118
  h = ensure_lowercase(headers)
117
119
  return unless vary_compatible?(h['vary'])
@@ -136,7 +138,8 @@ module Capybara
136
138
  stored_at: Time.now,
137
139
  max_age: max_age,
138
140
  no_cache: cc[:no_cache],
139
- immutable: cc[:immutable] == true
141
+ immutable: cc[:immutable] == true,
142
+ encoded: encoded
140
143
  )
141
144
  end
142
145