declapract-typescript-ehmpathy 0.47.9 → 0.47.10

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 (15) hide show
  1. package/dist/practices/tests/bad-practices/old-acceptance-dir-location/.declapract.readme.md +22 -0
  2. package/dist/practices/tests/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.acceptance.test.ts.declapract.ts +19 -0
  3. package/dist/practices/tests/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.ts.declapract.ts +19 -0
  4. package/dist/practices/tests/bad-practices/old-acceptance-import-paths/.declapract.readme.md +31 -0
  5. package/dist/practices/tests/bad-practices/old-acceptance-import-paths/<star><star>/<star>.ts.declapract.ts +25 -0
  6. package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md +1 -1
  7. package/package.json +1 -1
  8. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/_utils/getDataFromLastOpenBracketAtStartOfLine.ts.declapract.ts +0 -0
  9. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/_utils/invokeLambda.ts.declapract.ts +0 -0
  10. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
  11. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-2/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
  12. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-3/{acceptance → blackbox}/_utils/environment.ts.declapract.ts +0 -0
  13. /package/dist/practices/tests/bad-practices/old-acceptance-test-utils-3/{acceptance → blackbox}/lambdas/<star>.ts.declapract.ts +0 -0
  14. /package/dist/practices/tests-service/best-practice/{acceptance → blackbox}/<star><star>/<star>.acceptance.test.ts.declapract.ts +0 -0
  15. /package/dist/practices/tests-service/best-practice/{acceptance → blackbox}/lambdas/<star>.acceptance.test.ts.declapract.ts +0 -0
@@ -0,0 +1,22 @@
1
+ # old-acceptance-dir-location
2
+
3
+ ## .what
4
+
5
+ detects test files located in `acceptance/` directory and migrates them to `blackbox/`.
6
+
7
+ ## .why
8
+
9
+ the term "blackbox" makes the testing philosophy explicit:
10
+ - blackbox tests interact only through public contracts (APIs, CLIs, SDKs)
11
+ - no access to internal implementation details
12
+ - tests validate behavior from the caller's perspective
13
+
14
+ the rename from `acceptance/` to `blackbox/` clarifies this intent.
15
+
16
+ ## .fix
17
+
18
+ moves all files from `acceptance/` to `blackbox/` while preserving the directory structure.
19
+
20
+ ## .note
21
+
22
+ the `.acceptance.test.ts` file extension is preserved — it communicates the test type while the directory name communicates the testing philosophy.
@@ -0,0 +1,19 @@
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
+
3
+ export const check = FileCheckType.EXISTS; // if files exist in acceptance/, flag as bad practice
4
+
5
+ /**
6
+ * .what = moves acceptance test files from acceptance/ to blackbox/
7
+ * .why = blackbox/ naming makes the testing philosophy explicit
8
+ */
9
+ export const fix: FileFixFunction = (contents, context) => {
10
+ // move from acceptance/ to blackbox/
11
+ const newPath = context.relativeFilePath.replace(
12
+ /^acceptance\//,
13
+ 'blackbox/',
14
+ );
15
+ return {
16
+ contents: contents ?? null,
17
+ relativeFilePath: newPath,
18
+ };
19
+ };
@@ -0,0 +1,19 @@
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
+
3
+ export const check = FileCheckType.EXISTS; // if any ts files exist in acceptance/, flag as bad practice
4
+
5
+ /**
6
+ * .what = moves ts files from acceptance/ to blackbox/
7
+ * .why = blackbox/ naming makes the testing philosophy explicit
8
+ */
9
+ export const fix: FileFixFunction = (contents, context) => {
10
+ // move from acceptance/ to blackbox/
11
+ const newPath = context.relativeFilePath.replace(
12
+ /^acceptance\//,
13
+ 'blackbox/',
14
+ );
15
+ return {
16
+ contents: contents ?? null,
17
+ relativeFilePath: newPath,
18
+ };
19
+ };
@@ -0,0 +1,31 @@
1
+ # old-acceptance-import-paths
2
+
3
+ ## .what
4
+
5
+ detects import statements that reference the old `acceptance/` directory path.
6
+
7
+ ## .why
8
+
9
+ the `acceptance/` directory has been renamed to `blackbox/` to make the testing philosophy explicit:
10
+ - blackbox tests interact only through public contracts
11
+ - no access to internal implementation details
12
+
13
+ import paths must be updated to reference `blackbox/` instead of `acceptance/`.
14
+
15
+ ## .fix
16
+
17
+ replaces all occurrences of `acceptance/` with `blackbox/` in import paths.
18
+
19
+ ## .examples
20
+
21
+ before:
22
+ ```typescript
23
+ import { locally } from '../acceptance/environment';
24
+ import { stage } from '../../acceptance/utils/environment';
25
+ ```
26
+
27
+ after:
28
+ ```typescript
29
+ import { locally } from '../blackbox/environment';
30
+ import { stage } from '../../blackbox/utils/environment';
31
+ ```
@@ -0,0 +1,25 @@
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
+
3
+ /**
4
+ * .what = detects imports that reference acceptance/ directory
5
+ * .why = acceptance/ has been renamed to blackbox/
6
+ */
7
+ export const check: FileCheckFunction = (contents) => {
8
+ // match imports that reference acceptance/ directory
9
+ if (contents?.match(/from ['"]\.\.?\/.*acceptance\//)) return; // matches bad practice
10
+ if (contents?.match(/from ['"]acceptance\//)) return; // matches bad practice
11
+ throw new Error('does not match bad practice');
12
+ };
13
+
14
+ /**
15
+ * .what = replaces acceptance/ with blackbox/ in import paths
16
+ * .why = blackbox/ naming makes the testing philosophy explicit
17
+ */
18
+ export const fix: FileFixFunction = (contents) => {
19
+ if (!contents) return {};
20
+ return {
21
+ contents: contents
22
+ .replace(/(['"])(.*)\/acceptance\//g, '$1$2/blackbox/')
23
+ .replace(/(['"])acceptance\//g, '$1blackbox/'),
24
+ };
25
+ };
@@ -5,4 +5,4 @@ the `.test.utils/` directory replaces `__test_utils__` and `.test.assets/` repla
5
5
  examples:
6
6
  - `src/domain/__test_utils__/exampleUser.ts` → `src/domain/.test.utils/exampleUser.ts`
7
7
  - `src/logic/__test_assets__/fixtures.json` → `src/logic/.test.assets/fixtures.json`
8
- - `acceptance/__test_utils__/environment.ts` → `acceptance/.test.utils/environment.ts`
8
+ - `blackbox/__test_utils__/environment.ts` → `blackbox/.test.utils/environment.ts`
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.47.9",
5
+ "version": "0.47.10",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",