@opice/harness 0.3.0 → 0.4.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/README.md CHANGED
@@ -19,7 +19,7 @@ Runs under the Bun test runner.
19
19
  import { test, describe } from 'bun:test'
20
20
  import { browserTest, el, byRole, byLabel, step, expect } from '@opice/harness'
21
21
 
22
- browserTest('DataGrid', () => {
22
+ browserTest({ name: 'DataGrid', hash: 'datagrid' }, () => {
23
23
  test('renders and is interactive', async () => {
24
24
  await step('table is visible', async () => {
25
25
  await expect(el('datagrid-table')).toBeVisible()
@@ -30,7 +30,7 @@ browserTest('DataGrid', () => {
30
30
  await expect(el('datagrid-row-0')).toHaveAttribute('data-highlighted', '')
31
31
  })
32
32
  }, 60_000)
33
- }, { hash: 'datagrid' })
33
+ })
34
34
  ```
35
35
 
36
36
  The DSL is **async** and returns Playwright `Locator`s, so the full Locator API
@@ -1,6 +1,8 @@
1
1
  import type { Locator, Page } from 'playwright';
2
2
  /** The ARIA role union accepted by Playwright's `getByRole`. */
3
3
  type Role = Parameters<Page['getByRole']>[0];
4
+ /** Playwright's `getByRole` options minus `name` (which is passed positionally). */
5
+ type RoleOptions = Omit<NonNullable<Parameters<Page['getByRole']>[1]>, 'name'>;
4
6
  /**
5
7
  * Accessible-name selectors — `byRole` / `byLabel` / `byText`.
6
8
  *
@@ -17,9 +19,14 @@ type Role = Parameters<Page['getByRole']>[0];
17
19
  */
18
20
  /**
19
21
  * Find an element by ARIA role and (optionally) its accessible name.
20
- * `name` does a substring, case-insensitive match by default.
22
+ * `name` does a substring, case-insensitive match when a string; pass a
23
+ * `RegExp` to match the accessible name by pattern (e.g. a generated id).
24
+ *
25
+ * `options` forwards the rest of Playwright's `getByRole` filters — most useful
26
+ * is `level` to pin a heading (`byRole('heading', 'Title', { level: 2 })`), plus
27
+ * `exact`, `checked`, `pressed`, `expanded`, `disabled`, etc.
21
28
  */
22
- export declare function byRole(role: Role, name?: string): Locator;
29
+ export declare function byRole(role: Role, name?: string | RegExp, options?: RoleOptions): Locator;
23
30
  /** Find a form control by its associated `<label>` (or `aria-label`) text. */
24
31
  export declare function byLabel(text: string): Locator;
25
32
  /** Find an element by its visible text (substring, case-insensitive). */
@@ -1 +1 @@
1
- {"version":3,"file":"accessible.d.ts","sourceRoot":"","sources":["../src/accessible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAG/C,gEAAgE;AAChE,KAAK,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE5C;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,yEAAyE;AACzE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C"}
1
+ {"version":3,"file":"accessible.d.ts","sourceRoot":"","sources":["../src/accessible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAG/C,gEAAgE;AAChE,KAAK,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5C,oFAAoF;AACpF,KAAK,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAGzF;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,yEAAyE;AACzE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C"}
@@ -15,10 +15,16 @@ import { getPage } from './context.js';
15
15
  */
16
16
  /**
17
17
  * Find an element by ARIA role and (optionally) its accessible name.
18
- * `name` does a substring, case-insensitive match by default.
18
+ * `name` does a substring, case-insensitive match when a string; pass a
19
+ * `RegExp` to match the accessible name by pattern (e.g. a generated id).
20
+ *
21
+ * `options` forwards the rest of Playwright's `getByRole` filters — most useful
22
+ * is `level` to pin a heading (`byRole('heading', 'Title', { level: 2 })`), plus
23
+ * `exact`, `checked`, `pressed`, `expanded`, `disabled`, etc.
19
24
  */
20
- export function byRole(role, name) {
21
- return getPage().getByRole(role, name == null ? undefined : { name });
25
+ export function byRole(role, name, options) {
26
+ const opts = { ...options, ...(name == null ? {} : { name }) };
27
+ return getPage().getByRole(role, Object.keys(opts).length > 0 ? opts : undefined);
22
28
  }
23
29
  /** Find a form control by its associated `<label>` (or `aria-label`) text. */
24
30
  export function byLabel(text) {
@@ -1 +1 @@
1
- {"version":3,"file":"accessible.js","sourceRoot":"","sources":["../src/accessible.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAKtC;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAU,EAAE,IAAa;IAC/C,OAAO,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AACtE,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAY;IACnC,OAAO,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,MAAM,CAAC,IAAY;IAClC,OAAO,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC"}
1
+ {"version":3,"file":"accessible.js","sourceRoot":"","sources":["../src/accessible.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAOtC;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAC,IAAU,EAAE,IAAsB,EAAE,OAAqB;IAC/E,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IAC9D,OAAO,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAClF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAY;IACnC,OAAO,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,MAAM,CAAC,IAAY;IAClC,OAAO,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ export { el, tid, waitFor, wait, evalJs, screenshot } from './element.js';
2
2
  export { byLabel, byRole, byText } from './accessible.js';
3
3
  export { back, currentPath, currentUrl, forward, open, reload } from './navigation.js';
4
4
  export { getPage, getContext } from './context.js';
5
- export { browserTest, step } from './scenario.js';
6
- export type { BrowserTestOptions } from './scenario.js';
5
+ export { browserTest, invariant, step } from './scenario.js';
6
+ export type { BrowserTestMeta, StepContract } from './scenario.js';
7
7
  export { getReporter, setReporter, configureFromEnv } from './reporter.js';
8
8
  export type { Reporter, ReporterConfig, StepEvent, ScenarioStart, ScenarioFinish } from './reporter.js';
9
9
  export { parseOpiceDsn } from './dsn.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEzD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEtF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEvG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAC5G,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA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,MAAM,YAAY,CAAA;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGzC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ export { el, tid, waitFor, wait, evalJs, screenshot } from './element.js';
2
2
  export { byLabel, byRole, byText } from './accessible.js';
3
3
  export { back, currentPath, currentUrl, forward, open, reload } from './navigation.js';
4
4
  export { getPage, getContext } from './context.js';
5
- export { browserTest, step } from './scenario.js';
5
+ export { browserTest, invariant, step } from './scenario.js';
6
6
  export { getReporter, setReporter, configureFromEnv } from './reporter.js';
7
7
  export { parseOpiceDsn } from './dsn.js';
8
8
  export { command, call, runCommand, makeCtx, loadUserCommands, findUserCommandsFile, z } from './command.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEzD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEtF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAGjD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAG5G,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG7D,iFAAiF;AACjF,uEAAuE;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEzD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEtF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAG5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAG5G,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG7D,iFAAiF;AACjF,uEAAuE;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA"}
@@ -26,16 +26,27 @@ export interface StepEvent {
26
26
  scenarioId: string;
27
27
  /** Authoring order within the scenario, assigned at step() call time. */
28
28
  sequence: number;
29
+ /**
30
+ * 'step' (a procedural step) or 'invariant' (a scenario-level acceptance).
31
+ * The platform may render invariants distinctly; older workers ignore it.
32
+ */
33
+ kind?: 'step' | 'invariant';
29
34
  name: string;
30
35
  /**
31
36
  * 'fixme' (a step.fixme that failed, as expected) and 'fixmepass' (a
32
37
  * step.fixme that unexpectedly passed) are tolerated warnings — neither
33
- * fails the scenario.
38
+ * fails the scenario. 'pending' is a phase-1 stub that never ran (no body
39
+ * yet); a scenario carrying one reads as 'incomplete'.
34
40
  */
35
- status: 'passed' | 'failed' | 'fixme' | 'fixmepass';
41
+ status: 'passed' | 'failed' | 'fixme' | 'fixmepass' | 'pending';
36
42
  durationMs: number;
37
43
  error?: string;
38
- /** Mandatory note from step.fixme — why the failure is tolerated. */
44
+ /**
45
+ * Durable rationale carried from the unit's contract (phase-1 `intent`) —
46
+ * why it exists / what it proves. Surfaced on the dashboard.
47
+ */
48
+ intent?: string;
49
+ /** Mandatory note from .fixme — why the failure is tolerated. */
39
50
  reason?: string;
40
51
  screenshotPath?: string;
41
52
  }
@@ -43,7 +54,12 @@ export interface ScenarioStart {
43
54
  name: string;
44
55
  hash?: string;
45
56
  testFile?: string;
46
- scenarioFile?: string;
57
+ /** Requirement / feature id this scenario covers (grouping). */
58
+ feature?: string;
59
+ /** Seeds required for the scenario (machine-checkable preconditions). */
60
+ seeds?: string[];
61
+ /** Identities / roles the scenario acts as. */
62
+ roles?: string[];
47
63
  }
48
64
  export interface ScenarioFinish {
49
65
  scenarioId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oEAAoE;IACpE,MAAM,CAAC,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,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,QAAQ;IACxB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACpD,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAWD,eAAO,MAAM,WAAW,QAAwC,CAAA;AAMhE,MAAM,WAAW,UAAU;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACb;AAmKD,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,QAAQ,CA8B/E"}
package/dist/reporter.js CHANGED
@@ -73,7 +73,9 @@ class HttpReporter {
73
73
  name: input.name,
74
74
  hash: input.hash,
75
75
  testFile: input.testFile,
76
- scenarioFile: input.scenarioFile,
76
+ feature: input.feature,
77
+ seeds: input.seeds,
78
+ roles: input.roles,
77
79
  });
78
80
  return response['scenarioId'];
79
81
  }
@@ -92,10 +94,12 @@ class HttpReporter {
92
94
  : undefined;
93
95
  await this.fetch('POST', `/api/v1/runs/${runId}/scenarios/${event.scenarioId}/steps`, {
94
96
  sequence: event.sequence,
97
+ kind: event.kind,
95
98
  name: event.name,
96
99
  status: event.status,
97
100
  durationMs: event.durationMs,
98
101
  error: event.error,
102
+ intent: event.intent,
99
103
  reason: event.reason,
100
104
  screenshot,
101
105
  });
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,+EAA+E;AAC/E,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,kFAAkF;AAClF,MAAM,eAAe,GAAG,MAAM,CAAA;AAkD9B,MAAM,YAAY;IACjB,KAAK,CAAC,aAAa,CAAC,KAAoB;QACvC,OAAO,QAAQ,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;IAC1C,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,MAAiB,IAAkB,CAAC;IACrD,KAAK,CAAC,cAAc,CAAC,MAAsB,IAAkB,CAAC;IAC9D,KAAK,CAAC,KAAK,KAAmB,CAAC;CAC/B;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAA;AAEhE,SAAS,WAAW,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,CAAA;AAC7C,CAAC;AAQD,MAAM,YAAY;IAKY;IAJrB,YAAY,GAA2B,IAAI,CAAA;IAClC,OAAO,GAA0B,IAAI,GAAG,EAAE,CAAA;IACnD,iBAAiB,GAAG,KAAK,CAAA;IAEjC,YAA6B,MAAsB;QAAtB,WAAM,GAAN,MAA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AI,CAAC,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;QACxC,OAAO,IAAI,YAAY,EAAE,CAAA;IAC1B,CAAC;IACD,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,0BAA0B;IAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACnD,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;IAC1D,MAAM,YAAY,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAC/E,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,IAAI,YAAY,EAAE,CAAA;IAC1B,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC;QACjC,QAAQ;QACR,SAAS;QACT,MAAM;QACN,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC;QACrD,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC;QAChD,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAC7B,CAAC,CAAA;IACF,WAAW,CAAC,QAAQ,CAAC,CAAA;IACrB,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED,gCAAgC;AAChC,gBAAgB,EAAE,CAAA"}
@@ -1,24 +1,85 @@
1
- export interface BrowserTestOptions {
2
- /** Hash fragment appended to PLAYGROUND_URL (e.g. 'datagrid'). */
3
- hash?: string;
4
- /** Override base URL (defaults to PLAYGROUND_URL env). */
1
+ /**
2
+ * Scenario metadata the **first** argument to `browserTest`.
3
+ *
4
+ * This is the durable, machine-relevant context an opice scenario carries
5
+ * independent of its concrete steps: where it runs, what it presupposes, what
6
+ * requirement it covers. It is written in **phase 1** (planning, `opice-plan`)
7
+ * and preserved through **phase 2** (authoring, `opice-author`) — the scenario
8
+ * file IS the spec, so this metadata never lives in a separate `.md` that can
9
+ * drift from the test.
10
+ *
11
+ * The rule of thumb for what belongs here vs. a code comment: *does anything
12
+ * other than a human read it?* Seeds (a precondition a runner could verify),
13
+ * the feature id (grouping on the dashboard), the acting roles — yes, so they
14
+ * are first-class fields. Background rationale that only a human reads stays a
15
+ * comment next to the relevant step.
16
+ */
17
+ export interface BrowserTestMeta {
18
+ /** Scenario name — becomes the `describe()` title. Required. */
19
+ name: string;
20
+ /** Override base URL (defaults to the `PLAYGROUND_URL` env var). */
5
21
  url?: string;
22
+ /** Hash fragment appended to the base URL (e.g. `'datagrid'`). */
23
+ hash?: string;
24
+ /** Feature / requirement id this scenario covers (e.g. `'F-SML-03a'`). */
25
+ feature?: string;
6
26
  /**
7
- * Path to the human-readable `*.scenario.md` this test was authored from.
8
- * Reported to the platform so the re-eval workflow can find the source.
9
- * If omitted, defaults to the test file path with `.test.ts` → `.scenario.md`.
27
+ * Seeds that must be loaded for this scenario to run — machine-checkable
28
+ * preconditions, not prose. e.g. `['initial-data', 'crm-master-data']`.
10
29
  */
11
- scenarioFile?: string;
30
+ seeds?: string[];
31
+ /** Identities / roles the scenario acts as, e.g. `['crmOperator']`. */
32
+ roles?: string[];
12
33
  }
13
34
  /**
14
35
  * Register a top-level browser test scenario.
15
36
  *
16
- * Each `browserTest(name, fn)` launches its own isolated Playwright browser +
37
+ * Each `browserTest(meta, fn)` launches its own isolated Playwright browser +
17
38
  * context + page, navigates to the playground URL, runs the given `fn` (which
18
39
  * typically contains nested `describe`/`test` blocks), and tears the browser
19
40
  * down in `afterAll`.
41
+ *
42
+ * Metadata is the **first** argument (`{ name, url, hash, feature, seeds,
43
+ * roles }`); `name` is required.
20
44
  */
21
- export declare function browserTest(name: string, fn: () => void, options?: BrowserTestOptions | string): void;
45
+ export declare function browserTest(meta: BrowserTestMeta, fn: () => void): void;
46
+ /**
47
+ * The durable contract of a step or invariant, separate from its mechanics.
48
+ *
49
+ * `intent` is written in **phase 1** and survives **verbatim** into the
50
+ * authored test — it's the "why this exists / what it proves", the independent
51
+ * statement of intent that the concrete body is checked against. `hint` is
52
+ * phase-1 scaffolding *for the authoring agent* ("what to actually do here");
53
+ * it is consumed when the step is authored and dropped once a body exists.
54
+ */
55
+ export interface StepContract {
56
+ /** Durable rationale: why this step/invariant exists, what it proves. */
57
+ intent?: string;
58
+ /**
59
+ * Phase-1 instruction to the authoring agent — what to do on the page here.
60
+ * Ephemeral: drop it once the body is written.
61
+ */
62
+ hint?: string;
63
+ }
64
+ type StepBody = () => void | Promise<void>;
65
+ interface StepFn {
66
+ /** Executable step. */
67
+ (name: string, fn: StepBody): Promise<void>;
68
+ /** Phase-1 stub: a step with a contract but no body yet (status: pending). */
69
+ (name: string, contract: StepContract): Promise<void>;
70
+ /** Authored step that keeps its durable contract. */
71
+ (name: string, contract: StepContract, fn: StepBody): Promise<void>;
72
+ }
73
+ interface StepExtras {
74
+ fixme: (name: string, reason: string, fn: StepBody) => Promise<void>;
75
+ /**
76
+ * A **blocked** pending stub: the step can't be authored yet because the app
77
+ * feature it covers isn't implemented. Reports as 'pending' with the reason
78
+ * attached (the dashboard shows it as blocked, distinct from a plain stub
79
+ * that's merely awaiting a test). `reason` is mandatory — say what's missing.
80
+ */
81
+ blocked: (name: string, reason: string, contract?: StepContract) => Promise<void>;
82
+ }
22
83
  /**
23
84
  * A reportable step inside a scenario. Captures duration + screenshot on
24
85
  * finish, forwards to the active reporter (no-op unless configured via env).
@@ -26,6 +87,14 @@ export declare function browserTest(name: string, fn: () => void, options?: Brow
26
87
  * The body may be sync or async; `step` always returns a promise, so call it
27
88
  * with `await step('…', async () => { … })`.
28
89
  *
90
+ * Three forms:
91
+ * - `step(name, fn)` — executable step (the common case).
92
+ * - `step(name, { intent, hint })` — a **pending** phase-1 stub: declares the
93
+ * step's intent and what to do, but has no body yet. It does not run and
94
+ * reports as `pending`; `opice-author` fills in the body.
95
+ * - `step(name, { intent }, fn)` — an authored step that keeps its durable
96
+ * `intent` (preserved verbatim from phase 1) alongside the body.
97
+ *
29
98
  * `step.fixme(name, reason, fn)` marks a **known, tolerated failure**: the body
30
99
  * still runs, but a failure inside it does NOT fail the scenario or the CI run —
31
100
  * it's reported as an amber warning instead. The `reason` is mandatory (use it
@@ -33,8 +102,41 @@ export declare function browserTest(name: string, fn: () => void, options?: Brow
33
102
  * step unexpectedly *passes*, it's flagged too ('fixmepass') so a stale marker
34
103
  * doesn't linger. Unlike Playwright's `test.fixme()`, which **skips** the test,
35
104
  * `step.fixme` **runs** it — the mandatory reason is there to keep them apart.
105
+ *
106
+ * `step.blocked(name, reason, contract?)` is a pending stub that **can't be
107
+ * authored yet** because the app feature doesn't exist — distinct from a plain
108
+ * `step(name, contract)` stub that's simply awaiting a test. Both report as
109
+ * 'pending' (scenario reads 'incomplete'); the blocked one carries its reason.
110
+ */
111
+ export declare const step: StepFn & StepExtras;
112
+ /**
113
+ * A scenario-level **invariant** — an acceptance property the scenario
114
+ * enforces, independent of the procedural steps. This is the durable "what
115
+ * must be true" that used to live in a scenario's prose Notes; expressing it as
116
+ * a call keeps it in the one source of truth (the test) instead of a separate
117
+ * `.md` that drifts.
118
+ *
119
+ * A failing `invariant` fails the scenario like any hard assertion — it's an
120
+ * acceptance, not a nicety.
121
+ *
122
+ * - `invariant(name, fn)` — enforced now.
123
+ * - `invariant.todo(name, hint?)` — phase-1 stub: states the acceptance but
124
+ * isn't wired yet (status: pending). `opice-author` promotes it to an
125
+ * enforced `invariant(...)` (or an `invariant.fixme(...)` if it can't hold
126
+ * yet) once it knows how to check it.
127
+ * - `invariant.blocked(name, reason)` — a pending acceptance that can't be
128
+ * wired yet because the feature it guards isn't implemented (vs `.todo`,
129
+ * which is merely awaiting authoring). Reports 'pending' with the reason.
130
+ * - `invariant.fixme(name, reason, fn)` — a known-unenforceable acceptance,
131
+ * tolerated like `step.fixme` (e.g. a security property deferred to a
132
+ * ticket). The body runs and is expected to fail; the failure is reported as
133
+ * an amber warning and neither fails the scenario nor the run.
36
134
  */
37
- export declare const step: ((name: string, fn: () => void | Promise<void>) => Promise<void>) & {
38
- fixme: (name: string, reason: string, fn: () => void | Promise<void>) => Promise<void>;
135
+ export declare const invariant: {
136
+ (name: string, fn: StepBody): Promise<void>;
137
+ todo: (name: string, hint?: string) => Promise<void>;
138
+ blocked: (name: string, reason: string) => Promise<void>;
139
+ fixme: (name: string, reason: string, fn: StepBody) => Promise<void>;
39
140
  };
141
+ export {};
40
142
  //# sourceMappingURL=scenario.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../src/scenario.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,kBAAkB;IAClC,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB;AAuCD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,GAAE,kBAAkB,GAAG,MAAW,GAAG,IAAI,CA6DzG;AAsDD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,UACT,MAAM,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;kBAE9C,MAAM,UAAU,MAAM,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;CAGrF,CAAA"}
1
+ {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../src/scenario.ts"],"names":[],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pE;;;;;OAKG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,GAAG,UAa3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,SAAS,EAAE;IACvB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAWpE,CAAA"}
package/dist/scenario.js CHANGED
@@ -40,14 +40,10 @@ function captureTestFile() {
40
40
  }
41
41
  return undefined;
42
42
  }
43
- function defaultScenarioFile(testFile) {
44
- if (!testFile)
45
- return undefined;
46
- return testFile.replace(/\.test\.[tj]sx?$/, '.scenario.md');
47
- }
48
43
  let currentScenarioId = null;
49
44
  let currentScenarioStart = 0;
50
45
  let currentScenarioFailures = 0;
46
+ let currentScenarioPending = 0;
51
47
  // Monotonic per-scenario step counter. Assigned synchronously at each step()
52
48
  // call so order reflects authoring order — step records are POSTed
53
49
  // fire-and-forget and would otherwise be sequenced by arrival order at the
@@ -56,24 +52,41 @@ let currentScenarioStepSeq = 0;
56
52
  /**
57
53
  * Register a top-level browser test scenario.
58
54
  *
59
- * Each `browserTest(name, fn)` launches its own isolated Playwright browser +
55
+ * Each `browserTest(meta, fn)` launches its own isolated Playwright browser +
60
56
  * context + page, navigates to the playground URL, runs the given `fn` (which
61
57
  * typically contains nested `describe`/`test` blocks), and tears the browser
62
58
  * down in `afterAll`.
59
+ *
60
+ * Metadata is the **first** argument (`{ name, url, hash, feature, seeds,
61
+ * roles }`); `name` is required.
63
62
  */
64
- export function browserTest(name, fn, options = {}) {
65
- const opts = typeof options === 'string' ? { hash: options } : options;
63
+ export function browserTest(meta, fn) {
64
+ if (typeof meta === 'string') {
65
+ // Migration aid: the old signature was `browserTest(name, fn, options)`.
66
+ throw new Error('opice: browserTest now takes metadata first — browserTest({ name, url, hash, … }, fn). '
67
+ + `Got a string name (${JSON.stringify(meta)}); wrap it: browserTest({ name: ${JSON.stringify(meta)} }, fn).`);
68
+ }
69
+ if (!meta?.name) {
70
+ throw new Error('opice: browserTest requires a `name` in its metadata — browserTest({ name: "…" }, fn).');
71
+ }
66
72
  const reporter = getReporter();
67
73
  const testFile = captureTestFile();
68
- const scenarioFile = opts.scenarioFile ?? defaultScenarioFile(testFile);
69
74
  const { describe, beforeAll, afterAll } = bunTest();
70
- describe(name, () => {
75
+ describe(meta.name, () => {
71
76
  beforeAll(async () => {
72
77
  currentScenarioStart = Date.now();
73
78
  currentScenarioFailures = 0;
79
+ currentScenarioPending = 0;
74
80
  currentScenarioStepSeq = 0;
75
81
  try {
76
- currentScenarioId = await reporter.startScenario({ name, hash: opts.hash, testFile, scenarioFile });
82
+ currentScenarioId = await reporter.startScenario({
83
+ name: meta.name,
84
+ hash: meta.hash,
85
+ testFile,
86
+ feature: meta.feature,
87
+ seeds: meta.seeds,
88
+ roles: meta.roles,
89
+ });
77
90
  }
78
91
  catch {
79
92
  currentScenarioId = null;
@@ -85,8 +98,8 @@ export function browserTest(name, fn, options = {}) {
85
98
  const setup = await loadUserSetup();
86
99
  if (setup)
87
100
  await setup(getContext());
88
- const base = opts.url ?? PLAYGROUND_URL;
89
- const url = opts.hash ? `${base}#${opts.hash}` : base;
101
+ const base = meta.url ?? PLAYGROUND_URL;
102
+ const url = meta.hash ? `${base}#${meta.hash}` : base;
90
103
  // `domcontentloaded`, not the default `load`: an SPA paints after its JS
91
104
  // runs and may hold `load` on a slow chunk or long-lived connection, so
92
105
  // waiting for `load` flakily times out under CI contention. Readiness is
@@ -100,6 +113,14 @@ export function browserTest(name, fn, options = {}) {
100
113
  catch {
101
114
  // ignore close errors
102
115
  }
116
+ // A scenario still carrying unfilled (pending) steps is a phase-1
117
+ // skeleton that was run before authoring. It's not a failure, but it's
118
+ // not done either — make it loud so a half-authored test isn't mistaken
119
+ // for a passing one.
120
+ if (currentScenarioPending > 0) {
121
+ console.warn(`[opice] scenario "${meta.name}" has ${currentScenarioPending} pending step(s) — `
122
+ + 'authored skeleton, not yet filled in by opice-author. The body did NOT run.');
123
+ }
103
124
  if (currentScenarioId) {
104
125
  // Drain pending step records (incl. their screenshot uploads)
105
126
  // before marking the scenario done. step() fires recordStep
@@ -125,17 +146,40 @@ export function browserTest(name, fn, options = {}) {
125
146
  fn();
126
147
  });
127
148
  }
128
- async function runStep(name, fn, fixmeReason) {
149
+ async function runUnit(unit) {
129
150
  const reporter = getReporter();
130
151
  // Capture order at call time, before the fire-and-forget record below.
131
152
  const sequence = currentScenarioStepSeq++;
153
+ // A reason *with* a body is a .fixme (tolerated failure). A reason *without*
154
+ // a body is .blocked (a pending stub that can't be authored yet).
155
+ const fixme = unit.reason !== undefined && unit.fn !== undefined;
156
+ // Phase-1 stub: no body to run. Report it as 'pending' (so the dashboard
157
+ // shows the skeleton — a scenario carrying one reads as 'incomplete') and
158
+ // count it so afterAll can warn. A `reason` here marks it 'blocked' (the
159
+ // feature isn't built); no reason is a plain todo awaiting authoring. No
160
+ // screenshot, zero duration.
161
+ if (!unit.fn) {
162
+ currentScenarioPending++;
163
+ if (currentScenarioId) {
164
+ void reporter.recordStep({
165
+ scenarioId: currentScenarioId,
166
+ sequence,
167
+ kind: unit.kind,
168
+ name: unit.name,
169
+ status: 'pending',
170
+ durationMs: 0,
171
+ intent: unit.contract?.intent,
172
+ reason: unit.reason,
173
+ });
174
+ }
175
+ return;
176
+ }
132
177
  const start = Date.now();
133
- const fixme = fixmeReason !== undefined;
134
178
  let status = 'passed';
135
179
  let error;
136
180
  try {
137
- await fn();
138
- // A fixme step that *passes* is a stale marker: surface it as an
181
+ await unit.fn();
182
+ // A fixme unit that *passes* is a stale marker: surface it as a
139
183
  // 'fixmepass' warning so the author knows they can drop the marker,
140
184
  // rather than letting it pass silently.
141
185
  if (fixme)
@@ -146,7 +190,7 @@ async function runStep(name, fn, fixmeReason) {
146
190
  if (fixme) {
147
191
  // Known / tolerated failure. Record it as 'fixme', but DON'T count it
148
192
  // toward scenario failures and DON'T re-throw — that's the whole point
149
- // of step.fixme: the scenario (and the CI run) stay green, the failure
193
+ // of .fixme: the scenario (and the CI run) stay green, the failure
150
194
  // surfaces as an amber warning on the dashboard.
151
195
  status = 'fixme';
152
196
  }
@@ -169,11 +213,13 @@ async function runStep(name, fn, fixmeReason) {
169
213
  void reporter.recordStep({
170
214
  scenarioId: currentScenarioId,
171
215
  sequence,
172
- name,
216
+ kind: unit.kind,
217
+ name: unit.name,
173
218
  status,
174
219
  durationMs,
175
220
  error,
176
- reason: fixmeReason,
221
+ intent: unit.contract?.intent,
222
+ reason: unit.reason,
177
223
  screenshotPath,
178
224
  });
179
225
  }
@@ -186,6 +232,14 @@ async function runStep(name, fn, fixmeReason) {
186
232
  * The body may be sync or async; `step` always returns a promise, so call it
187
233
  * with `await step('…', async () => { … })`.
188
234
  *
235
+ * Three forms:
236
+ * - `step(name, fn)` — executable step (the common case).
237
+ * - `step(name, { intent, hint })` — a **pending** phase-1 stub: declares the
238
+ * step's intent and what to do, but has no body yet. It does not run and
239
+ * reports as `pending`; `opice-author` fills in the body.
240
+ * - `step(name, { intent }, fn)` — an authored step that keeps its durable
241
+ * `intent` (preserved verbatim from phase 1) alongside the body.
242
+ *
189
243
  * `step.fixme(name, reason, fn)` marks a **known, tolerated failure**: the body
190
244
  * still runs, but a failure inside it does NOT fail the scenario or the CI run —
191
245
  * it's reported as an amber warning instead. The `reason` is mandatory (use it
@@ -193,8 +247,47 @@ async function runStep(name, fn, fixmeReason) {
193
247
  * step unexpectedly *passes*, it's flagged too ('fixmepass') so a stale marker
194
248
  * doesn't linger. Unlike Playwright's `test.fixme()`, which **skips** the test,
195
249
  * `step.fixme` **runs** it — the mandatory reason is there to keep them apart.
250
+ *
251
+ * `step.blocked(name, reason, contract?)` is a pending stub that **can't be
252
+ * authored yet** because the app feature doesn't exist — distinct from a plain
253
+ * `step(name, contract)` stub that's simply awaiting a test. Both report as
254
+ * 'pending' (scenario reads 'incomplete'); the blocked one carries its reason.
255
+ */
256
+ export const step = Object.assign((name, arg2, arg3) => {
257
+ if (typeof arg2 === 'function') {
258
+ return runUnit({ kind: 'step', name, fn: arg2 });
259
+ }
260
+ return runUnit({ kind: 'step', name, contract: arg2, fn: arg3 });
261
+ }, {
262
+ fixme: (name, reason, fn) => runUnit({ kind: 'step', name, reason, fn }),
263
+ blocked: (name, reason, contract) => runUnit({ kind: 'step', name, contract, reason }),
264
+ });
265
+ /**
266
+ * A scenario-level **invariant** — an acceptance property the scenario
267
+ * enforces, independent of the procedural steps. This is the durable "what
268
+ * must be true" that used to live in a scenario's prose Notes; expressing it as
269
+ * a call keeps it in the one source of truth (the test) instead of a separate
270
+ * `.md` that drifts.
271
+ *
272
+ * A failing `invariant` fails the scenario like any hard assertion — it's an
273
+ * acceptance, not a nicety.
274
+ *
275
+ * - `invariant(name, fn)` — enforced now.
276
+ * - `invariant.todo(name, hint?)` — phase-1 stub: states the acceptance but
277
+ * isn't wired yet (status: pending). `opice-author` promotes it to an
278
+ * enforced `invariant(...)` (or an `invariant.fixme(...)` if it can't hold
279
+ * yet) once it knows how to check it.
280
+ * - `invariant.blocked(name, reason)` — a pending acceptance that can't be
281
+ * wired yet because the feature it guards isn't implemented (vs `.todo`,
282
+ * which is merely awaiting authoring). Reports 'pending' with the reason.
283
+ * - `invariant.fixme(name, reason, fn)` — a known-unenforceable acceptance,
284
+ * tolerated like `step.fixme` (e.g. a security property deferred to a
285
+ * ticket). The body runs and is expected to fail; the failure is reported as
286
+ * an amber warning and neither fails the scenario nor the run.
196
287
  */
197
- export const step = Object.assign((name, fn) => runStep(name, fn), {
198
- fixme: (name, reason, fn) => runStep(name, fn, reason),
288
+ export const invariant = Object.assign((name, fn) => runUnit({ kind: 'invariant', name, fn }), {
289
+ todo: (name, hint) => runUnit({ kind: 'invariant', name, contract: hint ? { hint } : undefined }),
290
+ blocked: (name, reason) => runUnit({ kind: 'invariant', name, reason }),
291
+ fixme: (name, reason, fn) => runUnit({ kind: 'invariant', name, reason, fn }),
199
292
  });
200
293
  //# sourceMappingURL=scenario.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.js","sourceRoot":"","sources":["../src/scenario.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,SAAS,OAAO;IACf,OAAO,OAAO,CAAC,UAAU,CAA8B,CAAA;AACxD,CAAC;AAED,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,wBAAwB,CAAA;AAehF;;;;GAIG;AACH,SAAS,eAAe;IACvB,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,K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EAAiB,EAAE,CACjF,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;CAClD,CACD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,SAAS,GAKlB,MAAM,CAAC,MAAM,CAChB,CAAC,IAAY,EAAE,EAAY,EAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EACvF;IACC,IAAI,EAAE,CAAC,IAAY,EAAE,IAAa,EAAiB,EAAE,CACpD,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAC5E,OAAO,EAAE,CAAC,IAAY,EAAE,MAAc,EAAiB,EAAE,CACxD,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7C,KAAK,EAAE,CAAC,IAAY,EAAE,MAAc,EAAE,EAAY,EAAiB,EAAE,CACpE,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CACjD,CACD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opice/harness",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Runtime primitives for opice — AI-driven E2E browser tests on top of Playwright",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/accessible.ts CHANGED
@@ -3,6 +3,8 @@ import { getPage } from './context.js'
3
3
 
4
4
  /** The ARIA role union accepted by Playwright's `getByRole`. */
5
5
  type Role = Parameters<Page['getByRole']>[0]
6
+ /** Playwright's `getByRole` options minus `name` (which is passed positionally). */
7
+ type RoleOptions = Omit<NonNullable<Parameters<Page['getByRole']>[1]>, 'name'>
6
8
 
7
9
  /**
8
10
  * Accessible-name selectors — `byRole` / `byLabel` / `byText`.
@@ -21,10 +23,16 @@ type Role = Parameters<Page['getByRole']>[0]
21
23
 
22
24
  /**
23
25
  * Find an element by ARIA role and (optionally) its accessible name.
24
- * `name` does a substring, case-insensitive match by default.
26
+ * `name` does a substring, case-insensitive match when a string; pass a
27
+ * `RegExp` to match the accessible name by pattern (e.g. a generated id).
28
+ *
29
+ * `options` forwards the rest of Playwright's `getByRole` filters — most useful
30
+ * is `level` to pin a heading (`byRole('heading', 'Title', { level: 2 })`), plus
31
+ * `exact`, `checked`, `pressed`, `expanded`, `disabled`, etc.
25
32
  */
26
- export function byRole(role: Role, name?: string): Locator {
27
- return getPage().getByRole(role, name == null ? undefined : { name })
33
+ export function byRole(role: Role, name?: string | RegExp, options?: RoleOptions): Locator {
34
+ const opts = { ...options, ...(name == null ? {} : { name }) }
35
+ return getPage().getByRole(role, Object.keys(opts).length > 0 ? opts : undefined)
28
36
  }
29
37
 
30
38
  /** Find a form control by its associated `<label>` (or `aria-label`) text. */
package/src/index.ts CHANGED
@@ -6,8 +6,8 @@ export { back, currentPath, currentUrl, forward, open, reload } from './navigati
6
6
 
7
7
  export { getPage, getContext } from './context.js'
8
8
 
9
- export { browserTest, step } from './scenario.js'
10
- export type { BrowserTestOptions } from './scenario.js'
9
+ export { browserTest, invariant, step } from './scenario.js'
10
+ export type { BrowserTestMeta, StepContract } from './scenario.js'
11
11
 
12
12
  export { getReporter, setReporter, configureFromEnv } from './reporter.js'
13
13
  export type { Reporter, ReporterConfig, StepEvent, ScenarioStart, ScenarioFinish } from './reporter.js'
package/src/reporter.ts CHANGED
@@ -39,16 +39,27 @@ export interface StepEvent {
39
39
  scenarioId: string
40
40
  /** Authoring order within the scenario, assigned at step() call time. */
41
41
  sequence: number
42
+ /**
43
+ * 'step' (a procedural step) or 'invariant' (a scenario-level acceptance).
44
+ * The platform may render invariants distinctly; older workers ignore it.
45
+ */
46
+ kind?: 'step' | 'invariant'
42
47
  name: string
43
48
  /**
44
49
  * 'fixme' (a step.fixme that failed, as expected) and 'fixmepass' (a
45
50
  * step.fixme that unexpectedly passed) are tolerated warnings — neither
46
- * fails the scenario.
51
+ * fails the scenario. 'pending' is a phase-1 stub that never ran (no body
52
+ * yet); a scenario carrying one reads as 'incomplete'.
47
53
  */
48
- status: 'passed' | 'failed' | 'fixme' | 'fixmepass'
54
+ status: 'passed' | 'failed' | 'fixme' | 'fixmepass' | 'pending'
49
55
  durationMs: number
50
56
  error?: string
51
- /** Mandatory note from step.fixme — why the failure is tolerated. */
57
+ /**
58
+ * Durable rationale carried from the unit's contract (phase-1 `intent`) —
59
+ * why it exists / what it proves. Surfaced on the dashboard.
60
+ */
61
+ intent?: string
62
+ /** Mandatory note from .fixme — why the failure is tolerated. */
52
63
  reason?: string
53
64
  screenshotPath?: string
54
65
  }
@@ -57,7 +68,12 @@ export interface ScenarioStart {
57
68
  name: string
58
69
  hash?: string
59
70
  testFile?: string
60
- scenarioFile?: string
71
+ /** Requirement / feature id this scenario covers (grouping). */
72
+ feature?: string
73
+ /** Seeds required for the scenario (machine-checkable preconditions). */
74
+ seeds?: string[]
75
+ /** Identities / roles the scenario acts as. */
76
+ roles?: string[]
61
77
  }
62
78
 
63
79
  export interface ScenarioFinish {
@@ -133,7 +149,9 @@ class HttpReporter implements Reporter {
133
149
  name: input.name,
134
150
  hash: input.hash,
135
151
  testFile: input.testFile,
136
- scenarioFile: input.scenarioFile,
152
+ feature: input.feature,
153
+ seeds: input.seeds,
154
+ roles: input.roles,
137
155
  })
138
156
  return response['scenarioId'] as string
139
157
  }
@@ -154,10 +172,12 @@ class HttpReporter implements Reporter {
154
172
  : undefined
155
173
  await this.fetch('POST', `/api/v1/runs/${runId}/scenarios/${event.scenarioId}/steps`, {
156
174
  sequence: event.sequence,
175
+ kind: event.kind,
157
176
  name: event.name,
158
177
  status: event.status,
159
178
  durationMs: event.durationMs,
160
179
  error: event.error,
180
+ intent: event.intent,
161
181
  reason: event.reason,
162
182
  screenshot,
163
183
  })
package/src/scenario.ts CHANGED
@@ -19,17 +19,38 @@ function bunTest(): typeof import('bun:test') {
19
19
 
20
20
  const PLAYGROUND_URL = process.env['PLAYGROUND_URL'] ?? 'http://localhost:15180'
21
21
 
22
- export interface BrowserTestOptions {
23
- /** Hash fragment appended to PLAYGROUND_URL (e.g. 'datagrid'). */
24
- hash?: string
25
- /** Override base URL (defaults to PLAYGROUND_URL env). */
22
+ /**
23
+ * Scenario metadata the **first** argument to `browserTest`.
24
+ *
25
+ * This is the durable, machine-relevant context an opice scenario carries
26
+ * independent of its concrete steps: where it runs, what it presupposes, what
27
+ * requirement it covers. It is written in **phase 1** (planning, `opice-plan`)
28
+ * and preserved through **phase 2** (authoring, `opice-author`) — the scenario
29
+ * file IS the spec, so this metadata never lives in a separate `.md` that can
30
+ * drift from the test.
31
+ *
32
+ * The rule of thumb for what belongs here vs. a code comment: *does anything
33
+ * other than a human read it?* Seeds (a precondition a runner could verify),
34
+ * the feature id (grouping on the dashboard), the acting roles — yes, so they
35
+ * are first-class fields. Background rationale that only a human reads stays a
36
+ * comment next to the relevant step.
37
+ */
38
+ export interface BrowserTestMeta {
39
+ /** Scenario name — becomes the `describe()` title. Required. */
40
+ name: string
41
+ /** Override base URL (defaults to the `PLAYGROUND_URL` env var). */
26
42
  url?: string
43
+ /** Hash fragment appended to the base URL (e.g. `'datagrid'`). */
44
+ hash?: string
45
+ /** Feature / requirement id this scenario covers (e.g. `'F-SML-03a'`). */
46
+ feature?: string
27
47
  /**
28
- * Path to the human-readable `*.scenario.md` this test was authored from.
29
- * Reported to the platform so the re-eval workflow can find the source.
30
- * If omitted, defaults to the test file path with `.test.ts` → `.scenario.md`.
48
+ * Seeds that must be loaded for this scenario to run — machine-checkable
49
+ * preconditions, not prose. e.g. `['initial-data', 'crm-master-data']`.
31
50
  */
32
- scenarioFile?: string
51
+ seeds?: string[]
52
+ /** Identities / roles the scenario acts as, e.g. `['crmOperator']`. */
53
+ roles?: string[]
33
54
  }
34
55
 
35
56
  /**
@@ -55,14 +76,10 @@ function captureTestFile(): string | undefined {
55
76
  return undefined
56
77
  }
57
78
 
58
- function defaultScenarioFile(testFile: string | undefined): string | undefined {
59
- if (!testFile) return undefined
60
- return testFile.replace(/\.test\.[tj]sx?$/, '.scenario.md')
61
- }
62
-
63
79
  let currentScenarioId: string | null = null
64
80
  let currentScenarioStart: number = 0
65
81
  let currentScenarioFailures = 0
82
+ let currentScenarioPending = 0
66
83
  // Monotonic per-scenario step counter. Assigned synchronously at each step()
67
84
  // call so order reflects authoring order — step records are POSTed
68
85
  // fire-and-forget and would otherwise be sequenced by arrival order at the
@@ -72,25 +89,44 @@ let currentScenarioStepSeq = 0
72
89
  /**
73
90
  * Register a top-level browser test scenario.
74
91
  *
75
- * Each `browserTest(name, fn)` launches its own isolated Playwright browser +
92
+ * Each `browserTest(meta, fn)` launches its own isolated Playwright browser +
76
93
  * context + page, navigates to the playground URL, runs the given `fn` (which
77
94
  * typically contains nested `describe`/`test` blocks), and tears the browser
78
95
  * down in `afterAll`.
96
+ *
97
+ * Metadata is the **first** argument (`{ name, url, hash, feature, seeds,
98
+ * roles }`); `name` is required.
79
99
  */
80
- export function browserTest(name: string, fn: () => void, options: BrowserTestOptions | string = {}): void {
81
- const opts: BrowserTestOptions = typeof options === 'string' ? { hash: options } : options
100
+ export function browserTest(meta: BrowserTestMeta, fn: () => void): void {
101
+ if (typeof meta === 'string') {
102
+ // Migration aid: the old signature was `browserTest(name, fn, options)`.
103
+ throw new Error(
104
+ 'opice: browserTest now takes metadata first — browserTest({ name, url, hash, … }, fn). '
105
+ + `Got a string name (${JSON.stringify(meta)}); wrap it: browserTest({ name: ${JSON.stringify(meta)} }, fn).`,
106
+ )
107
+ }
108
+ if (!meta?.name) {
109
+ throw new Error('opice: browserTest requires a `name` in its metadata — browserTest({ name: "…" }, fn).')
110
+ }
82
111
  const reporter = getReporter()
83
112
  const testFile = captureTestFile()
84
- const scenarioFile = opts.scenarioFile ?? defaultScenarioFile(testFile)
85
113
  const { describe, beforeAll, afterAll } = bunTest()
86
114
 
87
- describe(name, () => {
115
+ describe(meta.name, () => {
88
116
  beforeAll(async () => {
89
117
  currentScenarioStart = Date.now()
90
118
  currentScenarioFailures = 0
119
+ currentScenarioPending = 0
91
120
  currentScenarioStepSeq = 0
92
121
  try {
93
- currentScenarioId = await reporter.startScenario({ name, hash: opts.hash, testFile, scenarioFile })
122
+ currentScenarioId = await reporter.startScenario({
123
+ name: meta.name,
124
+ hash: meta.hash,
125
+ testFile,
126
+ feature: meta.feature,
127
+ seeds: meta.seeds,
128
+ roles: meta.roles,
129
+ })
94
130
  } catch {
95
131
  currentScenarioId = null
96
132
  }
@@ -100,8 +136,8 @@ export function browserTest(name: string, fn: () => void, options: BrowserTestOp
100
136
  // own scripts on first paint.
101
137
  const setup = await loadUserSetup()
102
138
  if (setup) await setup(getContext())
103
- const base = opts.url ?? PLAYGROUND_URL
104
- const url = opts.hash ? `${base}#${opts.hash}` : base
139
+ const base = meta.url ?? PLAYGROUND_URL
140
+ const url = meta.hash ? `${base}#${meta.hash}` : base
105
141
  // `domcontentloaded`, not the default `load`: an SPA paints after its JS
106
142
  // runs and may hold `load` on a slow chunk or long-lived connection, so
107
143
  // waiting for `load` flakily times out under CI contention. Readiness is
@@ -115,6 +151,16 @@ export function browserTest(name: string, fn: () => void, options: BrowserTestOp
115
151
  } catch {
116
152
  // ignore close errors
117
153
  }
154
+ // A scenario still carrying unfilled (pending) steps is a phase-1
155
+ // skeleton that was run before authoring. It's not a failure, but it's
156
+ // not done either — make it loud so a half-authored test isn't mistaken
157
+ // for a passing one.
158
+ if (currentScenarioPending > 0) {
159
+ console.warn(
160
+ `[opice] scenario "${meta.name}" has ${currentScenarioPending} pending step(s) — `
161
+ + 'authored skeleton, not yet filled in by opice-author. The body did NOT run.',
162
+ )
163
+ }
118
164
  if (currentScenarioId) {
119
165
  // Drain pending step records (incl. their screenshot uploads)
120
166
  // before marking the scenario done. step() fires recordStep
@@ -140,19 +186,78 @@ export function browserTest(name: string, fn: () => void, options: BrowserTestOp
140
186
  })
141
187
  }
142
188
 
143
- type StepStatus = 'passed' | 'failed' | 'fixme' | 'fixmepass'
189
+ type StepStatus = 'passed' | 'failed' | 'fixme' | 'fixmepass' | 'pending'
190
+ type StepKind = 'step' | 'invariant'
191
+
192
+ /**
193
+ * The durable contract of a step or invariant, separate from its mechanics.
194
+ *
195
+ * `intent` is written in **phase 1** and survives **verbatim** into the
196
+ * authored test — it's the "why this exists / what it proves", the independent
197
+ * statement of intent that the concrete body is checked against. `hint` is
198
+ * phase-1 scaffolding *for the authoring agent* ("what to actually do here");
199
+ * it is consumed when the step is authored and dropped once a body exists.
200
+ */
201
+ export interface StepContract {
202
+ /** Durable rationale: why this step/invariant exists, what it proves. */
203
+ intent?: string
204
+ /**
205
+ * Phase-1 instruction to the authoring agent — what to do on the page here.
206
+ * Ephemeral: drop it once the body is written.
207
+ */
208
+ hint?: string
209
+ }
210
+
211
+ interface RunUnit {
212
+ kind: StepKind
213
+ name: string
214
+ contract?: StepContract
215
+ /** Present once authored. Absent ⇒ a pending (phase-1) stub. */
216
+ fn?: () => void | Promise<void>
217
+ /**
218
+ * A human note. With a body (`.fixme`): why a tolerated failure is allowed.
219
+ * Without a body (`.blocked`): why the stub can't be authored yet (the app
220
+ * feature isn't implemented). A plain pending stub has no reason.
221
+ */
222
+ reason?: string
223
+ }
144
224
 
145
- async function runStep(name: string, fn: () => void | Promise<void>, fixmeReason?: string): Promise<void> {
225
+ async function runUnit(unit: RunUnit): Promise<void> {
146
226
  const reporter = getReporter()
147
227
  // Capture order at call time, before the fire-and-forget record below.
148
228
  const sequence = currentScenarioStepSeq++
229
+ // A reason *with* a body is a .fixme (tolerated failure). A reason *without*
230
+ // a body is .blocked (a pending stub that can't be authored yet).
231
+ const fixme = unit.reason !== undefined && unit.fn !== undefined
232
+
233
+ // Phase-1 stub: no body to run. Report it as 'pending' (so the dashboard
234
+ // shows the skeleton — a scenario carrying one reads as 'incomplete') and
235
+ // count it so afterAll can warn. A `reason` here marks it 'blocked' (the
236
+ // feature isn't built); no reason is a plain todo awaiting authoring. No
237
+ // screenshot, zero duration.
238
+ if (!unit.fn) {
239
+ currentScenarioPending++
240
+ if (currentScenarioId) {
241
+ void reporter.recordStep({
242
+ scenarioId: currentScenarioId,
243
+ sequence,
244
+ kind: unit.kind,
245
+ name: unit.name,
246
+ status: 'pending',
247
+ durationMs: 0,
248
+ intent: unit.contract?.intent,
249
+ reason: unit.reason,
250
+ })
251
+ }
252
+ return
253
+ }
254
+
149
255
  const start = Date.now()
150
- const fixme = fixmeReason !== undefined
151
256
  let status: StepStatus = 'passed'
152
257
  let error: string | undefined
153
258
  try {
154
- await fn()
155
- // A fixme step that *passes* is a stale marker: surface it as an
259
+ await unit.fn()
260
+ // A fixme unit that *passes* is a stale marker: surface it as a
156
261
  // 'fixmepass' warning so the author knows they can drop the marker,
157
262
  // rather than letting it pass silently.
158
263
  if (fixme) status = 'fixmepass'
@@ -161,7 +266,7 @@ async function runStep(name: string, fn: () => void | Promise<void>, fixmeReason
161
266
  if (fixme) {
162
267
  // Known / tolerated failure. Record it as 'fixme', but DON'T count it
163
268
  // toward scenario failures and DON'T re-throw — that's the whole point
164
- // of step.fixme: the scenario (and the CI run) stay green, the failure
269
+ // of .fixme: the scenario (and the CI run) stay green, the failure
165
270
  // surfaces as an amber warning on the dashboard.
166
271
  status = 'fixme'
167
272
  } else {
@@ -181,17 +286,41 @@ async function runStep(name: string, fn: () => void | Promise<void>, fixmeReason
181
286
  void reporter.recordStep({
182
287
  scenarioId: currentScenarioId,
183
288
  sequence,
184
- name,
289
+ kind: unit.kind,
290
+ name: unit.name,
185
291
  status,
186
292
  durationMs,
187
293
  error,
188
- reason: fixmeReason,
294
+ intent: unit.contract?.intent,
295
+ reason: unit.reason,
189
296
  screenshotPath,
190
297
  })
191
298
  }
192
299
  }
193
300
  }
194
301
 
302
+ type StepBody = () => void | Promise<void>
303
+
304
+ interface StepFn {
305
+ /** Executable step. */
306
+ (name: string, fn: StepBody): Promise<void>
307
+ /** Phase-1 stub: a step with a contract but no body yet (status: pending). */
308
+ (name: string, contract: StepContract): Promise<void>
309
+ /** Authored step that keeps its durable contract. */
310
+ (name: string, contract: StepContract, fn: StepBody): Promise<void>
311
+ }
312
+
313
+ interface StepExtras {
314
+ fixme: (name: string, reason: string, fn: StepBody) => Promise<void>
315
+ /**
316
+ * A **blocked** pending stub: the step can't be authored yet because the app
317
+ * feature it covers isn't implemented. Reports as 'pending' with the reason
318
+ * attached (the dashboard shows it as blocked, distinct from a plain stub
319
+ * that's merely awaiting a test). `reason` is mandatory — say what's missing.
320
+ */
321
+ blocked: (name: string, reason: string, contract?: StepContract) => Promise<void>
322
+ }
323
+
195
324
  /**
196
325
  * A reportable step inside a scenario. Captures duration + screenshot on
197
326
  * finish, forwards to the active reporter (no-op unless configured via env).
@@ -199,6 +328,14 @@ async function runStep(name: string, fn: () => void | Promise<void>, fixmeReason
199
328
  * The body may be sync or async; `step` always returns a promise, so call it
200
329
  * with `await step('…', async () => { … })`.
201
330
  *
331
+ * Three forms:
332
+ * - `step(name, fn)` — executable step (the common case).
333
+ * - `step(name, { intent, hint })` — a **pending** phase-1 stub: declares the
334
+ * step's intent and what to do, but has no body yet. It does not run and
335
+ * reports as `pending`; `opice-author` fills in the body.
336
+ * - `step(name, { intent }, fn)` — an authored step that keeps its durable
337
+ * `intent` (preserved verbatim from phase 1) alongside the body.
338
+ *
202
339
  * `step.fixme(name, reason, fn)` marks a **known, tolerated failure**: the body
203
340
  * still runs, but a failure inside it does NOT fail the scenario or the CI run —
204
341
  * it's reported as an amber warning instead. The `reason` is mandatory (use it
@@ -206,11 +343,63 @@ async function runStep(name: string, fn: () => void | Promise<void>, fixmeReason
206
343
  * step unexpectedly *passes*, it's flagged too ('fixmepass') so a stale marker
207
344
  * doesn't linger. Unlike Playwright's `test.fixme()`, which **skips** the test,
208
345
  * `step.fixme` **runs** it — the mandatory reason is there to keep them apart.
346
+ *
347
+ * `step.blocked(name, reason, contract?)` is a pending stub that **can't be
348
+ * authored yet** because the app feature doesn't exist — distinct from a plain
349
+ * `step(name, contract)` stub that's simply awaiting a test. Both report as
350
+ * 'pending' (scenario reads 'incomplete'); the blocked one carries its reason.
351
+ */
352
+ export const step: StepFn & StepExtras = Object.assign(
353
+ (name: string, arg2: StepBody | StepContract, arg3?: StepBody): Promise<void> => {
354
+ if (typeof arg2 === 'function') {
355
+ return runUnit({ kind: 'step', name, fn: arg2 })
356
+ }
357
+ return runUnit({ kind: 'step', name, contract: arg2, fn: arg3 })
358
+ },
359
+ {
360
+ fixme: (name: string, reason: string, fn: StepBody): Promise<void> =>
361
+ runUnit({ kind: 'step', name, reason, fn }),
362
+ blocked: (name: string, reason: string, contract?: StepContract): Promise<void> =>
363
+ runUnit({ kind: 'step', name, contract, reason }),
364
+ },
365
+ )
366
+
367
+ /**
368
+ * A scenario-level **invariant** — an acceptance property the scenario
369
+ * enforces, independent of the procedural steps. This is the durable "what
370
+ * must be true" that used to live in a scenario's prose Notes; expressing it as
371
+ * a call keeps it in the one source of truth (the test) instead of a separate
372
+ * `.md` that drifts.
373
+ *
374
+ * A failing `invariant` fails the scenario like any hard assertion — it's an
375
+ * acceptance, not a nicety.
376
+ *
377
+ * - `invariant(name, fn)` — enforced now.
378
+ * - `invariant.todo(name, hint?)` — phase-1 stub: states the acceptance but
379
+ * isn't wired yet (status: pending). `opice-author` promotes it to an
380
+ * enforced `invariant(...)` (or an `invariant.fixme(...)` if it can't hold
381
+ * yet) once it knows how to check it.
382
+ * - `invariant.blocked(name, reason)` — a pending acceptance that can't be
383
+ * wired yet because the feature it guards isn't implemented (vs `.todo`,
384
+ * which is merely awaiting authoring). Reports 'pending' with the reason.
385
+ * - `invariant.fixme(name, reason, fn)` — a known-unenforceable acceptance,
386
+ * tolerated like `step.fixme` (e.g. a security property deferred to a
387
+ * ticket). The body runs and is expected to fail; the failure is reported as
388
+ * an amber warning and neither fails the scenario nor the run.
209
389
  */
210
- export const step = Object.assign(
211
- (name: string, fn: () => void | Promise<void>): Promise<void> => runStep(name, fn),
390
+ export const invariant: {
391
+ (name: string, fn: StepBody): Promise<void>
392
+ todo: (name: string, hint?: string) => Promise<void>
393
+ blocked: (name: string, reason: string) => Promise<void>
394
+ fixme: (name: string, reason: string, fn: StepBody) => Promise<void>
395
+ } = Object.assign(
396
+ (name: string, fn: StepBody): Promise<void> => runUnit({ kind: 'invariant', name, fn }),
212
397
  {
213
- fixme: (name: string, reason: string, fn: () => void | Promise<void>): Promise<void> =>
214
- runStep(name, fn, reason),
398
+ todo: (name: string, hint?: string): Promise<void> =>
399
+ runUnit({ kind: 'invariant', name, contract: hint ? { hint } : undefined }),
400
+ blocked: (name: string, reason: string): Promise<void> =>
401
+ runUnit({ kind: 'invariant', name, reason }),
402
+ fixme: (name: string, reason: string, fn: StepBody): Promise<void> =>
403
+ runUnit({ kind: 'invariant', name, reason, fn }),
215
404
  },
216
405
  )