@flash-ai-team/flash-test-framework 0.0.11 → 0.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.
@@ -1,2 +1,3 @@
1
- export declare function TestCase(target: any, propertyKey: string, descriptor: PropertyDescriptor): void | PropertyDescriptor;
2
- export declare function TestCase(value: Function, context: ClassMethodDecoratorContext): Function;
1
+ export declare function TestCase(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor;
2
+ export declare function TestCase<This, Args extends any[], Return>(target: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>): (this: This, ...args: Args) => Return;
3
+ export declare function TestCase(): any;
@@ -43,39 +43,52 @@ function getCallerFile() {
43
43
  }
44
44
  return '';
45
45
  }
46
- function TestCase(targetOrValue, contextOrKey, descriptor) {
47
- // Stage 3: (value, context)
48
- if (typeof contextOrKey === 'object' && contextOrKey !== null && 'kind' in contextOrKey) {
49
- const originalMethod = targetOrValue;
50
- const context = contextOrKey;
51
- const methodName = String(context.name);
52
- // Capture at definition time
53
- const definitionFile = getCallerFile();
54
- return async function (...args) {
55
- test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
56
- if (definitionFile) {
57
- test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
58
- }
59
- return await originalMethod.apply(this, args);
60
- };
61
- }
62
- // Legacy: (target, propertyKey, descriptor)
63
- let legacyDescriptor = descriptor;
64
- if (!legacyDescriptor && typeof contextOrKey === 'string') {
65
- legacyDescriptor = Object.getOwnPropertyDescriptor(targetOrValue, contextOrKey);
46
+ function TestCase(arg1, arg2, arg3) {
47
+ // Helper to apply the logic (shared between factory and direct call)
48
+ const applyDecorator = (targetOrValue, contextOrKey, descriptor) => {
49
+ // Stage 3: (value, context)
50
+ if (typeof contextOrKey === 'object' && contextOrKey !== null && 'kind' in contextOrKey) {
51
+ const originalMethod = targetOrValue;
52
+ const context = contextOrKey;
53
+ const methodName = String(context.name);
54
+ const definitionFile = getCallerFile();
55
+ return async function (...args) {
56
+ test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
57
+ if (definitionFile) {
58
+ test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
59
+ }
60
+ return await originalMethod.apply(this, args);
61
+ };
62
+ }
63
+ // Legacy: (target, propertyKey, descriptor)
64
+ let legacyDescriptor = descriptor;
65
+ if (!legacyDescriptor && typeof contextOrKey === 'string') {
66
+ legacyDescriptor = Object.getOwnPropertyDescriptor(targetOrValue, contextOrKey);
67
+ }
68
+ if (legacyDescriptor) {
69
+ const originalMethod = legacyDescriptor.value;
70
+ const methodName = contextOrKey;
71
+ const definitionFile = getCallerFile();
72
+ legacyDescriptor.value = async function (...args) {
73
+ test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
74
+ if (definitionFile) {
75
+ test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
76
+ }
77
+ return await originalMethod.apply(this, args);
78
+ };
79
+ return legacyDescriptor;
80
+ }
81
+ };
82
+ // Determine usage type
83
+ const isDirectCall = (arg2 && typeof arg2 === 'string') || // Legacy: (target, key)
84
+ (arg2 && typeof arg2 === 'object' && 'kind' in arg2); // Stage 3: (value, context)
85
+ if (isDirectCall) {
86
+ return applyDecorator(arg1, arg2, arg3);
66
87
  }
67
- if (legacyDescriptor) {
68
- const originalMethod = legacyDescriptor.value;
69
- const methodName = contextOrKey;
70
- // Capture at definition time
71
- const definitionFile = getCallerFile();
72
- legacyDescriptor.value = async function (...args) {
73
- test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
74
- if (definitionFile) {
75
- test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
76
- }
77
- return await originalMethod.apply(this, args);
88
+ else {
89
+ // Factory usage: @TestCase()
90
+ return function (target, key, descriptor) {
91
+ return applyDecorator(target, key, descriptor);
78
92
  };
79
- return legacyDescriptor;
80
93
  }
81
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flash-ai-team/flash-test-framework",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "A powerful keyword-driven automation framework built on top of Playwright and TypeScript.",
5
5
  "keywords": [
6
6
  "playwright",