trmnlp-test 0.1.12 → 0.1.14

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: 5ffe95db896ea1660559f274107340be575fe8e2a38b889b5f4e4a33c28aa605
4
- data.tar.gz: fab39d295adc996cd8e3eb7e279c80c77d2164f6fd37e699779b3a8b347cccfb
3
+ metadata.gz: 81bdf6b5992e4c2c35cf556f5d7fc4cd10eec6f69d5785c90a9e4b929ea9cfd8
4
+ data.tar.gz: 40b128c6952097961a9aa169e0b3ea7c00d4e5492c2f0127acb82304af1b61fc
5
5
  SHA512:
6
- metadata.gz: ab880b2b0441109463d27911eb72f301ab83cbc28658790ace66fd1ea7855371808310341d386c5b11ffb625b6dde2ea57367e2c4d7236a0b09ebc40463fbd10
7
- data.tar.gz: 19d06af41c7831ee922e611cc7363df6739b90b036135a0c3781671e61fca8604401d47476edac5beee91b026afef9d709159fda06a652bcf082f388ed10f90d
6
+ metadata.gz: cb8579d76f4a7e5ffa88d96aedb25775640d5852a668e2ca5344aa4486e3a75e9e249fcd37be51a27f97cd018183113d0e87e67f6284d5774e140b0dd0c66331
7
+ data.tar.gz: dacdf85d2739ab2b6848ecb5e54d94c769c7064892416a3e9815cb22fa1b560f74a597095d3c8d81cf4361eb183d109881e53801a0d459bd0769efc40ede7052
data/README.md CHANGED
@@ -23,6 +23,8 @@ 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 views.spec # only some tests (a file or a filter); Playwright args pass through
27
+ trmnlp-test run -- --rebaseline # args after -- reach the specs: require('trmnlp-test').args
26
28
  trmnlp-test help | --version # all commands and options / versions of trmnlp-test, trmnlp, Playwright
27
29
  ```
28
30
 
@@ -88,6 +90,7 @@ test('menu', async ({ trmnl }) => {
88
90
  await expect(screen).toHaveQr('BCD\n002...'); // black on white; { inverted: true | 'any' } for dark codes
89
91
  await expect(screen).toMatchScreen(); // PNG snapshot (--update-snapshots)
90
92
  await expect(screen).toFitDeviceImageLimit();
93
+ await expect(screen).toMatchReference('refs/photo.png', { selector: '.dial', refRect, minIoU: 0.93 }); // diff attached
91
94
  const png = await screen.png(); // pixel(x,y), colors(), inkRatio(rect), inkBounds(), crop()
92
95
  });
93
96
 
@@ -110,11 +113,13 @@ for (const s of matrix({ device: DEVICES.representative, view: VIEWS, darkMode:
110
113
  }
111
114
  ```
112
115
 
116
+ **Extending:** add matchers with `expect.extend` and fixtures with `test.extend` (Playwright's own mechanisms), and plugin-wide rules with `checks: ['test/trmnl/checks.js']` in the config. Checks run after every render, and `toRenderCleanly` reports their problems. See [docs/SPEC.md](docs/SPEC.md#91-extending).
117
+
113
118
  Other helpers: `trmnl.plugin('other/dir')`, `trmnl.lint()` with `toPassLint({ allow })`, `FRAMEWORK.majors()`, `FRAMEWORK.latestOf('2')`.
114
119
 
115
120
  ## How it works
116
121
 
117
- See [docs/README.md](docs/README.md) for diagrams of the components, a render, sessions and the file structure.
122
+ See [docs/README.md](docs/README.md) for diagrams and [docs/SPEC.md](docs/SPEC.md) for the full specification.
118
123
 
119
124
  ## Examples and self-tests
120
125
 
data/exe/trmnlp-test CHANGED
@@ -2,7 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Runs trmnlp-test (a Docker image) against a TRMNL plugin repository.
5
- # trmnlp-test [--repo DIR] [--mount DIR]... [run|init|models|versions|refresh|update|shell|version] [playwright args]
5
+ # trmnlp-test [run|init|models|versions|refresh|update|shell|version|help] [args] [-- spec args]
6
+ # --repo DIR, --mount DIR and --env NAME[=VALUE] are taken from anywhere before `--`.
6
7
  require 'etc'
7
8
  require 'fileutils'
8
9
  require_relative '../lib/trmnlp_test/version'
@@ -11,12 +12,25 @@ require_relative '../lib/trmnlp_test/version'
11
12
  image = ENV.fetch('TRMNLP_TEST_IMAGE', "#{TrmnlpTest::IMAGE}:latest")
12
13
  repo = Dir.pwd
13
14
  mounts = []
14
- args = ARGV.dup
15
- while %w[--repo --mount].include?(args.first)
16
- flag, dir = args.shift(2)
17
- abort "trmnlp-test: #{flag} needs a directory" unless dir
18
- path = File.realpath(dir)
19
- flag == '--repo' ? repo = path : mounts += ['-v', "#{path}:#{path}"]
15
+ # the container sees TRMNLP_TEST_* and CI; --env NAME[=VALUE] passes more
16
+ env = %w[CI FORCE_COLOR].flat_map { |k| ['-e', k] } + ENV.keys.grep(/\ATRMNLP_TEST_/).flat_map { |k| ['-e', k] }
17
+ args = []
18
+ rest = ARGV.dup
19
+ until rest.empty?
20
+ arg = rest.shift
21
+ if arg == '--'
22
+ args.push(arg, *rest)
23
+ break
24
+ elsif %w[--repo --mount --env].include?(arg)
25
+ value = rest.shift or abort("trmnlp-test: #{arg} needs a value")
26
+ case arg
27
+ when '--repo' then repo = File.realpath(value)
28
+ when '--mount' then (path = File.realpath(value)) && mounts.push('-v', "#{path}:#{path}")
29
+ else env.push('-e', value)
30
+ end
31
+ else
32
+ args << arg
33
+ end
20
34
  end
21
35
 
22
36
  USAGE = File.read(File.expand_path('../lib/trmnlp_test/usage.txt', __dir__))
@@ -59,6 +73,5 @@ if args.first == 'shell'
59
73
  entry = ['--entrypoint', 'bash']
60
74
  end
61
75
  tty = $stdout.tty? ? ['-t'] : []
62
- env = %w[CI TRMNLP_TEST_DEBUG TRMNLP_TEST_WORKERS TRMNLP_TEST_SHOW_DIFFERENCES FORCE_COLOR].flat_map { |k| ['-e', k] }
63
76
  exec 'docker', 'run', '--rm', '-i', *tty, '--init', '--ipc=host', '-u', "#{Process.uid}:#{Process.gid}",
64
77
  '-v', "#{repo}:#{repo}", '-w', repo, '-v', "#{cache}:/cache", *mounts, *env, *entry, image, *args
@@ -1,9 +1,10 @@
1
- Usage: trmnlp-test [options] [command] [args]
1
+ Usage: trmnlp-test [command] [args] [options] [-- spec args]
2
2
 
3
3
  Tests TRMNL plugins in the trmnlp format, in Docker.
4
4
 
5
5
  Commands:
6
- run [playwright args] run the tests (default), e.g. -g "dark", --update-snapshots, -j 4
6
+ run [playwright args] run the tests (default), e.g. -g "dark", --update-snapshots, -j 4;
7
+ a spec file or filter in first place runs those: trmnlp-test views.spec
7
8
  init create trmnlp-test.config.js and test/trmnl/plugin.spec.js
8
9
  models list the TRMNL device models and their palettes
9
10
  versions list the TRMNL framework versions
@@ -18,6 +19,9 @@ Options:
18
19
  --mount DIR also mount DIR into the container (repeatable)
19
20
  --root DIR the directory with trmnlp-test.config.js, inside the repository
20
21
  --report DIR where the report goes (default: config "report")
22
+ --env NAME[=VALUE] pass an environment variable to the specs (repeatable);
23
+ TRMNLP_TEST_* variables always pass
24
+ -- ARGS everything after -- reaches the specs as require('trmnlp-test').args
21
25
  -h, --help show this help
22
26
  -v, --version show versions
23
27
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TrmnlpTest
4
- VERSION = '0.1.12'
4
+ VERSION = '0.1.14'
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.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - ExcuseMi