trmnl_preview 0.17.2 → 0.18.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/lib/trmnlp/testing/publishable_recipe.rb +34 -0
- data/lib/trmnlp/testing/rspec.rb +1 -0
- data/lib/trmnlp/version.rb +1 -1
- data/templates/init/tests/plugin_spec.rb +2 -12
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53759b5b952609676a6313c40932bf0aa015ba665044fa2dae6d6dd25e96dfc1
|
|
4
|
+
data.tar.gz: 906e518e4193951665996a4ed7a49ff07e94cfec35269412f6fe2a172b1ae4c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51e39569a0ade12fc7f435176438ce3319adbaac3f613a4b36f441b3c01e7a89917f5df96395a62ad3a7a1dce3efb1e021847e1178afe84c47cdabfbec9b6f9d
|
|
7
|
+
data.tar.gz: a7b3b71f8fb839bca061a9b2083622d076f9290a6f4f128cacaea34b36cc6e0833ea3ae7876b13358dc7670c4fb71a6b973564866614474893efdd5715f898f8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.18.0
|
|
5
|
+
|
|
6
|
+
- `it_behaves_like 'a publishable recipe'` checks what a recipe should hold before it is published: every view draws without overflow or page errors on the TRMNL OG (1-bit and 2-bit) and the TRMNL X (landscape and portrait), and the transform runs without error within TRMNL's limits. `trmnlp init`'s starter spec uses it. (#176)
|
|
7
|
+
|
|
4
8
|
## 0.17.2
|
|
5
9
|
|
|
6
10
|
- `trmnlp test` no longer inlines a stylesheet link inside a script's string, such as a CDN fallback written with `document.write`. It broke the script, and every render came out blank. (#174)
|
data/README.md
CHANGED
|
@@ -473,7 +473,7 @@ See [TRMNL documentation](https://help.trmnl.com/en/articles/10542599-importing-
|
|
|
473
473
|
|
|
474
474
|
## Testing Plugins
|
|
475
475
|
|
|
476
|
-
`trmnlp init` starts a plugin with `tests/plugin_spec.rb` (
|
|
476
|
+
`trmnlp init` starts a plugin with `tests/plugin_spec.rb` (`it_behaves_like 'a publishable recipe'`, below) and a GitHub workflow that runs it in the `trmnl/trmnlp` image, uploads the report, can rewrite the snapshots on a manual run, and pushes to TRMNL only once lint and tests pass. `trmnlp test` runs the RSpec files in your plugin's `tests/` folder, through the same pipeline `serve` and `build` use, with fake APIs and a fixed clock:
|
|
477
477
|
|
|
478
478
|
```ruby
|
|
479
479
|
# tests/weather_spec.rb
|
|
@@ -505,6 +505,7 @@ end
|
|
|
505
505
|
- `mocks:` answer every request the run makes: polling urls, and the transform's own requests in any language, HTTPS included. Keys are urls, with `*` wildcards, a Regexp, or a method first (`'POST https://...'`). Values are `{ json:, body:, status:, headers:, delay:, body_delay:, advance_clock:, error: :reset }` (times in seconds: `body_delay:` sends the headers first and the body later, `advance_clock:` moves the transform's clock on when it answers), a string body, a lambda that takes the request, or an array of answers used in order. An unmocked request gets a 599. `requests` lists every request with its `status`, and `aborted: true` for one the transform gave up on before its answer arrived; `duration_ms` is how long the transform ran.
|
|
506
506
|
- `now:` starts every clock: Liquid's, the markup's scripts', and the transform's, through libfaketime (`brew install libfaketime` or `apt-get install libfaketime`; already in the Docker image). On macOS the interpreter must come from brew, mise or similar, since macOS will not hand libfaketime to its own `/usr/bin` binaries.
|
|
507
507
|
- `trmnlp test --report report` also writes `report/index.html` and `report/report.json`: every example with each screen it rendered (with a switch that outlines every drawn box, and the page's problems) and each transform it ran (time, memory, requests). Under GitHub Actions the counts and failures go to the run's summary too.
|
|
508
|
+
- `it_behaves_like 'a publishable recipe'` is what a recipe should hold before it is published: every view draws without overflow or page errors on the TRMNL OG (1-bit and 2-bit) and the TRMNL X (landscape and portrait), and the transform runs without error within TRMNL's limits. It uses the group's `mocks` and `custom_fields` when the group defines them; `screens: [{ device: 'kobo_libra_2' }, ...]` draws on other devices.
|
|
508
509
|
- `match_snapshot` stores a missing snapshot under `tests/snapshots/<os>/` and fails one on CI; `trmnlp test --update` rewrites them. Fonts render differently per operating system, so run tests in the Docker image when CI should share your snapshots. `fit_image_size_limit` checks the PNG against the model's limit.
|
|
509
510
|
|
|
510
511
|
## Development
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TRMNLP
|
|
4
|
+
module Testing
|
|
5
|
+
# The screens a recipe is drawn on: TRMNL's own devices, and a portrait screen.
|
|
6
|
+
PUBLISHABLE_RECIPE_SCREENS = [
|
|
7
|
+
{ device: 'og_png' }, { device: 'og_plus' }, { device: 'v2' }, { device: 'v2', orientation: :portrait }
|
|
8
|
+
].freeze
|
|
9
|
+
PUBLISHABLE_RECIPE_VIEWS = %w[full half_horizontal half_vertical quadrant].freeze
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
RSpec.shared_examples 'a publishable recipe' do |screens: TRMNLP::Testing::PUBLISHABLE_RECIPE_SCREENS|
|
|
14
|
+
let(:recipe_inputs) do
|
|
15
|
+
{ mocks: respond_to?(:mocks) ? mocks : {}, custom_fields: respond_to?(:custom_fields) ? custom_fields : {} }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
TRMNLP::Testing::PUBLISHABLE_RECIPE_VIEWS.product(screens).each do |view, screen|
|
|
19
|
+
device = screen[:device].is_a?(Hash) ? screen[:device][:model] : screen[:device]
|
|
20
|
+
screen_name = [device, screen[:orientation]].compact.join(' ')
|
|
21
|
+
|
|
22
|
+
it "draws the #{view} view on #{screen_name} without overflow or page errors" do
|
|
23
|
+
expect(trmnl.render(view:, **screen, **recipe_inputs)).to have_no_overflow.and have_no_problems
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'runs its transform without error' do
|
|
28
|
+
expect(trmnl.transform(device: screens.first[:device], **recipe_inputs).error).to be_nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "stays within TRMNL's serverless limits" do
|
|
32
|
+
expect(trmnl.transform(device: screens.first[:device], **recipe_inputs)).to stay_within_serverless_limits
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/trmnlp/testing/rspec.rb
CHANGED
data/lib/trmnlp/version.rb
CHANGED
|
@@ -10,18 +10,8 @@ RSpec.describe 'My Plugin' do
|
|
|
10
10
|
# The values of the custom fields in src/settings.yml to test with.
|
|
11
11
|
let(:custom_fields) { {} }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
screen = trmnl.render(view:, mocks:, custom_fields:)
|
|
16
|
-
|
|
17
|
-
expect(screen).to have_no_overflow
|
|
18
|
-
expect(screen).to have_no_problems
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "stays within TRMNL's serverless limits" do
|
|
23
|
-
expect(trmnl.transform(mocks:, custom_fields:)).to stay_within_serverless_limits
|
|
24
|
-
end
|
|
13
|
+
# Every view on TRMNL's devices without overflow or page errors, and the transform within TRMNL's limits.
|
|
14
|
+
it_behaves_like 'a publishable recipe'
|
|
25
15
|
|
|
26
16
|
# A picture of the full view, compared pixel for pixel on every run. Record it once with
|
|
27
17
|
# `trmnlp test --update` (or the workflow's update_snapshots run) and commit tests/snapshots.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trmnl_preview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rockwell Schrock
|
|
@@ -468,6 +468,7 @@ files:
|
|
|
468
468
|
- lib/trmnlp/testing/mock_table.rb
|
|
469
469
|
- lib/trmnlp/testing/node_version.rb
|
|
470
470
|
- lib/trmnlp/testing/plugin.rb
|
|
471
|
+
- lib/trmnlp/testing/publishable_recipe.rb
|
|
471
472
|
- lib/trmnlp/testing/report.html.erb
|
|
472
473
|
- lib/trmnlp/testing/report.rb
|
|
473
474
|
- lib/trmnlp/testing/rspec.rb
|