@diagonal-hq/cli 0.21.3 → 0.22.1

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/dist/index.d.ts CHANGED
@@ -1252,14 +1252,12 @@ type TestSignInTarget =
1252
1252
  | ({ id: string } & Record<string, unknown>)
1253
1253
  | { resource: string; id: string };
1254
1254
 
1255
- /** `Sdk` in the test function. `setup` is the object that the setup function returned. */
1256
- export type TestSdk<S> = {
1255
+ /** `Sdk` in the test function. */
1256
+ export type TestSdk = {
1257
1257
  /** The workspace that the run acts on. */
1258
1258
  readonly workspace: { readonly id: string; readonly name: string; readonly baseUrl: string };
1259
1259
  /** An absolute URL on the run's workspace. */
1260
1260
  url(path?: string): string;
1261
- /** The object that setup returned, or `{}` without a setup function. */
1262
- readonly setup: S;
1263
1261
  /** Signs `page` in as a record that setup returned, or as `{ resource, id }`, then opens `redirectTo` (default `/`). */
1264
1262
  loginAs(record: TestSignInTarget, options?: { redirectTo?: string }): Promise<void>;
1265
1263
  /** Opens a second browser signed in as another record and returns its page. */
@@ -1293,39 +1291,40 @@ export type TestSdk<S> = {
1293
1291
  };
1294
1292
 
1295
1293
  /** The values that the runner gives the test function. */
1296
- export type TestFixtures<S> = {
1294
+ export type TestFixtures<C> = {
1297
1295
  page: import('@playwright/test').Page;
1298
1296
  context: import('@playwright/test').BrowserContext;
1299
1297
  request: import('@playwright/test').APIRequestContext;
1300
1298
  browser: import('@playwright/test').Browser;
1301
1299
  expect: import('@playwright/test').Expect;
1302
- Sdk: TestSdk<S>;
1300
+ Sdk: TestSdk;
1301
+ /** The object that setup returned, or `{}` without a setup function. A change to it reaches assert. */
1302
+ ctx: C;
1303
1303
  };
1304
1304
 
1305
1305
  /**
1306
- * The functions of a test. `setup` and `assert` are workflow handlers without a config: the build
1307
- * compiles each one as `defineWorkflow(handler)` of `@diagonal-hq/workflows/test`, and the run
1308
- * executes it once in the test workspace as an embedded script. It runs as the acting account,
1309
- * with no trigger, no `runAs`, and no `input` schema, so its input is fixed. To act as another
1310
- * identity, call `workflow.run` with a workflow that sets Run As. `test` runs in the browser runner
1311
- * as the body of a Playwright test, so it can use only its fixtures: no import or helper of its file.
1306
+ * The functions of a test. They share one ctx: setup gets it empty, and the object that setup
1307
+ * returns is the ctx of the test function and of assert. A change that the test function makes to
1308
+ * ctx reaches assert. The run sends ctx between them as JSON.
1309
+ *
1310
+ * `setup` and `assert` run once in the test workspace as embedded scripts, as the acting account,
1311
+ * with the `test` script profile. To act as another identity, call `workflow.run` with a workflow
1312
+ * that sets Run As. `test` runs in the browser runner as the body of a Playwright test, so it can
1313
+ * use only its fixtures: no import or helper of its file.
1312
1314
  */
1313
- export type TestHandlers<S> = {
1314
- /** Creates the records that the test needs and returns them. Its input is `{}`. */
1315
- setup?: (input: Record<string, never>, ctx: WorkflowContext) => S | Promise<S>;
1316
- test: (fixtures: TestFixtures<Awaited<S>>) => Promise<void>;
1317
- /**
1318
- * Reads the records after the test, and calls `fail(...)` when a value is wrong. Its input is
1319
- * the object that `setup` returned, or `{}` without a setup.
1320
- */
1321
- assert?: (setup: Awaited<S>, ctx: WorkflowContext) => void | Promise<void>;
1315
+ export type TestHandlers<C> = {
1316
+ /** Creates the records that the test needs and returns them. They become ctx. */
1317
+ setup?: (ctx: Record<string, unknown>) => C | Promise<C>;
1318
+ test: (fixtures: TestFixtures<Awaited<C>>) => Promise<void>;
1319
+ /** Reads the records after the test, and calls `fail(...)` when a value is wrong. */
1320
+ assert?: (ctx: Awaited<C>) => void | Promise<void>;
1322
1321
  };
1323
1322
 
1324
1323
  /**
1325
1324
  * The default export of `tests/<suite>/<key>.ts`, one E2E test of the suite in the folder. The
1326
1325
  * file name is the test key.
1327
1326
  */
1328
- export declare function defineTest<S = Record<string, never>>(
1327
+ export declare function defineTest<C = {}>(
1329
1328
  config: TestConfig,
1330
- handlers: TestHandlers<S>
1331
- ): { readonly config: TestConfig } & TestHandlers<S>;
1329
+ handlers: TestHandlers<C>
1330
+ ): { readonly config: TestConfig } & TestHandlers<C>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.21.3",
3
+ "version": "0.22.1",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {