trmnlp-test 0.1.2 → 0.1.4

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: cfefb51546891c33222e11f7c2ba094168787d9207966a1addbc307462290fd2
4
- data.tar.gz: 4323d3400e827f4d88913f1d624ccf7d64bd65e0f15428add123b8c3af01e782
3
+ metadata.gz: 919b1bf33568827657d00e7b935d0253bfb0e7a9384d9be057cb665c97fa5f96
4
+ data.tar.gz: 92608945975bad2ed2748a732b24ad2bd2a1cc899c1ebb49fa1ca8329e07dad3
5
5
  SHA512:
6
- metadata.gz: 2b4b67e735b844dc2510eac564e98a825217516709ef67fd68e78294ffddb40bdc99075045e1390b09dde904e3bc2311b8974ffa1d70bf230f4ab6d36b1996a1
7
- data.tar.gz: 6b590003ac56c97e22392b85376d3fcce7bb22d172e25636a02489ac9a0304b8c3d6ed83c7c8b9f5e8a06b2598379607b872e4bdf82085827686f617a78f9a67
6
+ metadata.gz: c60c6424e6d751d3634da01e3f88b26eeb5090f8c00af4d83014c19aa3f8c195589c070721c9ce9f3978b662f8f91fd10ec51aaee862a076337ac3d3f734bb80
7
+ data.tar.gz: c02bcabd8a0e2541168db2b4793cab321ab91f3b94b49433e3ebb3f87381578304ebba11125b08cc9fa2d4a7a9b920d59fc58d0d855462c4e46b0b00dd03c73f
data/README.md CHANGED
@@ -23,6 +23,7 @@ trmnlp-test init # trmnlp-test.config.js + test/trmnl/plugin.spec.
23
23
  trmnlp-test # run; Playwright args pass through (-g, --update-snapshots)
24
24
  trmnlp-test models | versions # device models / framework versions
25
25
  trmnlp-test update # pull the image now (otherwise at most once a day)
26
+ trmnlp-test help | --version # all commands and options / versions of trmnlp-test, trmnlp, Playwright
26
27
  ```
27
28
 
28
29
  `--repo DIR` runs against another directory. `--mount DIR` mounts an extra directory.
@@ -52,7 +53,9 @@ const { test, expect, matrix, VIEWS, DEVICES, FRAMEWORK } = require('trmnlp-test
52
53
 
53
54
  test('menu', async ({ trmnl }) => {
54
55
  const screen = await trmnl.render({
55
- device: 'og_plus', view: 'full', // any model, orientation: 'portrait', palette, darkMode, theme, scale, textScale, fonts, framework
56
+ device: 'og_plus', view: 'full', // any model, orientation: 'portrait', palette, theme, scale, textScale, fonts, framework
57
+ darkMode: true, // as the server does it: everything inverted except images ('framework': the v3 class only)
58
+ server: true, // TRMNL's quirks: { qr: 'server' | 'fixed', crlf: true }
56
59
  fields: { data_source: 'webhook' }, // custom field values (defaults + .trmnlp.yml + these)
57
60
  webhook: { merge_variables: {...} }, // or data: {...} to render given data as is
58
61
  mocks: { 'https://api.example.com/*': { temp: 21 } },
@@ -63,6 +66,7 @@ test('menu', async ({ trmnl }) => {
63
66
  await expect(screen.locator('[data-row]')).toHaveCount(7); // any Playwright locator assertion
64
67
  await expect(screen).toHaveNoOverflow();
65
68
  await expect(screen).toHaveNoOverlap('.title', 'img');
69
+ await expect(screen).toShowText('Espresso'); // visible: not cut off by an ellipsis, clamp or the edge ({ visible: false }: content only)
66
70
  await expect(screen).toHaveQr('BCD\n002...');
67
71
  await expect(screen).toMatchScreen(); // PNG snapshot (--update-snapshots)
68
72
  await expect(screen).toFitDeviceImageLimit();
@@ -88,6 +92,8 @@ for (const s of matrix({ device: DEVICES.representative, view: VIEWS, darkMode:
88
92
  }
89
93
  ```
90
94
 
95
+ **Where the server differs from trmnlp.** trmnlp-test renders with trmnlp's code, so it shares trmnlp's differences from TRMNL's server. The ones seen on trmnl.com are built in: `server: { qr: 'server' }` (the `qr_code` filter ignores "responsive" and returns the viewBox plus its natural width/height and `style="max-width:100%;height:auto"`) and `{ crlf: true }` (the web editor's preview made the template's newlines CR LF, so a newline typed in the template no longer matches `\n` in data). `{ qr: 'fixed' }` (a size and no viewBox) has not been seen and is there for robustness. `server: true` applies the seen ones. `matrix({ server: SERVER.variants })` renders each on its own. Dark mode follows what the server shows (inverted, images kept) rather than the v3 class, which leaves inline SVG and hard-coded colours as they are; `darkMode: 'framework'` renders the class only.
96
+
91
97
  Other helpers: `trmnl.plugin('other/dir')`, `trmnl.lint()` with `toPassLint({ allow })`, `FRAMEWORK.majors()`, `FRAMEWORK.latestOf('2')`.
92
98
 
93
99
  ## How it works
@@ -96,5 +102,5 @@ See [docs/README.md](docs/README.md) for diagrams of the components, a render, s
96
102
 
97
103
  ## Examples and self-tests
98
104
 
99
- - `examples/payment-qr`: the payment QR plugin, current Liquid version and the earlier webhook + serverless version (53 tests).
105
+ - `examples/payment-qr`: the earlier webhook + serverless version of the payment QR plugin (the current version tests itself with trmnlp-test in its own repository).
100
106
  - `test/self`: fixture plugins for every strategy and language (86 tests). Run with `bin/trmnlp-test run --root test/self`.
data/exe/trmnlp-test CHANGED
@@ -19,9 +19,19 @@ while %w[--repo --mount].include?(args.first)
19
19
  flag == '--repo' ? repo = path : mounts += ['-v', "#{path}:#{path}"]
20
20
  end
21
21
 
22
+ USAGE = File.read(File.expand_path('../lib/trmnlp_test/usage.txt', __dir__))
23
+ args[0] = { '-h' => 'help', '--help' => 'help', '-v' => 'version', '--version' => 'version' }.fetch(args[0], args[0]) if args.any?
22
24
  case args.first
25
+ when 'help'
26
+ puts USAGE
27
+ exit
23
28
  when 'version'
24
- puts "trmnlp-test #{TrmnlpTest::VERSION} (#{image})"
29
+ puts "launcher #{TrmnlpTest::VERSION}, image #{image}"
30
+ if system('docker', 'image', 'inspect', image, out: File::NULL, err: File::NULL)
31
+ exec 'docker', 'run', '--rm', image, 'version'
32
+ else
33
+ puts 'image not pulled yet (trmnlp-test update)'
34
+ end
25
35
  exit
26
36
  when 'update'
27
37
  exec 'docker', 'pull', image
@@ -34,13 +44,14 @@ FileUtils.mkdir_p(cache)
34
44
 
35
45
  # a missing image is pulled; a :latest image is refreshed at most once a day
36
46
  present = system('docker', 'image', 'inspect', image, out: File::NULL, err: File::NULL)
37
- stamp = File.join(cache, '.pulled-' + image.gsub(/[^A-Za-z0-9.]+/, '_'))
47
+ # the stamp names the launcher version too: a new launcher pulls at once, it may need a newer image
48
+ stamp = File.join(cache, ".pulled-#{TrmnlpTest::VERSION}-" + image.gsub(/[^A-Za-z0-9.]+/, '_'))
38
49
  stale = image.end_with?(':latest') && (!File.exist?(stamp) || Time.now - File.mtime(stamp) > 86_400)
39
50
  if !present || (stale && !ENV['TRMNLP_TEST_NO_PULL'])
40
- warn "trmnlp-test: pulling #{image}"
41
- pulled = system('docker', 'pull', '-q', image, out: File::NULL)
51
+ warn "trmnlp-test: pulling #{image}" unless present
52
+ pulled = system('docker', 'pull', '-q', image, out: File::NULL, err: present ? File::NULL : $stderr)
42
53
  abort("trmnlp-test: could not pull #{image}") if !pulled && !present
43
- FileUtils.touch(stamp) if pulled
54
+ FileUtils.touch(stamp) # checked today, whether or not the registry had it
44
55
  end
45
56
  entry = []
46
57
  if args.first == 'shell'
@@ -0,0 +1,30 @@
1
+ Usage: trmnlp-test [options] [command] [args]
2
+
3
+ Tests TRMNL plugins in the trmnlp format, in Docker.
4
+
5
+ Commands:
6
+ run [playwright args] run the tests (default), e.g. -g "dark", --update-snapshots, -j 4
7
+ init create trmnlp-test.config.js and test/trmnl/plugin.spec.js
8
+ models list the TRMNL device models and their palettes
9
+ versions list the TRMNL framework versions
10
+ refresh re-download models, palettes and framework versions
11
+ update pull the newest image now (otherwise at most once a day)
12
+ shell open a shell in the image
13
+ version show the versions of trmnlp-test, trmnlp and Playwright
14
+ help show this help (run --help: the Playwright test options)
15
+
16
+ Options:
17
+ --repo DIR the plugin repository (default: the current directory)
18
+ --mount DIR also mount DIR into the container (repeatable)
19
+ --root DIR the directory with trmnlp-test.config.js, inside the repository
20
+ --report DIR where the report goes (default: config "report")
21
+ -h, --help show this help
22
+ -v, --version show versions
23
+
24
+ Environment:
25
+ TRMNLP_TEST_WORKERS parallel workers, a number or "50%" (default: half the CPUs)
26
+ TRMNLP_TEST_IMAGE image to run (default: ghcr.io/excusemi/trmnlp-test:latest)
27
+ TRMNLP_TEST_CACHE_DIR cache directory (default: ~/.cache/trmnlp-test)
28
+ TRMNLP_TEST_NO_PULL=1 never pull the image automatically
29
+
30
+ Docs: https://github.com/ExcuseMi/trmnlp-test
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TrmnlpTest
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.4'
5
5
  IMAGE = 'ghcr.io/excusemi/trmnlp-test'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnlp-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ExcuseMi
@@ -21,6 +21,7 @@ files:
21
21
  - LICENSE
22
22
  - README.md
23
23
  - exe/trmnlp-test
24
+ - lib/trmnlp_test/usage.txt
24
25
  - lib/trmnlp_test/version.rb
25
26
  homepage: https://github.com/ExcuseMi/trmnlp-test
26
27
  licenses: