@integry/sdk 4.6.9 → 4.6.11

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.
@@ -0,0 +1,80 @@
1
+ import OpenAI from 'openai';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import dotenv from 'dotenv';
5
+
6
+ dotenv.config();
7
+
8
+ const openai = new OpenAI({
9
+ apiKey: "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",
10
+ });
11
+
12
+ async function generateTest(filePath, feedback = '') {
13
+ const code = fs.readFileSync(filePath, 'utf-8');
14
+
15
+ let messages = [
16
+ { role: 'system', content: 'You are a senior Preact developer with expertise in testing. Use Vitest framework.' },
17
+ { role: 'user', content: `Write Vitest unit tests for the following Preact component:\n${code}\n
18
+ Make sure to cover:
19
+ - Props validation
20
+ - Event handlers
21
+ - Conditional rendering
22
+ - User interactions
23
+ - Edge cases
24
+ ` }
25
+ ];
26
+
27
+ if (feedback) {
28
+ messages.push({
29
+ role: 'user',
30
+ content: `Here is the previous generated test:\n${feedback}\nPlease improve the tests based on the following feedback:
31
+ - Add more edge cases.
32
+ - You didn't test fields inside objects represented by field.properties or field.template_fields
33
+ - If object has no field, it should render a textarea.`
34
+ });
35
+ }
36
+
37
+ const completion = await openai.chat.completions.create({
38
+ model: 'gpt-4-turbo',
39
+ messages,
40
+ temperature: 0.3,
41
+ });
42
+
43
+ const generatedTests = completion.choices[0]?.message?.content || '';
44
+
45
+ const testFilePath = filePath.replace('.ts', '.test.ts');
46
+ fs.writeFileSync(testFilePath, generatedTests);
47
+
48
+ console.log(`✅ Test file generated: ${testFilePath}`);
49
+
50
+ return generatedTests;
51
+ }
52
+
53
+ async function main() {
54
+ // const componentsFolder = './src/components/form/ObjectField'; // Update this path
55
+ const componentsFolder = process.argv[2]; // Get folder path from command line argument
56
+
57
+ if (!componentsFolder) {
58
+ console.error('❌ Please provide the components folder path as an argument.');
59
+ process.exit(1);
60
+ }
61
+
62
+ if (!fs.existsSync(componentsFolder)) {
63
+ console.error(`❌ Path "${componentsFolder}" does not exist.`);
64
+ process.exit(1);
65
+ }
66
+ const files = fs.readdirSync(componentsFolder).filter((file) => file.endsWith('.ts'));
67
+
68
+ for (const file of files) {
69
+ const testFilePath = path.join(componentsFolder, `${file.replace('.ts', '.test.ts')}`);
70
+ let previousTest = '';
71
+
72
+ if (fs.existsSync(testFilePath)) {
73
+ previousTest = fs.readFileSync(testFilePath, 'utf-8');
74
+ }
75
+
76
+ await generateTest(path.join(componentsFolder, file), previousTest);
77
+ }
78
+ }
79
+
80
+ main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integry/sdk",
3
- "version": "4.6.9",
3
+ "version": "4.6.11",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -51,6 +51,7 @@
51
51
  "@storybook/preact": "^8.5.7",
52
52
  "@storybook/preact-webpack5": "^8.5.7",
53
53
  "@storybook/preset-scss": "^1.0.3",
54
+ "@testing-library/jest-dom": "^6.6.3",
54
55
  "@testing-library/preact": "^2.0.1",
55
56
  "@testing-library/user-event": "^14.6.1",
56
57
  "@types/jest": "^26.0.23",
@@ -102,6 +103,7 @@
102
103
  "fuzzysort": "^1.1.4",
103
104
  "htm": "3.1.0",
104
105
  "lit": "^3.2.1",
106
+ "openai": "^4.86.1",
105
107
  "preact": "^10.2.0",
106
108
  "superstruct": "^0.15.2",
107
109
  "unfetch": "^4.2.0",
File without changes
@@ -0,0 +1,3 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`ObjectField Component > renders with minimal props 1`] = `<div />`;
@@ -367,7 +367,11 @@ const ObjectField = (props: ObjectFieldProps) => {
367
367
  isMappable=${activityOutputDataRaw &&
368
368
  Object.entries(activityOutputDataRaw).length > 0}
369
369
  allowTagsInText=${activityOutputDataRaw}
370
- value=${formatValueForTextarea(objectValue)}
370
+ value=${objectHasFields
371
+ ? (objectArray[objectIndex] || {})[
372
+ fieldDetails?.meta?.machine_name || ''
373
+ ] || ''
374
+ : formatValueForTextarea(objectValue)}
371
375
  ><//>
372
376
  `}
373
377
  ${fieldType === 'CHECKBOX' &&
@@ -1490,7 +1490,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1490
1490
  html`
1491
1491
  <div id=${`integry-action-field-wrap-${
1492
1492
  el?.activity_field?.machine_name || ''
1493
- }`} class=${`integry-action-field-wrap`}>
1493
+ }`} class=${`integry-action-field-wrap ${
1494
+ el.is_visible ? '' : styles.fNotVisible
1495
+ }`}>
1494
1496
  <${ConfigureFieldWrapper}
1495
1497
  field=${el}
1496
1498
  stepId=${step.id}