agents-cli-automation 1.0.11 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-cli-automation",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Agents CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,56 +6,64 @@ argument-hint: "(no args)"
6
6
 
7
7
  # Playwright + TypeScript (BDD-capable) — repo snapshot
8
8
 
9
- This file documents the current Playwright + TypeScript testing scaffold in the repository and explains how the BDD workflow is wired right now.
9
+ This document explains the current Playwright + TypeScript scaffold and details the recommended layout for:
10
+ - Page Object Models using `@playwright/test`
11
+ - A small JSON data util
12
+ - Fixtures wired for `playwright-bdd`
13
+ - Step definitions that consume fixtures via `playwright-bdd`
10
14
 
11
- **Key points (current state)**
12
- - Playwright config exports a BDD config and a standard config: see [playwright.config.ts](playwright.config.ts).
13
- - Feature files live under `tests/features` (example: [tests/features/login.feature](tests/features/login.feature)).
14
- - Generated BDD test output (from Playwright-BDD / generator) appears under `.features-gen` (example: [.features-gen/tests/features/login.feature.spec.js](.features-gen/tests/features/login.feature.spec.js)).
15
- - Fixtures are defined in [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts). The repository uses the `playwright-bdd` test extension so steps can access fixtures like `loginPage`.
16
- - Step definitions live in [tests/steps](tests/steps). Example: [tests/steps/loginSteps.ts](tests/steps/loginSteps.ts) it uses `createBdd(test)` from `playwright-bdd` and registers Given/When/Then steps that operate on the `loginPage` fixture.
17
- - TypeScript path aliases are configured in [tsconfig.json](tsconfig.json) for convenience (e.g. `@steps/*`, `@pages/*`, `@fixtures/*`).
15
+ **Key points (current state and recommended layout)**
16
+ - Playwright config exports both the regular `PlaywrightTestConfig` and a `bddConfig` used by generators: see [playwright.config.ts](playwright.config.ts).
17
+ - Place Gherkin features in `tests/features/*.feature` (example: [tests/features/login.feature](tests/features/login.feature)).
18
+ - Page Objects: implement page classes under `tests/pages/` (example: `tests/pages/login.page.ts`) and import `Page` from `@playwright/test`.
19
+ - Test data util: add a JSON reader like `tests/utils/data.ts` that loads `tests/data/*.json` so tests/steps can read credentials and fixtures.
20
+ - Fixtures: create `tests/fixtures/base.fixture.ts` that extends `test` from `@playwright/test` and registers fixtures (for example `loginPage`) — when using BDD, expose those fixtures so step files can receive them.
21
+ - Steps: implement step definitions under `tests/steps/*.ts`. Use `createBdd(test)` from `playwright-bdd` and register Given/When/Then handlers that accept fixtures (e.g., `loginPage`) and call page object methods.
22
+ - Generated specs: the generator writes Playwright specs into `.features-gen` by default when using `npx bddgen` and the exported `bddConfig` globs.
18
23
 
19
- Files to inspect quickly
24
+ Files to inspect or add quickly
20
25
  - Playwright config: [playwright.config.ts](playwright.config.ts)
21
26
  - TS config / aliases: [tsconfig.json](tsconfig.json)
22
- - Main fixture: [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts)
27
+ - Page object example: [tests/pages/login.page.ts](tests/pages/login.page.ts)
28
+ - JSON data util: [tests/utils/data.ts](tests/utils/data.ts)
29
+ - Test data: [tests/data/users.json](tests/data/users.json)
30
+ - Fixtures: [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts)
23
31
  - Steps: [tests/steps/loginSteps.ts](tests/steps/loginSteps.ts)
24
32
  - Feature: [tests/features/login.feature](tests/features/login.feature)
25
- - Generated spec: [.features-gen/tests/features/login.feature.spec.js](.features-gen/tests/features/login.feature.spec.js)
26
- - Package scripts: [package.json](package.json)
27
-
28
- How the BDD flow works here
29
- - Edit or add Gherkin features in `tests/features/*.feature` and step implementations in `tests/steps/*.ts`.
30
- - Generate Playwright specs from features/steps with either Playwright-BDD's generator or a local generator (if present). Common commands:
31
- - Use the Playwright-BDD generator (fetches CLI via npx):
32
- ```bash
33
- npx bddgen
34
- ```
35
- - Or run a local generator script if your `package.json` defines one (check `package.json` for `generate:bdd`).
36
- - Generated specs are written to `.features-gen` (this repo currently contains generated files under `.features-gen/tests/features/`). Those generated specs import the repository fixtures and call `Given/When/Then` using the BDD test helpers.
37
-
38
- Run the UI BDD tests
33
+ - Direct Playwright spec (optional): [tests/specs/login.spec.ts](tests/specs/login.spec.ts)
34
+
35
+ How the flow works here
36
+ - Create page classes that import `Page` from `@playwright/test`; page methods should perform simple interactions and checks (for example, `LoginPage.goto()`, `LoginPage.login()`, `LoginPage.isInventoryVisible()`).
37
+ - Add a small data helper `readTestData(path)` that loads JSON from `tests/data/` so credentials are not hard-coded in steps or specs.
38
+ - Implement `tests/fixtures/base.fixture.ts` that extends Playwright's `test` to provide page-object fixtures (e.g., `loginPage`) so both direct specs and generated BDD specs can reuse them.
39
+ - Write step definitions in `tests/steps/*.ts` using `playwright-bdd`'s `createBdd(test)` helper. Example pattern:
40
+ - import `createBdd` and your `test` fixture: `const { Given, When, Then } = createBdd(test)`
41
+ - register steps that accept fixtures: `Given('I open login page', async ({ loginPage }) => { await loginPage.goto(); })`.
42
+ - Option A — Generator flow: use `npx bddgen` to turn `.feature` files into Playwright specs in `.features-gen` (generator reads `bddConfig` in `playwright.config.ts`). Note: some generator tools require specific versions of `@cucumber/cucumber` or other peer deps; if generator errors occur, either install the missing peer or use the direct-spec option below.
43
+ - Option B Direct spec flow (recommended for quick runs): write a small `tests/specs/*.ts` Playwright test that imports your fixtures and page objects (no generation). This bypasses generator compatibility issues and runs immediately with `npx playwright test`.
44
+
45
+ Run the direct Playwright spec (no generator required):
46
+
39
47
  ```bash
40
- # install deps (first time)
41
48
  npm install
42
- npx playwright install chromium
49
+ npx playwright install
50
+ npx playwright test --project=ui tests/specs/login.spec.ts
51
+ ```
43
52
 
44
- # generate specs (use either bddgen or local generator)
45
- npx bddgen
46
- # or (if present) npm run generate:bdd
53
+ Generator flow (if you want `.features-gen` generated specs):
47
54
 
48
- # run UI project (headed)
49
- npx playwright test --project=ui --headed
55
+ ```bash
56
+ npm install
57
+ npx bddgen
58
+ npx playwright test --project=ui
50
59
  ```
51
60
 
52
61
  Notes & tips
53
- - If `npx bddgen` is used it will read `bddConfig` exported from [playwright.config.ts](playwright.config.ts) (the `features` and `steps` globs) and will output generated `.feature.spec.*` files into the configured location.
54
- - The generated specs reference the repository fixtures (so keep `tests/fixtures/base.fixture.ts` exports stable).
55
- - If TypeScript path aliases are used, ensure editors and build tooling pick up `tsconfig.json` aliases.
56
- - If you want me to update any generated-spec import style (e.g. prefer `.ts` vs `.js`, or use path aliases inside generator output), tell me which style you prefer and I will patch the generator and re-generate specs.
62
+ - Keep fixtures stable: generated specs import your fixture module, so keep `tests/fixtures/base.fixture.ts` API stable.
63
+ - If `npx bddgen` errors with a missing module like `@cucumber/cucumber`, install the required peer dependency (for example `npm install --save-dev @cucumber/cucumber`) or prefer the direct-spec flow until generator versions are aligned.
64
+ - Steps should not import `@playwright/test` directly for test helpers they should use the fixtures passed by `playwright-bdd` (the `test` instance you pass to `createBdd(test)`). Page objects, however, should import `Page` and be created inside fixtures.
57
65
 
58
66
  If you'd like, I can now:
59
- - Run `npx bddgen` and then `npx playwright test --project=ui --headed` and show the test output, or
60
- - Adjust where the `ui` project looks for generated specs (e.g. change `testDir` to `tests/.features-gen`), or
61
- - Update the generator output to use TypeScript aliases for cleaner imports.
67
+ - Run the direct spec and show results, or
68
+ - Add full `tests/steps/*.ts` step definitions wired to the fixtures and attempt to re-run `npx bddgen` to regenerate specs, or
69
+ - Initialize Git + CI and wire the test into a workflow.