genat-mcp 2.3.3 → 2.3.4
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 +7 -2
- package/detect-framework.js +10 -4
- package/index.js +1 -1
- package/package.json +1 -1
- package/pytest-bdd-paths.js +23 -5
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ When creating run-genat.mjs: Use webhook-genat-login, NOT webhook-genat. Prefer
|
|
|
212
212
|
|
|
213
213
|
- **url** (string): Page URL to analyze for accessibility.
|
|
214
214
|
- **parentProjectFolder** (string): Path to the project root (TypeScript, JavaScript, or Python Playwright).
|
|
215
|
-
- **writeToProject** (boolean, optional): If `true`, write generated files under `tests/accessibility/` by default; for **pytest-bdd** Python projects, files go under `features/` / `step_defs/` (or `tests/features`, `steps`, etc.) when those directories exist.
|
|
215
|
+
- **writeToProject** (boolean, optional): If `true`, write generated files under `tests/accessibility/` by default; for **pytest-bdd** Python projects, files go under `features/` / `step_defs/` (or `tests/features`, `steps`, etc.) when those directories exist. New projects get **`step_defs/test_accessibility_steps.py`** when `accessibility_steps.py` is not already present.
|
|
216
216
|
- **maxAssertions** (number, optional): Override default assertion count for complex pages (e.g. `25`).
|
|
217
217
|
- **scopeToRegions** (string[], optional): Limit tests to specific regions (e.g. `["header", "main", "table"]`).
|
|
218
218
|
- **analyzeStates** (boolean, optional): If `true`, run axe in expanded dropdown/combobox states and include state-specific violations. Increases analysis time.
|
|
@@ -234,10 +234,15 @@ Generated tests include keyboard accessibility checks (Tab order, focus) by defa
|
|
|
234
234
|
GenAT does not guarantee that every Gherkin line has an implemented step. For **pytest-bdd** projects, the calling application or CI can:
|
|
235
235
|
|
|
236
236
|
1. Parse `*.feature` step lines (after `Given`/`When`/`Then`/`And`/`But`).
|
|
237
|
-
2. Confirm `accessibility_steps.py` (
|
|
237
|
+
2. Confirm `test_accessibility_steps.py` or `accessibility_steps.py` (your step module) defines matching `@given`/`@when`/`@then` patterns (or run `pytest --collect-only` / a dry run).
|
|
238
238
|
|
|
239
239
|
Keep this as an optional pre-merge check alongside `_stepDefIncomplete`.
|
|
240
240
|
|
|
241
|
+
### pytest-bdd discovery and axe-playwright-python
|
|
242
|
+
|
|
243
|
+
- **Pytest** collects `test_*.py` by default. GenAT now prefers writing **`step_defs/test_accessibility_steps.py`** for new projects; if **`accessibility_steps.py`** already exists, that path is used. Ensure **`@scenario`** test functions are in a collected module (often the same file when named `test_*.py`) or import step defs from **`conftest.py`** / **`pytest_plugins`**.
|
|
244
|
+
- **axe-playwright-python (sync):** `from axe_playwright_python.sync_playwright import Axe`; `axe = Axe()`; `results = axe.run(page)`; read **`results.response`** (axe-core JSON) and **`results.violations_count`**. Do not invent other APIs—see [axe-playwright-python docs](https://pamelafox.github.io/axe-playwright-python/).
|
|
245
|
+
|
|
241
246
|
## Sample prompts
|
|
242
247
|
|
|
243
248
|
See [prompts.md](prompts.md) for a full list of prompts including specific parent folders, login, JIRA, and combined options.
|
package/detect-framework.js
CHANGED
|
@@ -77,15 +77,21 @@ function collectProjectLayoutHints(root, scriptType, bddFramework) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (existsSync(join(root, 'step_defs'))) {
|
|
80
|
-
parts.push(
|
|
80
|
+
parts.push(
|
|
81
|
+
'Put step definitions under step_defs/; prefer test_accessibility_steps.py (test_*.py) so pytest discovers @scenario tests, or keep accessibility_steps.py and import that module from conftest.py'
|
|
82
|
+
);
|
|
81
83
|
} else if (existsSync(join(root, 'steps'))) {
|
|
82
|
-
parts.push('Put step definitions under steps
|
|
84
|
+
parts.push('Put step definitions under steps/; prefer test_*.py naming for pytest collection or import via conftest.py');
|
|
83
85
|
} else if (existsSync(join(root, 'tests', 'step_defs'))) {
|
|
84
|
-
parts.push('Put step definitions under tests/step_defs
|
|
86
|
+
parts.push('Put step definitions under tests/step_defs/; prefer test_accessibility_steps.py or conftest import');
|
|
85
87
|
} else {
|
|
86
|
-
parts.push('Prefer step_defs/ for pytest-bdd
|
|
88
|
+
parts.push('Prefer step_defs/ for pytest-bdd; use test_accessibility_steps.py for pytest discovery of scenario tests');
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
parts.push(
|
|
92
|
+
'Pytest collects test_*.py by default; ensure BDD scenario functions (@scenario) live in a collected module or are pulled in via conftest/pytest_plugins'
|
|
93
|
+
);
|
|
94
|
+
|
|
89
95
|
const conftestPaths = walkWithPaths(root, (f) => f === 'conftest.py');
|
|
90
96
|
const fixtureNames = new Set();
|
|
91
97
|
for (const p of conftestPaths.slice(0, 3)) {
|
package/index.js
CHANGED
package/package.json
CHANGED
package/pytest-bdd-paths.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolve pytest-bdd feature / step / spec paths from project layout (same rules as write-files).
|
|
3
|
+
* Step file: prefer legacy accessibility_steps.py if present; otherwise test_accessibility_steps.py
|
|
4
|
+
* so pytest discovers scenario tests (test_*.py).
|
|
3
5
|
*/
|
|
4
6
|
import { existsSync } from 'fs';
|
|
5
7
|
import { join } from 'path';
|
|
6
8
|
|
|
7
9
|
const DEFAULT_DIR = 'tests/accessibility';
|
|
8
10
|
|
|
11
|
+
const LEGACY_STEP = 'accessibility_steps.py';
|
|
12
|
+
const TEST_STEP = 'test_accessibility_steps.py';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} root
|
|
16
|
+
* @param {string[]} dirSegments - e.g. ['step_defs']
|
|
17
|
+
* @returns {string} relative path to step file
|
|
18
|
+
*/
|
|
19
|
+
function pickStepFileUnderDir(root, dirSegments) {
|
|
20
|
+
const legacy = join(...dirSegments, LEGACY_STEP);
|
|
21
|
+
const testNamed = join(...dirSegments, TEST_STEP);
|
|
22
|
+
if (existsSync(join(root, legacy))) return legacy;
|
|
23
|
+
if (existsSync(join(root, testNamed))) return testNamed;
|
|
24
|
+
return testNamed;
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
/**
|
|
10
28
|
* @param {string} root
|
|
11
29
|
* @returns {{ featureRel: string, stepRel: string, specRel: string }}
|
|
@@ -17,11 +35,11 @@ export function resolvePytestBddPaths(root) {
|
|
|
17
35
|
else featureRel = join('features', 'accessibility.feature');
|
|
18
36
|
|
|
19
37
|
let stepRel;
|
|
20
|
-
if (existsSync(join(root, 'step_defs'))) stepRel =
|
|
21
|
-
else if (existsSync(join(root, 'steps'))) stepRel =
|
|
22
|
-
else if (existsSync(join(root, 'tests', 'step_defs'))) stepRel =
|
|
23
|
-
else if (existsSync(join(root, 'tests', 'steps'))) stepRel =
|
|
24
|
-
else stepRel = join('step_defs',
|
|
38
|
+
if (existsSync(join(root, 'step_defs'))) stepRel = pickStepFileUnderDir(root, ['step_defs']);
|
|
39
|
+
else if (existsSync(join(root, 'steps'))) stepRel = pickStepFileUnderDir(root, ['steps']);
|
|
40
|
+
else if (existsSync(join(root, 'tests', 'step_defs'))) stepRel = pickStepFileUnderDir(root, ['tests', 'step_defs']);
|
|
41
|
+
else if (existsSync(join(root, 'tests', 'steps'))) stepRel = pickStepFileUnderDir(root, ['tests', 'steps']);
|
|
42
|
+
else stepRel = join('step_defs', TEST_STEP);
|
|
25
43
|
|
|
26
44
|
const specRel = join(DEFAULT_DIR, 'accessibility_test.py');
|
|
27
45
|
return { featureRel, stepRel, specRel };
|