@thinkwise/testwise 0.2.0-beta.22 → 0.2.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.
Files changed (115) hide show
  1. package/Testwise.ts +1 -3
  2. package/artifact-builder/InterfaceGenerator.ts +9 -1
  3. package/artifact-builder/ModelDataBuilder.ts +31 -60
  4. package/artifact-builder/ModelDataRefiner.ts +9 -5
  5. package/artifact-builder/SelectorBuilder.ts +8 -1
  6. package/artifact-builder/SubjectComponentGenerator.ts +77 -7
  7. package/artifact-builder/SubjectGenerator.ts +1 -1
  8. package/artifact-builder/SubjectRegistration.ts +68 -55
  9. package/artifact-builder/helpers/DataRetriever.ts +5 -2
  10. package/artifact-builder/helpers/NamingHandler.ts +25 -19
  11. package/components/BaseComponentObjects.ts +4 -1
  12. package/components/action-bar/ActionBar.ts +3 -3
  13. package/components/grid/Grid.ts +18 -21
  14. package/components/tab/BaseTab.ts +2 -2
  15. package/components/tab/BaseTabObjects.ts +1 -1
  16. package/components/tab/DetailTabPage.ts +2 -2
  17. package/components/tab/Tab.ts +4 -4
  18. package/controls/LookupDropdown.ts +7 -2
  19. package/dist/Testwise.js +1 -3
  20. package/dist/Testwise.js.map +1 -1
  21. package/dist/artifact-builder/InterfaceGenerator.d.ts +1 -0
  22. package/dist/artifact-builder/InterfaceGenerator.js +6 -1
  23. package/dist/artifact-builder/InterfaceGenerator.js.map +1 -1
  24. package/dist/artifact-builder/ModelDataBuilder.js +26 -50
  25. package/dist/artifact-builder/ModelDataBuilder.js.map +1 -1
  26. package/dist/artifact-builder/ModelDataRefiner.js +9 -5
  27. package/dist/artifact-builder/ModelDataRefiner.js.map +1 -1
  28. package/dist/artifact-builder/SelectorBuilder.js +3 -1
  29. package/dist/artifact-builder/SelectorBuilder.js.map +1 -1
  30. package/dist/artifact-builder/SubjectComponentGenerator.d.ts +4 -0
  31. package/dist/artifact-builder/SubjectComponentGenerator.js +61 -5
  32. package/dist/artifact-builder/SubjectComponentGenerator.js.map +1 -1
  33. package/dist/artifact-builder/SubjectGenerator.js +1 -1
  34. package/dist/artifact-builder/SubjectGenerator.js.map +1 -1
  35. package/dist/artifact-builder/SubjectRegistration.d.ts +9 -9
  36. package/dist/artifact-builder/SubjectRegistration.js +51 -42
  37. package/dist/artifact-builder/SubjectRegistration.js.map +1 -1
  38. package/dist/artifact-builder/helpers/DataRetriever.js +3 -2
  39. package/dist/artifact-builder/helpers/DataRetriever.js.map +1 -1
  40. package/dist/artifact-builder/helpers/NamingHandler.d.ts +2 -1
  41. package/dist/artifact-builder/helpers/NamingHandler.js +20 -15
  42. package/dist/artifact-builder/helpers/NamingHandler.js.map +1 -1
  43. package/dist/components/BaseComponentObjects.d.ts +1 -0
  44. package/dist/components/BaseComponentObjects.js +3 -1
  45. package/dist/components/BaseComponentObjects.js.map +1 -1
  46. package/dist/components/action-bar/ActionBar.d.ts +1 -1
  47. package/dist/components/action-bar/ActionBar.js +3 -3
  48. package/dist/components/grid/Grid.d.ts +5 -4
  49. package/dist/components/grid/Grid.js +13 -19
  50. package/dist/components/grid/Grid.js.map +1 -1
  51. package/dist/components/tab/BaseTab.d.ts +2 -2
  52. package/dist/components/tab/BaseTab.js +2 -2
  53. package/dist/components/tab/BaseTab.js.map +1 -1
  54. package/dist/components/tab/BaseTabObjects.js +1 -1
  55. package/dist/components/tab/BaseTabObjects.js.map +1 -1
  56. package/dist/components/tab/DetailTabPage.d.ts +2 -2
  57. package/dist/components/tab/DetailTabPage.js +2 -2
  58. package/dist/components/tab/DetailTabPage.js.map +1 -1
  59. package/dist/components/tab/Tab.d.ts +3 -3
  60. package/dist/components/tab/Tab.js +4 -4
  61. package/dist/components/tab/Tab.js.map +1 -1
  62. package/dist/controls/LookupDropdown.d.ts +3 -7
  63. package/dist/controls/LookupDropdown.js.map +1 -1
  64. package/dist/enums/ElementTypes.d.ts +1 -1
  65. package/dist/enums/ElementTypes.js +1 -1
  66. package/dist/enums/ElementTypes.js.map +1 -1
  67. package/dist/helpers/ConfigChecker.d.ts +3 -0
  68. package/dist/helpers/ConfigChecker.js +7 -0
  69. package/dist/helpers/ConfigChecker.js.map +1 -0
  70. package/dist/helpers/LoginHelper.js +1 -1
  71. package/dist/helpers/LoginHelper.js.map +1 -1
  72. package/dist/interfaces/IComponentObjects.d.ts +1 -0
  73. package/dist/page-extensions/SubjectRegistry.d.ts +0 -8
  74. package/dist/page-extensions/SubjectRegistry.js +2 -6
  75. package/dist/page-extensions/SubjectRegistry.js.map +1 -1
  76. package/dist/page-extensions/index.d.ts +0 -1
  77. package/dist/page-extensions/index.js +0 -1
  78. package/dist/page-extensions/index.js.map +1 -1
  79. package/dist/services/IndiciumApi.service.d.ts +27 -0
  80. package/dist/services/IndiciumApi.service.js +135 -0
  81. package/dist/services/IndiciumApi.service.js.map +1 -0
  82. package/dist/templates/test-artifacts/SubjectPageBase.d.ts +5 -0
  83. package/dist/templates/test-artifacts/SubjectPageBase.js +6 -0
  84. package/dist/templates/test-artifacts/SubjectPageBase.js.map +1 -0
  85. package/dist/templates/test-artifacts/screens/index.d.ts +1 -0
  86. package/dist/templates/test-artifacts/screens/index.js +2 -0
  87. package/dist/templates/test-artifacts/screens/index.js.map +1 -0
  88. package/dist/templates/test-artifacts/subjects/index.d.ts +1 -0
  89. package/dist/templates/test-artifacts/subjects/index.js +2 -0
  90. package/dist/templates/test-artifacts/subjects/index.js.map +1 -0
  91. package/enums/ElementTypes.ts +1 -1
  92. package/helpers/ConfigChecker.ts +7 -0
  93. package/helpers/LoginHelper.ts +1 -1
  94. package/interfaces/IComponentObjects.ts +1 -0
  95. package/package.json +3 -2
  96. package/page-extensions/SubjectRegistry.ts +2 -19
  97. package/page-extensions/index.ts +0 -1
  98. package/scripts/main.js +48 -69
  99. package/scripts/postinstall.js +40 -39
  100. package/scripts/sync.js +756 -102
  101. package/services/IndiciumApi.service.ts +159 -0
  102. package/templates/SubjectRegistry.template.ts +73 -0
  103. package/templates/test-artifacts/SubjectPageBase.ts +9 -0
  104. package/templates/test-artifacts/screens/index.ts +0 -0
  105. package/templates/test-artifacts/subjects/index.ts +0 -0
  106. package/tsconfig.json +2 -3
  107. package/dist/config.json +0 -10
  108. package/dist/page-extensions/SubjectProvider.d.ts +0 -11
  109. package/dist/page-extensions/SubjectProvider.js +0 -24
  110. package/dist/page-extensions/SubjectProvider.js.map +0 -1
  111. package/dist/test-artifacts/index.d.ts +0 -3
  112. package/dist/test-artifacts/index.js +0 -4
  113. package/dist/test-artifacts/index.js.map +0 -1
  114. package/page-extensions/SubjectProvider.ts +0 -41
  115. package/test-artifacts/index.ts +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../templates/test-artifacts/screens/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../templates/test-artifacts/subjects/index.ts"],"names":[],"mappings":""}
@@ -4,5 +4,5 @@ export enum KnownElementTypes {
4
4
  Textarea = 'textarea',
5
5
  Checkbox = 'checkbox',
6
6
  Lookup = 'lookup',
7
- Column = 'column'
7
+ Column = 'column_cells'
8
8
  }
@@ -0,0 +1,7 @@
1
+ import { indiciumApi } from '../services/IndiciumApi.service.js';
2
+
3
+ export class ConfigChecker {
4
+ public async hasValidModelBuilderConfig(): Promise<boolean> {
5
+ return await indiciumApi.canConnectToProject();
6
+ }
7
+ }
@@ -7,7 +7,7 @@ import type { UniversalConfigOptions, UniversalLoginOptions } from '../types/ind
7
7
  import { pollUntil } from './Poll.js';
8
8
 
9
9
  const _dirname = path.dirname(fileURLToPath(import.meta.url));
10
- const configFixture = JSON.parse(fs.readFileSync(path.resolve(_dirname, '../config.json'), 'utf-8'));
10
+ const configFixture = JSON.parse(fs.readFileSync(path.resolve(_dirname, '../../config.json'), 'utf-8'));
11
11
 
12
12
  export class LoginHelper {
13
13
  private _page: Page;
@@ -2,4 +2,5 @@ import type { Locator } from '@playwright/test';
2
2
 
3
3
  export interface IComponentObjects {
4
4
  context: Locator;
5
+ mainHeader: Locator;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkwise/testwise",
3
- "version": "0.2.0-beta.22",
3
+ "version": "0.2.4",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -72,6 +72,7 @@
72
72
  "interfaces/",
73
73
  "test-artifacts/",
74
74
  "artifact-builder/",
75
- "**/config.json"
75
+ "**/config.json",
76
+ "templates/"
76
77
  ]
77
78
  }
@@ -1,27 +1,10 @@
1
- // import type { Page } from '@playwright/test';
2
1
  import type { Test } from '../types/Test.js';
3
-
4
- export type SubjectType = {
5
- none: unknown;
6
- };
7
-
8
- declare module '@playwright/test' {
9
- interface Page {
10
- subject: SubjectType;
11
- }
12
- }
13
-
14
2
  export class SubjectRegistry {
15
3
  private _test: Test;
16
4
 
17
5
  constructor(test: Test) {
18
- this._test = test.extend({
19
- page: async ({ page }, use) => {
20
- page.subject = {} as SubjectType;
21
-
22
- await use(page);
23
- }
24
- });
6
+ // Implementation of this class is in the templates folder, don't edit here
7
+ this._test = test;
25
8
  }
26
9
 
27
10
  get test() {
@@ -1,7 +1,6 @@
1
1
  export * from './GlobalComponents.js';
2
2
  export * from './GoToDeepLink.js';
3
3
  export * from './LoginFeatures.js';
4
- export * from './SubjectProvider.js';
5
4
  export * from './SubjectRegistry.js';
6
5
  export * from './UserSimulation.js';
7
6
  export * from './WaitEventHandler.js';
package/scripts/main.js CHANGED
@@ -1,84 +1,63 @@
1
1
  #!/usr/bin/env node
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
2
  import process from 'node:process';
5
- import { PathResolver } from '../dist/helpers/index.js';
6
3
  import { postinstall } from './postinstall.js';
7
4
  import { setup } from './setup.js';
8
5
  import { sync } from './sync.js';
9
6
 
10
- await setup();
11
- const { testwiseConfig } = await import('../dist/services/index.js');
12
- const config = testwiseConfig();
13
- const configBuilder = await config.load();
14
-
15
- if (process.argv[2] === 'postinstall') {
16
- if (!(await verifiedSeedData())) process.exit(0);
17
-
18
- postinstall();
19
- } else if (process.argv[2] === 'sync') {
20
- if (!(await verifiedSeedData())) process.exit(0);
21
-
22
- sync();
23
- } else {
24
- console.warn('Command unknown.');
25
- }
26
-
27
- async function verifiedSeedData() {
28
- const consumerRoot = new PathResolver().getConsumerRootDirectory();
29
- const seedDataDir = path.join(consumerRoot, 'seed-data');
30
- const subjectsJson = path.join(seedDataDir, 'subjects.json');
31
- const screensDir = path.join(seedDataDir, 'screen-schemas');
32
- const projectIsConfigured = await isConfigured();
33
-
34
- if (!fs.existsSync(seedDataDir)) {
35
- if (projectIsConfigured) {
36
- fs.mkdirSync(seedDataDir);
37
- fs.mkdirSync(screensDir);
38
-
39
- console.log('Created seed-data directory structure.');
40
- return true;
7
+ /**
8
+ * Main entry point for Testwise CLI commands
9
+ * @param {string[]} args - Command line arguments
10
+ */
11
+ async function main() {
12
+ try {
13
+ const command = process.argv[2];
14
+
15
+ if (!command) {
16
+ console.error('Error: No command provided.');
17
+ console.log('Usage: main.js <command>');
18
+ console.log('Available commands: postinstall, sync');
19
+ process.exit(1);
41
20
  }
42
21
 
43
- console.info('No seed-data directory found.');
44
- return false;
45
- }
46
-
47
- if (!fs.existsSync(subjectsJson) && !projectIsConfigured) {
48
- console.info('No subjects.json');
49
- return false;
50
- }
51
-
52
- if (!fs.existsSync(screensDir)) {
53
- if (projectIsConfigured) {
54
- fs.mkdirSync(screensDir);
55
- console.log('Created screen-schemas directory.');
56
- return true;
22
+ if (command === 'postinstall') {
23
+ await handlePostinstall();
24
+ } else if (command === 'sync') {
25
+ await handleSync();
26
+ } else {
27
+ console.error(`Error: Unknown command '${command}'.`);
28
+ console.log('Available commands: postinstall, sync');
29
+ process.exit(1);
57
30
  }
58
-
59
- console.info('No screen-schemas directory found.');
60
- return false;
31
+ } catch (error) {
32
+ console.error('Fatal error:', error.message);
33
+ process.exit(1);
61
34
  }
35
+ }
62
36
 
63
- const screenFiles = fs.readdirSync(screensDir).filter((f) => f.endsWith('.json'));
64
- if (screenFiles.length === 0 && !projectIsConfigured) {
65
- console.info('No screen JSON files found in seed-data/screen-schemas');
66
- return false;
37
+ /**
38
+ * Handle postinstall command
39
+ */
40
+ async function handlePostinstall() {
41
+ try {
42
+ await setup();
43
+ postinstall();
44
+ } catch (error) {
45
+ console.error('Postinstall failed:', error.message);
46
+ process.exit(1);
67
47
  }
68
- return true;
69
48
  }
70
49
 
71
- async function isConfigured() {
72
- const user = configBuilder.get('environmentSettings.authUser');
73
- const password = configBuilder.get('environmentSettings.authUserPassword');
74
- const guiApplAlias = configBuilder.get('environmentSettings.guiApplAlias');
75
-
76
- return Boolean(
77
- user &&
78
- user !== 'ExampleUser' &&
79
- password &&
80
- password !== 'ExamplePassword@1' &&
81
- guiApplAlias &&
82
- guiApplAlias !== 'ExampleName'
83
- );
50
+ /**
51
+ * Handle sync command
52
+ */
53
+ async function handleSync() {
54
+ try {
55
+ sync();
56
+ } catch (error) {
57
+ console.error('Sync failed:', error.message);
58
+ process.exit(1);
59
+ }
84
60
  }
61
+
62
+ // Start the application
63
+ main();
@@ -1,39 +1,40 @@
1
- import { execSync } from 'node:child_process';
2
- import path from 'node:path';
3
- import process from 'node:process';
4
- import { fileURLToPath } from 'node:url';
5
- import { ArtifactManager } from '../dist/artifact-builder/index.js';
6
- import { testwiseConfig } from '../dist/services/ConfigBuilder.js';
7
- import { sync } from './sync.js';
8
-
9
- const _filename = fileURLToPath(import.meta.url);
10
- const _dirname = path.dirname(_filename);
11
-
12
- export async function postinstall() {
13
- try {
14
- const autoSync = testwiseConfig().get('featureSettings.other.autoSync') ?? true;
15
- if (!autoSync) return;
16
-
17
- const rootDir = path.resolve(_dirname, '..');
18
- const artifactManager = new ArtifactManager();
19
-
20
- if (artifactManager.backupExists()) {
21
- artifactManager.restoreBackup();
22
- console.info('Restored artifacts from backup.');
23
-
24
- // const { SubjectRegistration } = await import('../dist/artifact-builder/index.js');
25
- // new SubjectRegistration().run();
26
-
27
- execSync('npx tsc', { cwd: rootDir, stdio: 'inherit' });
28
-
29
- console.info('Postinstall restore process completed successfully.');
30
-
31
- return;
32
- }
33
-
34
- await sync();
35
- } catch (error) {
36
- console.error('Postinstall process failed:', error.message);
37
- process.exit(1);
38
- }
39
- }
1
+ import { execSync } from 'node:child_process';
2
+ import path from 'node:path';
3
+ import process from 'node:process';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { ArtifactManager } from '../dist/artifact-builder/index.js';
6
+ import { testwiseConfig } from '../dist/services/ConfigBuilder.js';
7
+ import { sync } from './sync.js';
8
+
9
+ const _filename = fileURLToPath(import.meta.url);
10
+ const _dirname = path.dirname(_filename);
11
+
12
+ export async function postinstall() {
13
+ try {
14
+ const autoSync = testwiseConfig().get('featureSettings.other.autoSync') ?? true;
15
+ if (!autoSync) return;
16
+
17
+ const rootDir = path.resolve(_dirname, '..');
18
+ const artifactManager = new ArtifactManager();
19
+
20
+ if (artifactManager.backupExists()) {
21
+ artifactManager.restoreBackup();
22
+ console.info('Restored artifacts from backup.');
23
+
24
+ // eslint-disable-next-line @typescript-eslint/naming-convention
25
+ const { SubjectRegistration } = await import('../dist/artifact-builder/index.js');
26
+ new SubjectRegistration().run();
27
+
28
+ execSync('npx tsc', { cwd: rootDir, stdio: 'inherit' });
29
+
30
+ console.info('Postinstall restore process completed successfully.');
31
+
32
+ return;
33
+ }
34
+
35
+ await sync();
36
+ } catch (error) {
37
+ console.error('Postinstall process failed:', error.message);
38
+ process.exit(1);
39
+ }
40
+ }