@thinkwise/testwise 0.1.97 → 0.2.0-beta.3
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/Testwise.ts +8 -13
- package/artifact-builder/ArtifactManager.ts +34 -0
- package/artifact-builder/InterfaceGenerator.ts +183 -0
- package/artifact-builder/ModelDataBuilder.ts +177 -0
- package/artifact-builder/ModelDataRefiner.ts +38 -0
- package/artifact-builder/SchemaGenerator.ts +134 -0
- package/artifact-builder/ScreenInterfaceRefiner.ts +159 -0
- package/artifact-builder/SelectorBuilder.ts +82 -0
- package/artifact-builder/SubjectComponentGenerator.ts +186 -0
- package/artifact-builder/SubjectGenerator.ts +332 -0
- package/artifact-builder/SubjectRegistration.ts +136 -0
- package/artifact-builder/helpers/DataRetriever.ts +64 -0
- package/artifact-builder/helpers/NamingHandler.ts +180 -0
- package/artifact-builder/helpers/index.ts +2 -0
- package/artifact-builder/index.ts +9 -0
- package/components/{actionbar/Actionbar.ts → action-bar/ActionBar.ts} +12 -12
- package/components/{actionbar/ActionbarObjects.ts → action-bar/ActionBarObjects.ts} +4 -4
- package/components/{actionbar → action-bar}/CustomActionBar.ts +2 -2
- package/components/index.ts +3 -4
- package/components/tab/DetailTabPage.ts +20 -0
- package/components/tab/{DetailTabObjects.ts → DetailTabPageObjects.ts} +1 -1
- package/components/tab/Tab.ts +31 -5
- package/components/tab/TabObjects.ts +15 -3
- package/dist/Testwise.d.ts +0 -1
- package/dist/Testwise.js +7 -14
- package/dist/Testwise.js.map +1 -1
- package/dist/artifact-builder/ArtifactManager.d.ts +8 -0
- package/dist/artifact-builder/ArtifactManager.js +27 -0
- package/dist/artifact-builder/ArtifactManager.js.map +1 -0
- package/dist/artifact-builder/InterfaceGenerator.d.ts +16 -0
- package/dist/artifact-builder/InterfaceGenerator.js +134 -0
- package/dist/artifact-builder/InterfaceGenerator.js.map +1 -0
- package/dist/artifact-builder/ModelDataBuilder.d.ts +2 -0
- package/dist/artifact-builder/ModelDataBuilder.js +128 -0
- package/dist/artifact-builder/ModelDataBuilder.js.map +1 -0
- package/dist/artifact-builder/ModelDataRefiner.d.ts +4 -0
- package/dist/artifact-builder/ModelDataRefiner.js +28 -0
- package/dist/artifact-builder/ModelDataRefiner.js.map +1 -0
- package/dist/artifact-builder/SchemaGenerator.d.ts +12 -0
- package/dist/artifact-builder/SchemaGenerator.js +104 -0
- package/dist/artifact-builder/SchemaGenerator.js.map +1 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.d.ts +15 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.js +125 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.js.map +1 -0
- package/dist/artifact-builder/SelectorBuilder.d.ts +13 -0
- package/dist/artifact-builder/SelectorBuilder.js +69 -0
- package/dist/artifact-builder/SelectorBuilder.js.map +1 -0
- package/dist/artifact-builder/SubjectComponentGenerator.d.ts +23 -0
- package/dist/artifact-builder/SubjectComponentGenerator.js +136 -0
- package/dist/artifact-builder/SubjectComponentGenerator.js.map +1 -0
- package/dist/artifact-builder/SubjectGenerator.d.ts +27 -0
- package/dist/artifact-builder/SubjectGenerator.js +235 -0
- package/dist/artifact-builder/SubjectGenerator.js.map +1 -0
- package/dist/artifact-builder/SubjectRegistration.d.ts +22 -0
- package/dist/artifact-builder/SubjectRegistration.js +96 -0
- package/dist/artifact-builder/SubjectRegistration.js.map +1 -0
- package/dist/artifact-builder/helpers/DataRetriever.d.ts +12 -0
- package/dist/artifact-builder/helpers/DataRetriever.js +52 -0
- package/dist/artifact-builder/helpers/DataRetriever.js.map +1 -0
- package/dist/artifact-builder/helpers/NamingHandler.d.ts +24 -0
- package/dist/artifact-builder/helpers/NamingHandler.js +145 -0
- package/dist/artifact-builder/helpers/NamingHandler.js.map +1 -0
- package/dist/artifact-builder/helpers/index.d.ts +2 -0
- package/dist/artifact-builder/helpers/index.js +3 -0
- package/dist/artifact-builder/helpers/index.js.map +1 -0
- package/dist/artifact-builder/index.d.ts +9 -0
- package/dist/artifact-builder/index.js +10 -0
- package/dist/artifact-builder/index.js.map +1 -0
- package/dist/components/{actionbar/Actionbar.d.ts → action-bar/ActionBar.d.ts} +4 -4
- package/dist/components/{actionbar/Actionbar.js → action-bar/ActionBar.js} +9 -9
- package/dist/components/action-bar/ActionBar.js.map +1 -0
- package/dist/components/{actionbar/ActionbarObjects.d.ts → action-bar/ActionBarObjects.d.ts} +2 -2
- package/dist/components/{actionbar/ActionbarObjects.js → action-bar/ActionBarObjects.js} +5 -5
- package/dist/components/action-bar/ActionBarObjects.js.map +1 -0
- package/dist/components/{actionbar → action-bar}/CustomActionBar.d.ts +2 -2
- package/dist/components/action-bar/CustomActionBar.js +7 -0
- package/dist/components/action-bar/CustomActionBar.js.map +1 -0
- package/dist/components/index.d.ts +3 -4
- package/dist/components/index.js +3 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/tab/DetailTabPage.d.ts +9 -0
- package/dist/components/tab/DetailTabPage.js +15 -0
- package/dist/components/tab/DetailTabPage.js.map +1 -0
- package/dist/components/tab/{DetailTabObjects.d.ts → DetailTabPageObjects.d.ts} +1 -1
- package/dist/components/tab/{DetailTabObjects.js → DetailTabPageObjects.js} +2 -2
- package/dist/components/tab/DetailTabPageObjects.js.map +1 -0
- package/dist/components/tab/Tab.d.ts +8 -3
- package/dist/components/tab/Tab.js +25 -4
- package/dist/components/tab/Tab.js.map +1 -1
- package/dist/components/tab/TabObjects.d.ts +7 -2
- package/dist/components/tab/TabObjects.js +9 -2
- package/dist/components/tab/TabObjects.js.map +1 -1
- package/dist/enums/ElementTypes.d.ts +8 -0
- package/dist/enums/ElementTypes.js +10 -0
- package/dist/enums/ElementTypes.js.map +1 -0
- package/dist/helpers/PathResolver.d.ts +3 -0
- package/dist/helpers/PathResolver.js +26 -0
- package/dist/helpers/PathResolver.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/IProperty.d.ts +4 -0
- package/dist/interfaces/IProperty.js +2 -0
- package/dist/interfaces/IProperty.js.map +1 -0
- package/dist/interfaces/IRegisteredSubjects.d.ts +5 -0
- package/dist/interfaces/IRegisteredSubjects.js +2 -0
- package/dist/interfaces/IRegisteredSubjects.js.map +1 -0
- package/dist/interfaces/ISubject.d.ts +8 -0
- package/dist/interfaces/ISubject.js +2 -0
- package/dist/interfaces/ISubject.js.map +1 -0
- package/dist/page-extensions/SubjectProvider.d.ts +11 -0
- package/dist/page-extensions/SubjectProvider.js +24 -0
- package/dist/page-extensions/SubjectProvider.js.map +1 -0
- package/dist/page-extensions/SubjectRegistry.d.ts +14 -0
- package/dist/page-extensions/SubjectRegistry.js +14 -0
- package/dist/page-extensions/SubjectRegistry.js.map +1 -0
- package/dist/page-extensions/index.d.ts +3 -0
- package/dist/page-extensions/index.js +3 -0
- package/dist/page-extensions/index.js.map +1 -1
- package/dist/services/ConfigBuilder.d.ts +1 -0
- package/dist/services/ConfigBuilder.js +20 -1
- package/dist/services/ConfigBuilder.js.map +1 -1
- package/dist/test-artifacts/SubjectPageBase.d.ts +5 -0
- package/dist/test-artifacts/SubjectPageBase.js +6 -0
- package/dist/test-artifacts/SubjectPageBase.js.map +1 -0
- package/dist/test-artifacts/index.d.ts +3 -0
- package/dist/test-artifacts/index.js +4 -0
- package/dist/test-artifacts/index.js.map +1 -0
- package/dist/test-artifacts/screens/index.d.ts +1 -0
- package/dist/test-artifacts/screens/index.js +2 -0
- package/dist/test-artifacts/screens/index.js.map +1 -0
- package/dist/test-artifacts/subjects/index.d.ts +1 -0
- package/dist/test-artifacts/subjects/index.js +2 -0
- package/dist/test-artifacts/subjects/index.js.map +1 -0
- package/dist/types/Components.d.ts +7 -0
- package/dist/types/Components.js +28 -0
- package/dist/types/Components.js.map +1 -0
- package/enums/ElementTypes.ts +8 -0
- package/helpers/PathResolver.ts +30 -0
- package/helpers/index.ts +1 -0
- package/index.ts +1 -0
- package/interfaces/IProperty.ts +4 -0
- package/interfaces/IRegisteredSubjects.ts +5 -0
- package/interfaces/ISubject.ts +9 -0
- package/package.json +26 -9
- package/page-extensions/SubjectProvider.ts +41 -0
- package/page-extensions/SubjectRegistry.ts +30 -0
- package/page-extensions/index.ts +3 -0
- package/promptCredentials.js +124 -124
- package/scripts/Testwise.template.json +4 -1
- package/scripts/main.js +75 -4
- package/scripts/postinstall.js +42 -0
- package/scripts/setup.js +17 -14
- package/scripts/sync.js +69 -0
- package/scripts/tsconfig.template.json +1 -1
- package/services/ConfigBuilder.ts +25 -2
- package/test-artifacts/SubjectPageBase.ts +9 -0
- package/test-artifacts/index.ts +3 -0
- package/test-artifacts/screens/index.ts +0 -0
- package/test-artifacts/subjects/index.ts +0 -0
- package/tsconfig.json +1 -1
- package/types/Components.ts +55 -0
- package/components/tab/ComponentTab.ts +0 -40
- package/components/tab/ComponentTabObjects.ts +0 -17
- package/components/tab/DetailTab.ts +0 -20
- package/dist/Testwise.json +0 -25
- package/dist/bdd.d.ts +0 -6
- package/dist/bdd.js +0 -9
- package/dist/bdd.js.map +0 -1
- package/dist/biome.json +0 -52
- package/dist/components/actionbar/Actionbar.js.map +0 -1
- package/dist/components/actionbar/ActionbarObjects.js.map +0 -1
- package/dist/components/actionbar/CustomActionBar.js +0 -7
- package/dist/components/actionbar/CustomActionBar.js.map +0 -1
- package/dist/components/tab/ComponentTab.d.ts +0 -12
- package/dist/components/tab/ComponentTab.js +0 -31
- package/dist/components/tab/ComponentTab.js.map +0 -1
- package/dist/components/tab/ComponentTabObjects.d.ts +0 -8
- package/dist/components/tab/ComponentTabObjects.js +0 -11
- package/dist/components/tab/ComponentTabObjects.js.map +0 -1
- package/dist/components/tab/DetailTab.d.ts +0 -9
- package/dist/components/tab/DetailTab.js +0 -15
- package/dist/components/tab/DetailTab.js.map +0 -1
- package/dist/components/tab/DetailTabObjects.js.map +0 -1
- package/dist/helpers/TestExtensions.d.ts +0 -8
- package/dist/helpers/TestExtensions.js +0 -21
- package/dist/helpers/TestExtensions.js.map +0 -1
- package/dist/package-lock.json +0 -3852
- package/dist/package.json +0 -59
- package/dist/scripts/Testwise.template.json +0 -25
- package/dist/scripts/tsconfig.template.json +0 -12
- package/dist/services/ReportingService.d.ts +0 -8
- package/dist/services/ReportingService.js +0 -29
- package/dist/services/ReportingService.js.map +0 -1
- package/dist/tsconfig.json +0 -20
- package/services/ReportingService.ts +0 -37
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { KnownElementTypes } from '../../enums/ElementTypes.js';
|
|
3
|
+
import type { ScreenComponents, SubjectComponents } from '../../types/Components.js';
|
|
4
|
+
|
|
5
|
+
export class NamingHandler {
|
|
6
|
+
public getDefaultElementSuffixFromComponentType(componentType: SubjectComponents): KnownElementTypes {
|
|
7
|
+
const controlTypeMapping: Record<SubjectComponents, KnownElementTypes> = {
|
|
8
|
+
Form: KnownElementTypes.Input,
|
|
9
|
+
Grid: KnownElementTypes.Column
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return controlTypeMapping[componentType];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public getElementSuffixFromControlTypeAndComponentType(
|
|
16
|
+
controlType: string,
|
|
17
|
+
componentType: SubjectComponents
|
|
18
|
+
): string {
|
|
19
|
+
controlType = controlType.toLowerCase();
|
|
20
|
+
|
|
21
|
+
const formDefaultSuffix: KnownElementTypes = this.getDefaultElementSuffixFromComponentType('Form');
|
|
22
|
+
const gridDefaultSuffix: KnownElementTypes = this.getDefaultElementSuffixFromComponentType('Grid');
|
|
23
|
+
|
|
24
|
+
const controlTypeMappingMatrix: Record<SubjectComponents, Record<string, KnownElementTypes>> = {
|
|
25
|
+
Form: {
|
|
26
|
+
email: formDefaultSuffix,
|
|
27
|
+
phone_number: formDefaultSuffix,
|
|
28
|
+
suggestion_starts_with: KnownElementTypes.Lookup,
|
|
29
|
+
checkbox: KnownElementTypes.Checkbox,
|
|
30
|
+
multiline: KnownElementTypes.Textarea,
|
|
31
|
+
combo: KnownElementTypes.Dropdown
|
|
32
|
+
},
|
|
33
|
+
Grid: {
|
|
34
|
+
email: gridDefaultSuffix,
|
|
35
|
+
phone_number: gridDefaultSuffix,
|
|
36
|
+
suggestion_starts_with: gridDefaultSuffix,
|
|
37
|
+
checkbox: gridDefaultSuffix,
|
|
38
|
+
multiline: gridDefaultSuffix,
|
|
39
|
+
combo: gridDefaultSuffix
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const componentMapping = controlTypeMappingMatrix[componentType];
|
|
44
|
+
return (
|
|
45
|
+
componentMapping[controlType] || this.getDefaultElementSuffixFromComponentType(componentType)
|
|
46
|
+
).toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public getIdFromElementName(elementName: string): string {
|
|
50
|
+
return (
|
|
51
|
+
elementName
|
|
52
|
+
// Remove the suffix at the end
|
|
53
|
+
.replace(/([A-Z][a-z0-9]*)$/, '')
|
|
54
|
+
// Convert to kebab-case
|
|
55
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
56
|
+
.toLowerCase()
|
|
57
|
+
// Replace underscores with hyphens
|
|
58
|
+
.replace(/_/g, '-')
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public getComponentTypeFromFileName(fileName: string): SubjectComponents {
|
|
63
|
+
// ToDo: use this
|
|
64
|
+
const match = fileName.match(/([A-Z][a-z]+)(?=\.ts$)/);
|
|
65
|
+
if (match) {
|
|
66
|
+
const componentName = match[1];
|
|
67
|
+
if (componentName === 'Form') return 'Form';
|
|
68
|
+
if (componentName === 'Grid') return 'Grid';
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Unknown component type in file name: ${fileName}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public getElementTypeFromElementName(elementName: string): string {
|
|
74
|
+
// Get the suffix at the end of the element name
|
|
75
|
+
const match = elementName.match(/([A-Z][a-z0-9]*)$/);
|
|
76
|
+
|
|
77
|
+
// verify that match is a known element type
|
|
78
|
+
if (match) {
|
|
79
|
+
const elementType = match[1].toLowerCase();
|
|
80
|
+
if (Object.values(KnownElementTypes).includes(elementType as KnownElementTypes)) {
|
|
81
|
+
return elementType;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
throw new Error(`Could not extract element type from element name: ${elementName}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public getSubjectFromFileName(fileName: string): string {
|
|
89
|
+
return fileName.replace(/([A-Z][a-z0-9]*)$/, '');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public getPascalSubjectComponentName(file: string): string {
|
|
93
|
+
let fileName = path.basename(file, '.json').replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
94
|
+
fileName = fileName.charAt(0).toUpperCase() + fileName.slice(1);
|
|
95
|
+
return fileName;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public formatPascalCaseName(name: string): string {
|
|
99
|
+
if (!name.includes('_')) {
|
|
100
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return name
|
|
104
|
+
.toLowerCase()
|
|
105
|
+
.split('_')
|
|
106
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
107
|
+
.join('');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public formatSubjectName(subjectName: string): string {
|
|
111
|
+
subjectName.replace(/_([a-z])/g, (g: string) => g[1].toUpperCase());
|
|
112
|
+
return subjectName.charAt(0).toUpperCase() + subjectName.slice(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public formatPropertyName(name: string): string {
|
|
116
|
+
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public generateScreenInterfaceName(screentypeId: string): string {
|
|
120
|
+
return `I${screentypeId
|
|
121
|
+
.toLowerCase()
|
|
122
|
+
.split('_')
|
|
123
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
124
|
+
.join('')}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public snakeToPascalCase(value: string): string {
|
|
128
|
+
if (!value.includes('_')) {
|
|
129
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return value
|
|
133
|
+
.toLowerCase()
|
|
134
|
+
.split('_')
|
|
135
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
136
|
+
.join('');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public getComponentIdFromName(componentName: string, componentType: ScreenComponents): string {
|
|
140
|
+
if (componentType === 'ActionBar' || componentType === 'CustomActionBar') {
|
|
141
|
+
const capitalizedComponentName = this.capitalizeFirstLetter(componentName);
|
|
142
|
+
return capitalizedComponentName.replace(/Toolbar/, 'Toolbar_');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (componentType === 'Splitter') {
|
|
146
|
+
const componentId = componentName.toLowerCase();
|
|
147
|
+
|
|
148
|
+
if (/^splitter\d+$/.test(componentId)) {
|
|
149
|
+
return componentId;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return componentId.replace(/splitter/, 'splitter-');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (componentType === 'Tab') {
|
|
156
|
+
return this.capitalizeFirstLetter(componentName);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return componentName;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public capitalizeFirstLetter(value: string): string {
|
|
163
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public getTabParentFromComponentName(componentName: string): string {
|
|
167
|
+
const match = componentName.match(/^[a-z0-9]+(?=[A-Z])/);
|
|
168
|
+
if (match) {
|
|
169
|
+
return match[0];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
throw new Error(`Could not extract tab parent from component name: ${componentName}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public generateSubjectClassName(subject: { subject: string; screentype_context: string; variant: string }): string {
|
|
176
|
+
const uniqueSubjectIdentifier = subject.variant !== '' ? `${subject.subject}_${subject.variant}` : subject.subject;
|
|
177
|
+
const className = `${uniqueSubjectIdentifier}_${subject.screentype_context}`;
|
|
178
|
+
return this.formatPascalCaseName(className);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ArtifactManager.js';
|
|
2
|
+
export * from './helpers/index.js';
|
|
3
|
+
export * from './InterfaceGenerator.js';
|
|
4
|
+
export * from './ModelDataRefiner.js';
|
|
5
|
+
export * from './SchemaGenerator.js';
|
|
6
|
+
export * from './ScreenInterfaceRefiner.js';
|
|
7
|
+
export * from './SubjectComponentGenerator.js';
|
|
8
|
+
export * from './SubjectGenerator.js';
|
|
9
|
+
export * from './SubjectRegistration.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
-
import {
|
|
2
|
+
import { ActionBarObjects, ActionBarOverflowableObjects } from './ActionBarObjects.js';
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
private _objects:
|
|
4
|
+
class ActionBarActions {
|
|
5
|
+
private _objects: ActionBarOverflowableObjects;
|
|
6
6
|
|
|
7
7
|
constructor(page: Page, context: Locator | null = null) {
|
|
8
|
-
this._objects = new
|
|
8
|
+
this._objects = new ActionBarOverflowableObjects(page, context);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public getSearchInput = (): Locator => this._objects.searchInput();
|
|
@@ -86,18 +86,18 @@ class ActionbarActions {
|
|
|
86
86
|
public getCubeViewButtonByLabel = (label: string): Locator => this._objects.cubeViewButtonByLabel(label);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export class
|
|
90
|
-
private
|
|
91
|
-
private _overflowMenu:
|
|
89
|
+
export class ActionBar extends ActionBarActions {
|
|
90
|
+
private _actionBarObjects: ActionBarObjects;
|
|
91
|
+
private _overflowMenu: ActionBarOverflow;
|
|
92
92
|
|
|
93
93
|
constructor(page: Page, actionbarContext: Locator | null = null) {
|
|
94
94
|
super(page, actionbarContext);
|
|
95
|
-
this.
|
|
96
|
-
this._overflowMenu = new
|
|
95
|
+
this._actionBarObjects = new ActionBarObjects(page, actionbarContext);
|
|
96
|
+
this._overflowMenu = new ActionBarOverflow(page);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
public openOverflowMenu = async (): Promise<void> => {
|
|
100
|
-
await this.
|
|
100
|
+
await this._actionBarObjects.overflowMenuButton().click();
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
overflowMenu = {
|
|
@@ -146,13 +146,13 @@ export class Actionbar extends ActionbarActions {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
export class
|
|
149
|
+
export class ActionBarOverflow extends ActionBarActions {
|
|
150
150
|
constructor(page: Page) {
|
|
151
151
|
super(page, page.getByTestId('actionbar__overflow-menu__context'));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function wrapWithOverflowOpen(actionBarInstance:
|
|
155
|
+
function wrapWithOverflowOpen(actionBarInstance: ActionBar, getLocatorFn: () => Locator): Locator {
|
|
156
156
|
const locator = getLocatorFn();
|
|
157
157
|
|
|
158
158
|
return new Proxy(locator, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
2
|
import { BaseComponentObjects } from '../BaseComponentObjects.js';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class ActionBarOverflowableObjects extends BaseComponentObjects {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// ActionBar-near
|
|
10
10
|
public searchInput = () => this.context.getByTestId('actionbar__search__input').locator('input');
|
|
11
11
|
|
|
12
12
|
public prefilterButton = () =>
|
|
@@ -14,7 +14,7 @@ export class ActionbarOverflowableObjects extends BaseComponentObjects {
|
|
|
14
14
|
|
|
15
15
|
public filterButton = () => this.context.getByTestId('actionbar__filter');
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// ActionBar-far (overflowable)
|
|
18
18
|
public addButton = () => this.context.getByTestId('actionbar__add');
|
|
19
19
|
|
|
20
20
|
public copyButton = () => this.context.getByTestId('actionbar__copy');
|
|
@@ -99,7 +99,7 @@ export class ActionbarOverflowableObjects extends BaseComponentObjects {
|
|
|
99
99
|
this.context.getByTestId(new RegExp(`^prefilter-actionbar-group-${id}$`));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export class
|
|
102
|
+
export class ActionBarObjects extends ActionBarOverflowableObjects {
|
|
103
103
|
constructor(page: Page, context: Locator | null = null) {
|
|
104
104
|
super(page, context);
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
-
import {
|
|
2
|
+
import { ActionBar } from './ActionBar.js';
|
|
3
3
|
|
|
4
|
-
export class CustomActionBar extends
|
|
4
|
+
export class CustomActionBar extends ActionBar {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
package/components/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './action-bar/ActionBar.js';
|
|
2
|
+
export * from './action-bar/CustomActionBar.js';
|
|
3
3
|
export * from './cardlist/Cardlist.js';
|
|
4
4
|
export * from './chart/Chart.js';
|
|
5
5
|
export * from './combined-filter/CombinedFilter.js';
|
|
@@ -20,8 +20,7 @@ export * from './report-tiles/ReportTiles.js';
|
|
|
20
20
|
export * from './scheduler/Scheduler.js';
|
|
21
21
|
export * from './snackbar/SnackBar.js';
|
|
22
22
|
export * from './splitter/Splitter.js';
|
|
23
|
-
export * from './tab/
|
|
24
|
-
export * from './tab/DetailTab.js';
|
|
23
|
+
export * from './tab/DetailTabPage.js';
|
|
25
24
|
export * from './tab/Tab.js';
|
|
26
25
|
export * from './task/TaskBar.js';
|
|
27
26
|
export * from './task/TaskTiles.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTab } from './BaseTab.js';
|
|
3
|
+
import { DetailTabPageObjects } from './DetailTabPageObjects.js';
|
|
4
|
+
|
|
5
|
+
export class DetailTabPage extends BaseTab {
|
|
6
|
+
protected _objects: DetailTabPageObjects;
|
|
7
|
+
|
|
8
|
+
constructor(page: Page, context: Locator | null = null) {
|
|
9
|
+
super(page, context);
|
|
10
|
+
this._objects = new DetailTabPageObjects(page, context);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async getDetailTabPageById(name: string): Promise<Locator> {
|
|
14
|
+
return this._objects.detailTab(name);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public async getDetailTabPageByIndex(index: number): Promise<Locator> {
|
|
18
|
+
return this._objects.tabByIndex(index);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
2
|
import { BaseTabObjects } from './BaseTabObjects.js';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class DetailTabPageObjects extends BaseTabObjects {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
package/components/tab/Tab.ts
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTab } from './BaseTab.js';
|
|
2
3
|
import { TabObjects } from './TabObjects.js';
|
|
3
4
|
|
|
4
|
-
export class Tab {
|
|
5
|
-
|
|
5
|
+
export class Tab extends BaseTab {
|
|
6
|
+
protected _objects: TabObjects;
|
|
6
7
|
|
|
7
8
|
constructor(page: Page, context: Locator | null = null) {
|
|
8
|
-
|
|
9
|
+
super(page, context);
|
|
10
|
+
this._objects = new TabObjects(page, context);
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
// --- Component-specific helpers ---
|
|
14
|
+
|
|
15
|
+
// Opens the “List” tab in this tabstrip (default tabindex = -1 for master).
|
|
16
|
+
// If tabindex is left empty, the default is "-1" which is the master/base list tabindex
|
|
17
|
+
public async openListTab(tabindex: string = '-1'): Promise<void> {
|
|
18
|
+
await this._objects.listTab(tabindex).click();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Returns the “List” tab locator (scoped).
|
|
22
|
+
public async getListTab(tabindex: string = '-1'): Promise<Locator> {
|
|
23
|
+
return this._objects.listTab(tabindex);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Opens the “Form” tab in this tabstrip (scoped).
|
|
27
|
+
public async openFormTab(): Promise<void> {
|
|
28
|
+
await this._objects.formTab().click();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Returns the “Form” tab locator (scoped).
|
|
32
|
+
public async getFormTab(): Promise<Locator> {
|
|
33
|
+
return this._objects.formTab();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Opens a component tab by its ID in this tabstrip (scoped).
|
|
37
|
+
public async openTabByID(tabid: string): Promise<void> {
|
|
38
|
+
await this._objects.tab(tabid).click();
|
|
13
39
|
}
|
|
14
40
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTabObjects } from './BaseTabObjects.js';
|
|
2
3
|
|
|
3
|
-
export class TabObjects extends
|
|
4
|
-
|
|
4
|
+
export class TabObjects extends BaseTabObjects {
|
|
5
|
+
constructor(page: Page, context: Locator | null = null) {
|
|
6
|
+
super(page, context);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Component-specific selectors
|
|
10
|
+
public listTab = (tabindex: string): Locator =>
|
|
11
|
+
this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__list"][tabindex="${tabindex}"]`);
|
|
12
|
+
|
|
13
|
+
public formTab = (): Locator => this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__form"]`);
|
|
14
|
+
|
|
15
|
+
public tab = (tabid: string): Locator =>
|
|
16
|
+
this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__${tabid}"]`);
|
|
5
17
|
}
|
package/dist/Testwise.d.ts
CHANGED
package/dist/Testwise.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { test as base } from '@playwright/test';
|
|
2
|
-
import { test as bddBase } from 'playwright-bdd';
|
|
3
2
|
import { Components, GoToDeepLink, LoginFeatures, UserSimulation } from './page-extensions/index.js';
|
|
3
|
+
import { SubjectProvider } from './page-extensions/SubjectProvider.js';
|
|
4
|
+
import { SubjectRegistry } from './page-extensions/SubjectRegistry.js';
|
|
4
5
|
import { WaitEventHandler } from './page-extensions/WaitEventHandler.js';
|
|
5
6
|
import { ClickOverride } from './page-overrides/ClickOverride.js';
|
|
6
7
|
import { FillOverride } from './page-overrides/FillOverride.js';
|
|
7
8
|
function combineExtensions(baseTest, ...extensions) {
|
|
8
9
|
return extensions.reduce((test, Extension) => new Extension(test).test, baseTest);
|
|
9
10
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Components,
|
|
16
|
-
GoToDeepLink,
|
|
17
|
-
LoginFeatures,
|
|
18
|
-
UserSimulation,
|
|
19
|
-
WaitEventHandler
|
|
20
|
-
];
|
|
21
|
-
export const test = combineExtensions(base, ...extensions);
|
|
22
|
-
export const bddTest = combineExtensions(bddBase, ...extensions);
|
|
11
|
+
export const test = combineExtensions(base,
|
|
12
|
+
// Override section
|
|
13
|
+
ClickOverride, FillOverride,
|
|
14
|
+
// Extend section
|
|
15
|
+
Components, GoToDeepLink, LoginFeatures, UserSimulation, WaitEventHandler, SubjectRegistry, SubjectProvider);
|
|
23
16
|
//# sourceMappingURL=Testwise.js.map
|
package/dist/Testwise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Testwise.js","sourceRoot":"","sources":["../Testwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Testwise.js","sourceRoot":"","sources":["../Testwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,SAAS,iBAAiB,CAAC,QAAc,EAAE,GAAG,UAAkD;IAC9F,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAS,iBAAiB,CACzC,IAAI;AAEJ,mBAAmB;AACnB,aAAa,EACb,YAAY;AAEZ,iBAAiB;AACjB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,CAChB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export class ArtifactManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
const _filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const _dirname = path.dirname(_filename);
|
|
8
|
+
this._backupPath = path.resolve(_dirname, '..', '..', '..', 'backups', 'test-artifacts');
|
|
9
|
+
this._artifactPath = path.resolve(_dirname, '..', '..', 'test-artifacts');
|
|
10
|
+
}
|
|
11
|
+
performBackup() {
|
|
12
|
+
if (fs.existsSync(this._artifactPath)) {
|
|
13
|
+
fs.rmSync(this._backupPath, { recursive: true, force: true });
|
|
14
|
+
fs.cpSync(this._artifactPath, this._backupPath, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
backupExists() {
|
|
18
|
+
return fs.existsSync(this._backupPath);
|
|
19
|
+
}
|
|
20
|
+
restoreBackup() {
|
|
21
|
+
if (fs.existsSync(this._backupPath)) {
|
|
22
|
+
fs.rmSync(this._artifactPath, { recursive: true, force: true });
|
|
23
|
+
fs.cpSync(this._backupPath, this._artifactPath, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ArtifactManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactManager.js","sourceRoot":"","sources":["../../artifact-builder/ArtifactManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,eAAe;IAI1B;QACE,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC5E,CAAC;IAED,aAAa;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YACtC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,YAAY;QACV,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,aAAa;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAChE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class InterfaceGenerator {
|
|
2
|
+
private readonly _namingHandler;
|
|
3
|
+
private _filename;
|
|
4
|
+
private _dirname;
|
|
5
|
+
constructor();
|
|
6
|
+
generateScreenInterfacesFromSchemas(): Promise<void>;
|
|
7
|
+
generateSubjectInterfacesFromSchemas(): Promise<void>;
|
|
8
|
+
private verifyGeneratedSubjectSchemasDirectory;
|
|
9
|
+
private verifyOutputDirectory;
|
|
10
|
+
private getGeneratedSubjectSchemas;
|
|
11
|
+
private verifySubjectComponentsDirectory;
|
|
12
|
+
private createInterfaceFromSchema;
|
|
13
|
+
private generateInterfacesFromSchemaFiles;
|
|
14
|
+
private runPrettierOnSpecifiedDirectory;
|
|
15
|
+
getScreenSchemaFilesPath(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { PathResolver } from '../helpers/PathResolver.js';
|
|
6
|
+
import { NamingHandler } from '../index.js';
|
|
7
|
+
export class InterfaceGenerator {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._namingHandler = new NamingHandler();
|
|
10
|
+
this._filename = fileURLToPath(import.meta.url);
|
|
11
|
+
this._dirname = path.dirname(this._filename);
|
|
12
|
+
}
|
|
13
|
+
async generateScreenInterfacesFromSchemas() {
|
|
14
|
+
const screenOutputDirectory = path.resolve(this._dirname, '..', '..', 'test-artifacts/screens/');
|
|
15
|
+
this.verifyOutputDirectory(screenOutputDirectory);
|
|
16
|
+
const schemasDirectory = this.getScreenSchemaFilesPath();
|
|
17
|
+
await this.generateInterfacesFromSchemaFiles(schemasDirectory, SchemaType.Screen, screenOutputDirectory);
|
|
18
|
+
await this.runPrettierOnSpecifiedDirectory(screenOutputDirectory);
|
|
19
|
+
console.info('All screen schemas processed.');
|
|
20
|
+
}
|
|
21
|
+
async generateSubjectInterfacesFromSchemas() {
|
|
22
|
+
const schemasDirectory = path.resolve(this._dirname, '../test-artifacts/schemas');
|
|
23
|
+
const subjectOutputDirectory = path.resolve(this._dirname, '..', '..', 'test-artifacts/subjects');
|
|
24
|
+
this.verifyGeneratedSubjectSchemasDirectory(schemasDirectory);
|
|
25
|
+
this.verifyOutputDirectory(subjectOutputDirectory);
|
|
26
|
+
await this.generateInterfacesFromSchemaFiles(schemasDirectory, SchemaType.Subject, subjectOutputDirectory);
|
|
27
|
+
await this.runPrettierOnSpecifiedDirectory(subjectOutputDirectory);
|
|
28
|
+
console.info('All subject schemas processed.');
|
|
29
|
+
}
|
|
30
|
+
verifyGeneratedSubjectSchemasDirectory(directory) {
|
|
31
|
+
if (!fs.existsSync(directory)) {
|
|
32
|
+
console.error(`Schemas directory not found: ${directory}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
verifyOutputDirectory(directory) {
|
|
37
|
+
if (!fs.existsSync(directory)) {
|
|
38
|
+
console.info(`Creating output directory: ${directory}`);
|
|
39
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getGeneratedSubjectSchemas(schemasDirectory) {
|
|
43
|
+
return fs.readdirSync(schemasDirectory).filter((f) => f.endsWith('.json'));
|
|
44
|
+
}
|
|
45
|
+
verifySubjectComponentsDirectory(directory, subject) {
|
|
46
|
+
const componentsDirectory = path.join(directory, `${subject}/Components`);
|
|
47
|
+
if (!fs.existsSync(componentsDirectory)) {
|
|
48
|
+
fs.mkdirSync(componentsDirectory, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
return componentsDirectory;
|
|
51
|
+
}
|
|
52
|
+
createInterfaceFromSchema(schemasDirectory, outputPath, file, isInterface = false) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
exec(`quicktype --just-types --lang typescript --src-lang schema --nice-property-names -o "${outputPath}" "${file}"`, { cwd: schemasDirectory }, (error) => {
|
|
55
|
+
if (error) {
|
|
56
|
+
console.error(`Error processing ${file}:`, error.message);
|
|
57
|
+
reject(error);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// This is an ugly patch to fix interface names after quicktype generation due to quicktype applying naming logic to acronyms that we can't switch off
|
|
61
|
+
try {
|
|
62
|
+
const fileName = path.basename(outputPath, '.ts');
|
|
63
|
+
const fileContent = fs.readFileSync(outputPath, 'utf-8');
|
|
64
|
+
const interfaceNameMatch = fileContent.match(new RegExp(`interface ${fileName}`, 'i'));
|
|
65
|
+
if (interfaceNameMatch) {
|
|
66
|
+
const correctInterfaceName = isInterface
|
|
67
|
+
? this._namingHandler.generateScreenInterfaceName(file.slice(0, file.lastIndexOf('.')))
|
|
68
|
+
: this._namingHandler.snakeToPascalCase(file.slice(0, file.lastIndexOf('.')));
|
|
69
|
+
const updatedContent = fileContent.replace(new RegExp(`interface ${interfaceNameMatch[0].split(' ')[1]}`), `interface ${correctInterfaceName}`);
|
|
70
|
+
fs.writeFileSync(outputPath, updatedContent, 'utf-8');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (fsError) {
|
|
74
|
+
console.error(`Error post-processing ${outputPath}:`, fsError instanceof Error ? fsError.message : String(fsError));
|
|
75
|
+
reject(fsError);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.info(`Generated: ${outputPath}`);
|
|
79
|
+
resolve(true);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async generateInterfacesFromSchemaFiles(schemasDirectory, schemaType, outputPath) {
|
|
84
|
+
const schemaFiles = this.getGeneratedSubjectSchemas(schemasDirectory);
|
|
85
|
+
const quicktypePromises = schemaFiles.map((file) => {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const fileName = this._namingHandler.getPascalSubjectComponentName(file);
|
|
88
|
+
if (schemaType === SchemaType.Subject) {
|
|
89
|
+
const subject = this._namingHandler.getSubjectFromFileName(fileName);
|
|
90
|
+
const componentsDirectory = this.verifySubjectComponentsDirectory(outputPath, subject);
|
|
91
|
+
const perFileOutputPath = path.join(componentsDirectory, `${fileName}.ts`);
|
|
92
|
+
this.createInterfaceFromSchema(schemasDirectory, perFileOutputPath, file).then(resolve).catch(reject);
|
|
93
|
+
}
|
|
94
|
+
else if (schemaType === SchemaType.Screen) {
|
|
95
|
+
const perFileOutputPath = path.join(outputPath, `I${fileName}.ts`);
|
|
96
|
+
this.createInterfaceFromSchema(schemasDirectory, perFileOutputPath, file, true).then(resolve).catch(reject);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
reject(new Error(`Unsupported schema type: ${schemaType}`));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
await Promise.all(quicktypePromises);
|
|
104
|
+
}
|
|
105
|
+
async runPrettierOnSpecifiedDirectory(directory) {
|
|
106
|
+
const packageDir = path.resolve(this._dirname, '..');
|
|
107
|
+
const relativeDir = path.relative(packageDir, directory);
|
|
108
|
+
await new Promise((resolve, reject) => {
|
|
109
|
+
exec(`npx prettier --write "${relativeDir}"`, { cwd: packageDir }, (prettierError) => {
|
|
110
|
+
if (prettierError) {
|
|
111
|
+
console.error(`Prettier failed for ${directory}:`, prettierError.message);
|
|
112
|
+
reject(prettierError);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
console.info(`Formatted all files in: ${directory}`);
|
|
116
|
+
resolve(true);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
getScreenSchemaFilesPath() {
|
|
121
|
+
const directory = new PathResolver().getConsumerRootDirectory();
|
|
122
|
+
const screenSchemasPath = path.join(directory, 'seed-data/screen-schemas/');
|
|
123
|
+
if (!fs.existsSync(screenSchemasPath)) {
|
|
124
|
+
throw new Error(`Screen schemas directory not found at: ${screenSchemasPath}`);
|
|
125
|
+
}
|
|
126
|
+
return screenSchemasPath;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var SchemaType;
|
|
130
|
+
(function (SchemaType) {
|
|
131
|
+
SchemaType["Subject"] = "Subject";
|
|
132
|
+
SchemaType["Screen"] = "Screen";
|
|
133
|
+
})(SchemaType || (SchemaType = {}));
|
|
134
|
+
//# sourceMappingURL=InterfaceGenerator.js.map
|