@webship-js/meilisearch-steps 0.0.0-stage → 2.0.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.
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/assets/logo.svg +1 -0
- package/demo/books.json +502 -0
- package/package.json +69 -4
- package/tests/features/dashboard.feature +16 -0
- package/tests/features/indexes.feature +38 -0
- package/tests/features/keys.feature +27 -0
- package/tests/step-definitions/meilisearch-dashboard.steps.js +163 -0
- package/tests/step-definitions/meilisearch-indexes.steps.js +213 -0
- package/tests/step-definitions/meilisearch-keys.steps.js +122 -0
- package/tests/step-definitions/meilisearch-support.js +159 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Webship.co
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,219 @@
|
|
|
1
|
-
#
|
|
1
|
+
# meilisearch-steps
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center"><img src="https://raw.githubusercontent.com/webship/meilisearch-steps/2.0.x/assets/logo.svg" alt="Meilisearch logo" width="96"></p>
|
|
4
|
+
|
|
5
|
+
Cucumber step definitions for the Meilisearch search engine, for [webship-js](https://webship.co/docs/webship-js/2.0.x),
|
|
6
|
+
a BDD browser automation harness built on Playwright and Cucumber-js.
|
|
7
|
+
|
|
8
|
+
A search engine is used two ways: through its REST API, where every write is a task the steps wait for, and through its
|
|
9
|
+
own dashboard in the browser. The steps do both, and keep every key out of their words, their messages and their
|
|
10
|
+
failures:
|
|
11
|
+
|
|
12
|
+
- **indexes:** made from a JSON file of documents (deleted at the scenario's end), counted, deleted; their filterable,
|
|
13
|
+
sortable and searchable attributes and synonyms;
|
|
14
|
+
- **searches through the API:** typo-tolerant hits, filters, sorts (the first hit read), facets counted, highlighting;
|
|
15
|
+
- **the dashboard:** opened with the master key (handed to the page in memory, never typed in a step), an index chosen,
|
|
16
|
+
a search typed, a hit shown or none, and no request sent outside the site's own address;
|
|
17
|
+
- **keys:** one made with limited actions and indexes (deleted at the scenario's end); a request with it, with the
|
|
18
|
+
master key, or with none, and the answer's status and error code (401 without a key, 403 outside its rights);
|
|
19
|
+
- **the server:** its health and its version.
|
|
20
|
+
|
|
21
|
+
No step phrase names the platform: a scenario reads `Given the search engine has the index "books" with the documents
|
|
22
|
+
of "demo/books.json"` and `Then the search engine should answer 403 "invalid_api_key"`.
|
|
23
|
+
|
|
24
|
+
## Requirements
|
|
25
|
+
|
|
26
|
+
- Node.js 24 or newer.
|
|
27
|
+
- webship-js 2.0.20 or newer.
|
|
28
|
+
- A Meilisearch server with a master key. Meilisearch 1.59 and 1.55 are the two lines this pack is proven on. The
|
|
29
|
+
dashboard steps need it in development mode (`MEILI_ENV=development`), the mode that serves the dashboard; every
|
|
30
|
+
other step works in production mode too, which a public site should run in.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install --save-dev @webship-js/meilisearch-steps
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
List its step definitions in `cucumber.js`, after webship-js's own, and give it the master key from the environment:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
require: [
|
|
42
|
+
'node_modules/webship-js/tests/step-definitions/**/*.js',
|
|
43
|
+
'node_modules/@webship-js/meilisearch-steps/tests/step-definitions/**/*.js',
|
|
44
|
+
'tests/step-definitions/**/*.js',
|
|
45
|
+
],
|
|
46
|
+
worldParameters: {
|
|
47
|
+
launchUrl: 'http://127.0.0.1:7700',
|
|
48
|
+
meilisearch: {
|
|
49
|
+
masterKey: process.env.MEILISEARCH_MASTER_KEY,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```gherkin
|
|
57
|
+
Feature: Search
|
|
58
|
+
Background:
|
|
59
|
+
Given the search engine has the index "books" with the documents of "demo/books.json"
|
|
60
|
+
|
|
61
|
+
Scenario: Found with a typo, refused without a key
|
|
62
|
+
When I search the search engine's index "books" for "lighthous"
|
|
63
|
+
Then the search engine should find "The Winter Lighthouse" in its "title"
|
|
64
|
+
When I send the search engine "GET /indexes" without a key
|
|
65
|
+
Then the search engine should answer 401 "missing_authorization_header"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## From nothing to a green run
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/webship/meilisearch-steps && cd meilisearch-steps
|
|
72
|
+
npm ci && npx playwright install chromium
|
|
73
|
+
export MEILISEARCH_MASTER_KEY="$(openssl rand -hex 24)"
|
|
74
|
+
bash .github/scripts/build-demo.sh 1.59.0 # http://127.0.0.1:8750 (1.55.1: http://127.0.0.1:8751)
|
|
75
|
+
npx cucumber-js # LINE=1.55.1 for the other line
|
|
76
|
+
npm run test:must-fail
|
|
77
|
+
bash .github/scripts/remove-demo.sh 1.59.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The demo is the official image of the line by its digest, capped at 512 MB, run by the image's own init, in
|
|
81
|
+
development mode, telemetry off (`MEILI_NO_ANALYTICS=true`), its master key from the environment, never from a command
|
|
82
|
+
line. It refuses to start without one. The documents are our own 50 made-up books (`demo/books.json`: titles,
|
|
83
|
+
authors and blurbs written for this pack).
|
|
84
|
+
|
|
85
|
+
### What the suite tests
|
|
86
|
+
|
|
87
|
+
Three features, eight scenarios: indexes and searches (fifty books, found with a typo and highlighted; filtered, sorted
|
|
88
|
+
and counted by facets; synonyms; an index deleted), the dashboard (searched, nothing found, no request outside the
|
|
89
|
+
site), and keys and the server (no key, no data; a key that may only search one index; the line's version). Eleven
|
|
90
|
+
must-fail scenarios check that each assertion fails when it should, with its message and a hint (one of them against an
|
|
91
|
+
address nothing answers); the check then scans their output and reports for any key or "Bearer".
|
|
92
|
+
|
|
93
|
+
## Settings
|
|
94
|
+
|
|
95
|
+
`worldParameters.meilisearch` in `cucumber.js`:
|
|
96
|
+
|
|
97
|
+
| Setting | Default | What it is |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| `masterKey` | none | The server's master key, from the environment (`MEILISEARCH_MASTER_KEY`); never in a feature. |
|
|
100
|
+
|
|
101
|
+
## Steps
|
|
102
|
+
|
|
103
|
+
22 step definitions; each has five examples in its JSDoc block.
|
|
104
|
+
|
|
105
|
+
### `meilisearch-indexes.steps.js` (10)
|
|
106
|
+
|
|
107
|
+
- `Given the search engine has the index "<uid>" with the documents of "<file>"`: made afresh, its task waited for;
|
|
108
|
+
deleted at the scenario's end.
|
|
109
|
+
- `When I delete the index "<uid>" from the search engine`
|
|
110
|
+
- `Then the search engine should have the index "<uid>"` (`with <n> documents`) / `should not have the index "<uid>"`
|
|
111
|
+
- `Given the search engine's index "<uid>" has the filterable|sortable|searchable attributes "<a, b>"`
|
|
112
|
+
- `Given the search engine's index "<uid>" has the synonyms "<word>" for "<w1, w2>"`
|
|
113
|
+
- `When I search the search engine's index "<uid>" for "<q>"` (`filtered by "<filter>"`) (`sorted by "<a:desc>"`)
|
|
114
|
+
(`with the facets "<a>"`)
|
|
115
|
+
- `Then the search engine should find "<value>" in its "<field>"` / `should find nothing` / `should find <n> documents`
|
|
116
|
+
- `Then the search engine's first hit should have "<value>" in its "<field>"`
|
|
117
|
+
- `Then the search engine's facet "<a>" should count <n> for "<value>"`
|
|
118
|
+
- `Then the search engine should highlight "<text>" in its "<field>"`
|
|
119
|
+
|
|
120
|
+
### `meilisearch-dashboard.steps.js` (6)
|
|
121
|
+
|
|
122
|
+
- `Given I am on the search engine's dashboard with the master key`
|
|
123
|
+
- `When I choose the index "<uid>" in the search engine's dashboard`
|
|
124
|
+
- `When I search the search engine's dashboard for "<q>"`
|
|
125
|
+
- `Then the search engine's dashboard should show the hit "<value>"` / `should show no results`
|
|
126
|
+
- `Then the search engine's dashboard should have sent no request outside its address`
|
|
127
|
+
|
|
128
|
+
### `meilisearch-keys.steps.js` (6)
|
|
129
|
+
|
|
130
|
+
- `Given the search engine has a key "<name>" that may only "<actions>" on "<indexes>"`: deleted at the scenario's end.
|
|
131
|
+
- `When I send the search engine "<METHOD> <path>" with the key "<name>"` (`and the body "<json>"`)
|
|
132
|
+
- `When I send the search engine "<METHOD> <path>" with the master key` / `without a key`
|
|
133
|
+
- `Then the search engine should answer <status>` (`"<code>"`)
|
|
134
|
+
- `Then the search engine should be available`
|
|
135
|
+
- `Then the search engine's version should be "<line>"`
|
|
136
|
+
|
|
137
|
+
## Keys
|
|
138
|
+
|
|
139
|
+
The master key comes from the environment; a key a scenario makes lives in memory for that scenario and is deleted at
|
|
140
|
+
its end. No step shows a key: failures and messages replace any key's value with `…`. The dashboard gets the master key
|
|
141
|
+
in the page's memory (the dashboard keeps it there, not in the browser's storage), never typed in a step's words.
|
|
142
|
+
|
|
143
|
+
A failed request is the one place a key could slip out: Playwright's error for a request that gets no answer carries
|
|
144
|
+
the request's call log, its Authorization header among it. The pack catches every such error and rethrows its first
|
|
145
|
+
line only, with any key replaced. The must-fail run proves it: a scenario sends a request to an address nothing answers,
|
|
146
|
+
and the check scans every failure, the runs' output and their JSON and HTML reports for the key and for "Bearer".
|
|
147
|
+
|
|
148
|
+
## What a run leaves behind
|
|
149
|
+
|
|
150
|
+
Nothing: every index and key a scenario makes is deleted at its end, even when it fails.
|
|
151
|
+
|
|
152
|
+
## The console
|
|
153
|
+
|
|
154
|
+
The suite runs in webship-js's `fail` mode with nothing let through for the whole suite. The dashboard logs errors of
|
|
155
|
+
its own at two moments, and each dashboard step allows only its moment's, then counts them in the report:
|
|
156
|
+
|
|
157
|
+
- the step that opens the dashboard, before the key is in: the 401s of its first calls (`/indexes`, `/stats`,
|
|
158
|
+
`/version`, `/multi-search`) and "MeilisearchApiError: The Authorization header is missing…";
|
|
159
|
+
- the step that chooses the index, until it is chosen: the 400 of its search of no index at `/multi-search` and
|
|
160
|
+
"MeilisearchApiError: Invalid value at `.queries[0].indexUid`: `` is not a valid index uid…".
|
|
161
|
+
|
|
162
|
+
Any other browser error, or one of these at another moment, fails the scenario.
|
|
163
|
+
|
|
164
|
+
## Licence of the search engine, and its Enterprise Edition
|
|
165
|
+
|
|
166
|
+
Meilisearch is `MIT AND OpenLDAP AND BUSL-1.1`: MIT, its LMDB connector under the OpenLDAP licence, and the parts
|
|
167
|
+
marked "Enterprise Edition (EE)" under the Business Source License 1.1, whose use grant allows non-production use only
|
|
168
|
+
(testing, development, evaluation); production use of the EE features needs Meilisearch's commercial licence. This
|
|
169
|
+
pack only pulls the official image at the run, never redistributes it, and steps through MIT features only. It leaves
|
|
170
|
+
the EE parts alone and never turns them on:
|
|
171
|
+
|
|
172
|
+
- the network and sharding of several instances (the `network` experimental feature, its proxy and routes);
|
|
173
|
+
- S3 snapshots;
|
|
174
|
+
- dynamic search rules.
|
|
175
|
+
|
|
176
|
+
The official image runs none of them by default. With a master key set, `GET /experimental-features` answers every
|
|
177
|
+
feature off (`"network": false`, `"dynamicSearchRules": false`, …), and `GET /network` answers 400
|
|
178
|
+
`"code": "feature_not_enabled"` ("Using the /network route requires enabling the `network` experimental feature").
|
|
179
|
+
|
|
180
|
+
## Phrases shared with other packs
|
|
181
|
+
|
|
182
|
+
None. Every phrase says "the search engine". Checked before the release against the 71 published packs and the
|
|
183
|
+
Superset, Flask, Vaultwarden and Express packs: no example or feature step of this pack matches another pack's
|
|
184
|
+
definition, and no step of theirs matches one of this pack's.
|
|
185
|
+
|
|
186
|
+
## Findings
|
|
187
|
+
|
|
188
|
+
From the exploration and the runs on both lines:
|
|
189
|
+
|
|
190
|
+
1. **The dashboard** (mini-dashboard 0.4.2) is served at `/` in development mode only; it asks for a key and keeps it in
|
|
191
|
+
memory (a reload asks again). It also offers a cloud trial, a data export to a cloud account and a newsletter; the
|
|
192
|
+
steps never touch them, and the suite checks that searching sends no request outside the site.
|
|
193
|
+
2. **Without a key**, every route but `/health` and the dashboard's page answers 401
|
|
194
|
+
`"missing_authorization_header"`.
|
|
195
|
+
3. **A write is a task:** documents, settings and deletions answer 202 with a `taskUid`; the steps wait for it.
|
|
196
|
+
4. **A dump of 1.55.1 imports into 1.59.0** (`--import-dump` on a fresh data folder: the format V6, the documents and
|
|
197
|
+
the settings kept). Older to newer only; newer to older is never used.
|
|
198
|
+
5. **The image's own init** (tini as PID 1): run it without docker's `--init`.
|
|
199
|
+
6. **Measured** (512 MB cap): 34 MiB at the start, about 60 MiB with the books indexed; the suite in about 10 s.
|
|
200
|
+
|
|
201
|
+
## Testing this package
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm run test:examples # every example of every step matches its own definition only; every feature step one
|
|
205
|
+
npm run test:paths # a feature or a scenario named on the command line runs alone
|
|
206
|
+
npx cucumber-js --dry-run
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
CI, for each line (1.59.0 and 1.55.1), builds the demo and runs the suite twice and then the must-fail assertions.
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT. The pack carries no code of Meilisearch: the demo pulls the official image at the run.
|
|
214
|
+
|
|
215
|
+
## Logo
|
|
216
|
+
|
|
217
|
+
The logo is Simple Icons' Meilisearch icon (`icons/meilisearch.svg` of simple-icons 16.39.0, CC0-1.0), in the colour
|
|
218
|
+
the set lists for it (`#FF5CAA`); its path is unmodified. It names the search engine the pack tests. It is not covered
|
|
219
|
+
by this package's licence.
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Meilisearch</title><path fill="#FF5CAA" d="m6.505 18.998 4.434-11.345a4.168 4.168 0 0 1 3.882-2.651h2.674l-4.434 11.345a4.169 4.169 0 0 1-3.883 2.651H6.505Zm6.505 0 4.434-11.345a4.169 4.169 0 0 1 3.883-2.651H24l-4.434 11.345a4.168 4.168 0 0 1-3.882 2.651H13.01Zm-13.01 0L4.434 7.653a4.168 4.168 0 0 1 3.882-2.651h2.674L6.556 16.347a4.169 4.169 0 0 1-3.883 2.651H0Z"/></svg>
|