@syncmatters/connector-sdk 1.0.45 → 1.0.47

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.
Files changed (2) hide show
  1. package/docs/09-testing.md +34 -1
  2. package/package.json +3 -3
@@ -87,6 +87,20 @@ Established conventions:
87
87
  - **Test-data hygiene**: prefix every created record (`const testRecordPrefix = "sm_test";`)
88
88
  and have `before()` sweep and delete `sm_test*` leftovers, so crashed runs never pollute the
89
89
  sandbox account.
90
+ - **Clean up only what the run uses**: `before()` receives `selection` — what the run was
91
+ narrowed to: `objects` (`"all"`, `"selected"` or `"none"`), `objectIds` (the `--object` ids
92
+ when selected), `features` (`["all"]` unless restricted, e.g. `--only query`) and `checkIds`
93
+ (the `--check` ids). A suite whose sweep is slow or touches many objects limits it to the
94
+ objects the run tests **plus the objects those depend on** (a Contacts run that associates
95
+ companies still needs Companies swept), and skips write cleanup when nothing selected writes.
96
+ `selection` is absent on an older runner: treat absent as a full run.
97
+
98
+ ```js
99
+ async before({ connection, selection }) {
100
+ const wanted = !selection || selection.objects === "all" ? undefined : new Set(selection.objectIds);
101
+ if (!wanted || wanted.has("contacts") || wanted.has("companies")) await this.#sweepCrm();
102
+ }
103
+ ```
90
104
  - **Scoping out an object**: set `features.cannotTestReason = "<why>"` on an object's features
91
105
  instead of deleting it from the generated file.
92
106
  - `expectedIdentity` pins the account: if the sandbox credentials get re-pointed, the suite
@@ -190,6 +204,24 @@ const idsFilterData = {
190
204
  };
191
205
  ```
192
206
 
207
+ **`noRows: true`** says the query must succeed and return nothing: an unknown id that reads as
208
+ "not found" rather than an error, a filter or match that finds nothing, a parent without
209
+ children, a checkpoint with nothing newer. Row filters, match rules, related filters and
210
+ checkpoint step 2 honour it. Without it an empty expected id list is still rejected as invalid
211
+ test data, so a prepare hook that found nothing by accident cannot pass; with it the list must
212
+ be empty.
213
+
214
+ ```js
215
+ /** @type {SDKTest.RowFilterData} */
216
+ const unknownId = { rowFilter: { id: "999999999" }, expectedRowIds: [], expect: { noRows: true } };
217
+
218
+ /** @type {SDKTest.CheckpointStep2Data} - a quiet sandbox: nothing changed since the emitted checkpoint */
219
+ const step2 = { expectedRowIds: [], expect: { noRows: true } };
220
+ ```
221
+
222
+ Do not set `noRows` because a prepare hook's own query came back empty: state it only where the
223
+ suite knows the answer is "nothing" (an id it made up, a row it did not change).
224
+
193
225
  **`rows`** maps a row's `meta.key` (or `"*"` for every row) to assertions on `row.data` by path.
194
226
  Each assertion is one of:
195
227
 
@@ -525,7 +557,8 @@ Requirements that only surface as cryptic failures when unmet:
525
557
  normalizes or formats. And return the SAME `verifyFields` paths from both prepare calls:
526
558
  the harness reads row 2's values through call 1's paths.
527
559
  - **relatedFilterPrepare needs a declaring-object row that actually has related rows** —
528
- `expectedRelatedRowIds` must be non-empty. In the parent-owns-children shape that means a
560
+ `expectedRelatedRowIds` must be non-empty (a case that proves "this parent has no children"
561
+ says so with `expect: { noRows: true }`). In the parent-owns-children shape that means a
529
562
  parent with at least one child in the sandbox (create one in `before()` when the API allows;
530
563
  otherwise seed the sandbox account once and document it in the test file).
531
564
  - **Checkpoint step 2 does not have to create data** — see
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/connector-sdk",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "TypeScript type definitions for the SyncMatters connector SDK (types only - connectors execute on the SyncMatters platform)",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -12,9 +12,9 @@
12
12
  "license": "MIT",
13
13
  "author": "SyncMatters",
14
14
  "homepage": "https://syncmatters.com",
15
- "typesContentHash": "b7824973f26c6a656f1ec55fb456f957e89bdfd93310e6792f07b74df65291ea",
15
+ "typesContentHash": "ccbb10eddc34a239ade45eb32a0dd950c73bb934006dd3c4e899a9199f579434",
16
16
  "dependencies": {
17
17
  "@types/node": "*",
18
- "@syncmatters/script-api": "^1.0.47"
18
+ "@syncmatters/script-api": "^1.0.49"
19
19
  }
20
20
  }