@o3r/testing 10.0.0-next.9 → 11.0.0-next.0

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 (129) hide show
  1. package/README.md +1 -1
  2. package/core/angular/component-fixture.d.ts +0 -15
  3. package/core/angular/component-fixture.d.ts.map +1 -1
  4. package/core/angular/component-fixture.js +11 -20
  5. package/core/angular/component-fixture.js.map +1 -1
  6. package/core/angular/element.d.ts +0 -1
  7. package/core/angular/element.d.ts.map +1 -1
  8. package/core/angular/element.js +0 -1
  9. package/core/angular/element.js.map +1 -1
  10. package/core/angular-materials/autocomplete-material.d.ts +0 -1
  11. package/core/angular-materials/autocomplete-material.d.ts.map +1 -1
  12. package/core/angular-materials/autocomplete-material.js +0 -1
  13. package/core/angular-materials/autocomplete-material.js.map +1 -1
  14. package/core/angular-materials/select-material.d.ts +0 -7
  15. package/core/angular-materials/select-material.d.ts.map +1 -1
  16. package/core/angular-materials/select-material.js +0 -9
  17. package/core/angular-materials/select-material.js.map +1 -1
  18. package/core/component-fixture.d.ts +20 -12
  19. package/core/component-fixture.d.ts.map +1 -1
  20. package/core/component-fixture.js +18 -5
  21. package/core/component-fixture.js.map +1 -1
  22. package/core/elements/checkbox-element.d.ts +0 -1
  23. package/core/elements/checkbox-element.d.ts.map +1 -1
  24. package/core/elements/checkbox-element.js.map +1 -1
  25. package/core/elements/radio-element.d.ts +0 -1
  26. package/core/elements/radio-element.d.ts.map +1 -1
  27. package/core/elements/radio-element.js.map +1 -1
  28. package/core/elements/select-element.d.ts +0 -2
  29. package/core/elements/select-element.d.ts.map +1 -1
  30. package/core/elements/select-element.js +0 -2
  31. package/core/elements/select-element.js.map +1 -1
  32. package/core/helpers.d.ts +0 -2
  33. package/core/helpers.d.ts.map +1 -1
  34. package/core/helpers.js +0 -2
  35. package/core/helpers.js.map +1 -1
  36. package/core/page-fixture.d.ts +0 -1
  37. package/core/page-fixture.d.ts.map +1 -1
  38. package/core/page-fixture.js +0 -1
  39. package/core/page-fixture.js.map +1 -1
  40. package/core/playwright/component-fixture.d.ts +0 -15
  41. package/core/playwright/component-fixture.d.ts.map +1 -1
  42. package/core/playwright/component-fixture.js +14 -24
  43. package/core/playwright/component-fixture.js.map +1 -1
  44. package/core/playwright/element.d.ts +0 -2
  45. package/core/playwright/element.d.ts.map +1 -1
  46. package/core/playwright/element.js +0 -1
  47. package/core/playwright/element.js.map +1 -1
  48. package/core/protractor/component-fixture.d.ts +0 -15
  49. package/core/protractor/component-fixture.d.ts.map +1 -1
  50. package/core/protractor/component-fixture.js +11 -21
  51. package/core/protractor/component-fixture.js.map +1 -1
  52. package/core/protractor/utils.d.ts +0 -1
  53. package/core/protractor/utils.d.ts.map +1 -1
  54. package/core/protractor/utils.js +0 -1
  55. package/core/protractor/utils.js.map +1 -1
  56. package/kassette/update-dates-in-mocks.d.ts +0 -3
  57. package/kassette/update-dates-in-mocks.d.ts.map +1 -1
  58. package/kassette/update-dates-in-mocks.js +10 -6
  59. package/kassette/update-dates-in-mocks.js.map +1 -1
  60. package/localization/localization-mock.d.ts +0 -1
  61. package/localization/localization-mock.d.ts.map +1 -1
  62. package/localization/localization-mock.js +4 -3
  63. package/localization/localization-mock.js.map +1 -1
  64. package/mocks/mock-component-generator.d.ts +5 -4
  65. package/mocks/mock-component-generator.d.ts.map +1 -1
  66. package/mocks/mock-component-generator.js +5 -9
  67. package/mocks/mock-component-generator.js.map +1 -1
  68. package/package.json +65 -54
  69. package/schematics/add-functions-to-fixture/index.js +1 -1
  70. package/schematics/add-functions-to-fixture/index.js.map +1 -1
  71. package/schematics/add-functions-to-fixture/schema.json +1 -1
  72. package/schematics/fixture-to-component/index.d.ts.map +1 -1
  73. package/schematics/fixture-to-component/index.js +1 -1
  74. package/schematics/fixture-to-component/index.js.map +1 -1
  75. package/schematics/fixture-to-component/schema.json +1 -1
  76. package/schematics/ng-add/fixture/index.d.ts +2 -1
  77. package/schematics/ng-add/fixture/index.d.ts.map +1 -1
  78. package/schematics/ng-add/fixture/index.js +43 -16
  79. package/schematics/ng-add/fixture/index.js.map +1 -1
  80. package/schematics/ng-add/index.d.ts +0 -1
  81. package/schematics/ng-add/index.d.ts.map +1 -1
  82. package/schematics/ng-add/index.js +17 -18
  83. package/schematics/ng-add/index.js.map +1 -1
  84. package/schematics/ng-add/playwright/index.d.ts +0 -1
  85. package/schematics/ng-add/playwright/index.d.ts.map +1 -1
  86. package/schematics/ng-add/playwright/index.js +1 -2
  87. package/schematics/ng-add/playwright/index.js.map +1 -1
  88. package/schematics/ng-add/schema.json +2 -2
  89. package/schematics/ng-add/templates/project/jest.config.js.template +1 -1
  90. package/schematics/ng-add/templates/workspace/jest.config.js.template +1 -1
  91. package/schematics/ng-add/templates/workspace/jest.config.ut.js.template +53 -41
  92. package/schematics/playwright/sanity/index.d.ts +0 -1
  93. package/schematics/playwright/sanity/index.d.ts.map +1 -1
  94. package/schematics/playwright/sanity/index.js +2 -4
  95. package/schematics/playwright/sanity/index.js.map +1 -1
  96. package/schematics/playwright/sanity/schema.json +1 -1
  97. package/schematics/playwright/scenario/index.d.ts +0 -1
  98. package/schematics/playwright/scenario/index.d.ts.map +1 -1
  99. package/schematics/playwright/scenario/index.js +2 -4
  100. package/schematics/playwright/scenario/index.js.map +1 -1
  101. package/schematics/playwright/scenario/schema.json +1 -1
  102. package/store/testable-select.d.ts +0 -3
  103. package/store/testable-select.d.ts.map +1 -1
  104. package/store/testable-select.js +0 -6
  105. package/store/testable-select.js.map +1 -1
  106. package/store/typings.d.ts +0 -1
  107. package/store/typings.d.ts.map +1 -1
  108. package/store/typings.js +0 -1
  109. package/store/typings.js.map +1 -1
  110. package/tools/path-replacement/path-replacement.d.ts +0 -1
  111. package/tools/path-replacement/path-replacement.d.ts.map +1 -1
  112. package/tools/path-replacement/path-replacement.js +0 -1
  113. package/tools/path-replacement/path-replacement.js.map +1 -1
  114. package/tools/protractor/fetch-manager/_fetch-manager.js +0 -1
  115. package/tools/protractor/fetch-manager/_fetch-manager.js.map +1 -1
  116. package/tools/protractor/post-message-interceptor/_post-message-interceptor.js +0 -4
  117. package/tools/protractor/post-message-interceptor/_post-message-interceptor.js.map +1 -1
  118. package/tools/protractor/post-message-interceptor/post-message-interceptor.d.ts +0 -4
  119. package/tools/protractor/post-message-interceptor/post-message-interceptor.d.ts.map +1 -1
  120. package/tools/protractor/post-message-interceptor/post-message-interceptor.js +0 -4
  121. package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
  122. package/visual-test/utils.d.ts +0 -2
  123. package/visual-test/utils.d.ts.map +1 -1
  124. package/visual-test/utils.js +0 -2
  125. package/visual-test/utils.js.map +1 -1
  126. package/visual-test/visual-test.d.ts +1 -5
  127. package/visual-test/visual-test.d.ts.map +1 -1
  128. package/visual-test/visual-test.js +1 -5
  129. package/visual-test/visual-test.js.map +1 -1
@@ -7,7 +7,6 @@ var forms_1 = require("@angular/forms");
7
7
  var ts = require("typescript");
8
8
  /**
9
9
  * Determine if the node in an input field
10
- *
11
10
  * @param node Typescript AST Node
12
11
  * @param source Typescript source file
13
12
  */
@@ -16,7 +15,6 @@ function isInputNode(node, source) {
16
15
  }
17
16
  /**
18
17
  * Determine if the node in an output field
19
- *
20
18
  * @param node Typescript AST Node
21
19
  * @param source Typescript source file
22
20
  */
@@ -25,7 +23,6 @@ function isOutputNode(node, source) {
25
23
  }
26
24
  /**
27
25
  * Get the name of the input / output
28
- *
29
26
  * @param currentNode Typescript AST Node
30
27
  * @param decorator Current Input/Output decorator node
31
28
  * @param source Typescript source file
@@ -47,7 +44,6 @@ function getIOName(currentNode, decorator, source) {
47
44
  }
48
45
  /**
49
46
  * Get the list of Input and Output of a component
50
- *
51
47
  * @param parentNode Typescript AST Node
52
48
  * @param source Typescript source file
53
49
  */
@@ -80,7 +76,6 @@ function parseIO(parentNode, source) {
80
76
  }
81
77
  /**
82
78
  * Get the selector of an angular class
83
- *
84
79
  * @param parentNode Typescript AST Node
85
80
  * @param source Typescript source file
86
81
  * @param isInDecorator true if the recursive execution is in a decorator
@@ -113,7 +108,6 @@ function getSelector(parentNode, source, isInDecorator, isInComponentConfig) {
113
108
  }
114
109
  /**
115
110
  * Generate a mock class base on a component file
116
- *
117
111
  * @param componentPath Path to the component file to mock
118
112
  * @param config Object containing the following configurations:
119
113
  * template: should be provided if the template contain `<ng-content></ng-content>`
@@ -121,15 +115,17 @@ function getSelector(parentNode, source, isInDecorator, isInComponentConfig) {
121
115
  * @param config.template
122
116
  * @param config.isControlValueAccessor
123
117
  * @example
118
+ * ```typescript
124
119
  * // hero.component.ts
125
- * @Component({selector: 'hero'})
120
+ * \@Component({selector: 'hero'})
126
121
  * class HeroComponent {
127
- * @Input() name: string;
128
- * @Output() doSomething: EventEmitter<void>
122
+ * \@Input() name: string;
123
+ * \@Output() doSomething: EventEmitter<void>
129
124
  * }
130
125
  *
131
126
  * // mock generation
132
127
  * class MockComponent extends generateMockComponent('hero.component.ts') {}
128
+ * ```
133
129
  */
134
130
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
135
131
  function generateMockComponent(componentPath, config) {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;;;AAAA,sCAA0E;AAC1E,wCAAmD;AAEnD,+BAAiC;AAEjC;;;;;GAKG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;GAMG;AACH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OAAO,SAAA,IACJ,CAAC,MAAM,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAC7C,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,yBAAiB;gBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;gBACnC,KAAK,EAAE,IAAI;aACZ;SACF;KACF,CAAC,CAAC,CAAC,EAAE,EACN,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC;AAvCD,sDAuCC","sourcesContent":["import { Component, EventEmitter, forwardRef, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n *\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Input/.test(node.getText(source));\n}\n\n/**\n * Determine if the node in an output field\n *\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Output/.test(node.getText(source));\n}\n\n/**\n * Get the name of the input / output\n *\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(Input|Ouput) *\\( *(['\"](.*)['\"])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n *\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n *\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/['\"]/ig, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n *\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * // hero.component.ts\n * @Component({selector: 'hero'})\n * class HeroComponent {\n * @Input() name: string;\n * @Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.component.ts') {}\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport function generateMockComponent<T extends unknown = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => { };\n this.registerOnChange = () => { };\n this.registerOnTouched = () => { };\n }\n }\n };\n\n return Component({\n template: config && config.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor) ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n } : {}\n })(mock) as Type<T>;\n}\n"]}
1
+ {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;;;AAAA,sCAA0E;AAC1E,wCAAmD;AAEnD,+BAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,IAAM,eAAe,GAAG,SAAS,CAA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SAAS,EAAE;YACT;gBACE,OAAO,EAAE,yBAAiB;gBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;gBACnC,KAAK,EAAE,IAAI;aACZ;SACF;KACF,CAAC,CAAC,CAAC,EAAE,EACN,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC;AAvCD,sDAuCC","sourcesContent":["import { Component, EventEmitter, forwardRef, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Input/.test(node.getText(source));\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Output/.test(node.getText(source));\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(Input|Ouput) *\\( *(['\"](.*)['\"])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/['\"]/ig, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.component.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.component.ts') {}\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport function generateMockComponent<T extends unknown = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => { };\n this.registerOnChange = () => { };\n this.registerOnTouched = () => { };\n }\n }\n };\n\n return Component({\n template: config && config.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor) ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n } : {}\n })(mock) as Type<T>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "10.0.0-next.9",
3
+ "version": "11.0.0-next.0",
4
4
  "description": "The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.",
5
5
  "keywords": [
6
6
  "testing",
@@ -95,24 +95,24 @@
95
95
  },
96
96
  "peerDependencies": {
97
97
  "@amadeus-it-group/kassette": "^1.6.0",
98
- "@angular-devkit/schematics": "~16.2.0",
99
- "@angular/common": "~16.2.0",
100
- "@angular/core": "~16.2.0",
101
- "@angular/forms": "~16.2.0",
102
- "@angular/platform-browser": "~16.2.0",
103
- "@ngrx/store": "~16.2.0",
98
+ "@angular-devkit/schematics": "~17.0.0",
99
+ "@angular/common": "~17.0.2",
100
+ "@angular/core": "~17.0.2",
101
+ "@angular/forms": "~17.0.2",
102
+ "@angular/platform-browser": "~17.0.2",
103
+ "@ngrx/store": "~17.0.0",
104
104
  "@ngx-translate/core": "~15.0.0",
105
- "@o3r/core": "^10.0.0-next.9",
106
- "@o3r/localization": "^10.0.0-next.9",
107
- "@o3r/schematics": "^10.0.0-next.9",
108
- "@playwright/test": "~1.38.0",
109
- "@schematics/angular": "~16.2.0",
105
+ "@o3r/core": "^11.0.0-next.0",
106
+ "@o3r/localization": "^11.0.0-next.0",
107
+ "@o3r/schematics": "^11.0.0-next.0",
108
+ "@playwright/test": "~1.40.0",
109
+ "@schematics/angular": "~17.0.0",
110
110
  "pixelmatch": "^5.2.1",
111
111
  "pngjs": "^7.0.0",
112
112
  "protractor": "^7.0.0",
113
113
  "rxjs": "^7.8.1",
114
- "temporal-polyfill": "^0.1.1",
115
- "typescript": "~5.1.6"
114
+ "temporal-polyfill": "^0.2.0",
115
+ "typescript": "~5.2.2"
116
116
  },
117
117
  "peerDependenciesMeta": {
118
118
  "@amadeus-it-group/kassette": {
@@ -121,6 +121,9 @@
121
121
  "@angular-devkit/schematics": {
122
122
  "optional": true
123
123
  },
124
+ "@ngx-translate/core": {
125
+ "optional": true
126
+ },
124
127
  "@o3r/core": {
125
128
  "optional": true
126
129
  },
@@ -136,6 +139,12 @@
136
139
  "@schematics/angular": {
137
140
  "optional": true
138
141
  },
142
+ "pixelmatch": {
143
+ "optional": true
144
+ },
145
+ "pngjs": {
146
+ "optional": true
147
+ },
139
148
  "protractor": {
140
149
  "optional": true
141
150
  },
@@ -150,68 +159,69 @@
150
159
  },
151
160
  "devDependencies": {
152
161
  "@amadeus-it-group/kassette": "^1.6.0",
153
- "@angular-devkit/build-angular": "~16.2.0",
154
- "@angular-devkit/core": "~16.2.0",
155
- "@angular-devkit/schematics": "~16.2.0",
156
- "@angular-eslint/eslint-plugin": "~16.1.0",
157
- "@angular/cli": "~16.2.0",
158
- "@angular/common": "~16.2.0",
159
- "@angular/compiler": "~16.2.0",
160
- "@angular/compiler-cli": "~16.2.0",
161
- "@angular/core": "~16.2.0",
162
- "@angular/forms": "~16.2.0",
163
- "@angular/platform-browser": "~16.2.0",
164
- "@angular/platform-browser-dynamic": "~16.2.0",
165
- "@babel/core": "~7.22.0",
166
- "@babel/preset-typescript": "~7.22.0",
162
+ "@angular-devkit/build-angular": "~17.0.3",
163
+ "@angular-devkit/core": "~17.0.3",
164
+ "@angular-devkit/schematics": "~17.0.3",
165
+ "@angular-eslint/eslint-plugin": "~17.1.0",
166
+ "@angular/cli": "~17.0.3",
167
+ "@angular/common": "~17.0.4",
168
+ "@angular/compiler": "~17.0.4",
169
+ "@angular/compiler-cli": "~17.0.4",
170
+ "@angular/core": "~17.0.4",
171
+ "@angular/forms": "~17.0.4",
172
+ "@angular/platform-browser": "~17.0.4",
173
+ "@angular/platform-browser-dynamic": "~17.0.4",
174
+ "@babel/core": "~7.23.0",
175
+ "@babel/preset-typescript": "~7.23.0",
167
176
  "@compodoc/compodoc": "^1.1.19",
168
- "@ngrx/store": "~16.2.0",
177
+ "@ngrx/store": "~17.0.0",
169
178
  "@ngx-translate/core": "~15.0.0",
170
- "@nx/jest": "~16.8.0",
171
- "@o3r/build-helpers": "^10.0.0-next.9",
172
- "@o3r/core": "^10.0.0-next.9",
173
- "@o3r/dev-tools": "^10.0.0-next.9",
174
- "@o3r/eslint-plugin": "^10.0.0-next.9",
175
- "@o3r/localization": "^10.0.0-next.9",
176
- "@o3r/schematics": "^10.0.0-next.9",
177
- "@o3r/test-helpers": "^10.0.0-next.9",
178
- "@playwright/test": "~1.38.0",
179
- "@schematics/angular": "~16.2.0",
179
+ "@nx/eslint-plugin": "~17.1.1",
180
+ "@nx/jest": "~17.1.1",
181
+ "@o3r/build-helpers": "^11.0.0-next.0",
182
+ "@o3r/core": "^11.0.0-next.0",
183
+ "@o3r/eslint-plugin": "^11.0.0-next.0",
184
+ "@o3r/localization": "^11.0.0-next.0",
185
+ "@o3r/schematics": "^11.0.0-next.0",
186
+ "@o3r/test-helpers": "^11.0.0-next.0",
187
+ "@playwright/test": "~1.40.0",
188
+ "@schematics/angular": "~17.0.3",
180
189
  "@types/jest": "~29.5.2",
181
- "@types/node": "^18.0.0",
190
+ "@types/node": "^20.0.0",
182
191
  "@types/pixelmatch": "^5.2.3",
183
192
  "@types/pngjs": "^6.0.0",
184
- "@typescript-eslint/eslint-plugin": "^5.59.9",
185
- "@typescript-eslint/parser": "^5.59.9",
193
+ "@typescript-eslint/eslint-plugin": "6.11.0",
194
+ "@typescript-eslint/parser": "^6.11.0",
186
195
  "concurrently": "^8.0.0",
187
- "cpy-cli": "^4.2.0",
196
+ "cpy-cli": "^5.0.0",
188
197
  "eslint": "^8.42.0",
189
198
  "eslint-import-resolver-node": "^0.3.4",
190
- "eslint-plugin-jest": "~27.2.3",
191
- "eslint-plugin-jsdoc": "~46.8.0",
199
+ "eslint-plugin-jest": "~27.6.0",
200
+ "eslint-plugin-jsdoc": "~48.0.0",
192
201
  "eslint-plugin-prefer-arrow": "~1.2.3",
193
- "eslint-plugin-unicorn": "^47.0.0",
202
+ "eslint-plugin-unicorn": "^50.0.0",
194
203
  "isomorphic-fetch": "~3.0.0",
195
204
  "jest": "~29.7.0",
196
205
  "jest-environment-jsdom": "~29.7.0",
197
206
  "jest-junit": "~16.0.0",
198
- "jest-preset-angular": "~13.1.1",
199
- "nx": "~16.8.0",
207
+ "jest-preset-angular": "~13.1.4",
208
+ "jsonc-eslint-parser": "~2.4.0",
209
+ "nx": "~17.1.1",
200
210
  "pid-from-port": "^1.1.3",
201
211
  "pixelmatch": "^5.2.1",
202
212
  "pngjs": "^7.0.0",
203
213
  "protractor": "^7.0.0",
204
214
  "rxjs": "^7.8.1",
205
215
  "semver": "^7.5.2",
206
- "temporal-polyfill": "^0.1.1",
216
+ "temporal-polyfill": "^0.2.0",
207
217
  "ts-jest": "~29.1.1",
208
- "type-fest": "^3.12.0",
209
- "typescript": "~5.1.6",
210
- "zone.js": "~0.13.1"
218
+ "type-fest": "^4.3.1",
219
+ "typescript": "~5.2.2",
220
+ "zone.js": "~0.14.2"
211
221
  },
212
222
  "schematics": "./collection.json",
213
223
  "engines": {
214
- "node": ">=16.0.0"
224
+ "node": ">=18.0.0"
215
225
  },
216
226
  "type": "commonjs",
217
227
  "contributors": [
@@ -277,5 +287,6 @@
277
287
  ],
278
288
  "bugs": "https://github.com/AmadeusITGroup/otter/issues",
279
289
  "repository": "https://github.com/AmadeusITGroup/otter",
280
- "license": "BSD-3-Clause"
290
+ "license": "BSD-3-Clause",
291
+ "homepage": "https://amadeusitgroup.github.io/otter/"
281
292
  }
@@ -16,7 +16,7 @@ function ngAddFunctionsToFixture(options) {
16
16
  (tree) => {
17
17
  const { path, methods, selector } = options;
18
18
  if (!tree.exists(path)) {
19
- throw new Error(`File does not exist: ${path}`);
19
+ throw new schematics_2.O3rCliError(`File does not exist: ${path}`);
20
20
  }
21
21
  methods.forEach((methodType, index) => {
22
22
  const signature = (0, helpers_1.getSignature)(methodType, selector);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqE;AACrE,gDAAiD;AACjD,iCAAiC;AACjC,uCAA4D;AAC5D,qCAAuC;AAGvC;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,OAAgD;IACtF,OAAO,IAAA,kBAAK,EAAC;QACX,CAAC,IAAU,EAAE,EAAE;YACb,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;aACjD;YACD,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;gBACpC,MAAM,SAAS,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBAErD,MAAM,gBAAgB,GAAG,GAAG,oBAAW,CAAC,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC;gBAEzE,MAAM,iBAAiB,GAAG,YAAY,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CA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,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,2BAAc,GAAE;KAC/C,CAAC,CAAC;AACL,CAAC;AAvDD,0DAuDC"}
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "$id": "NgAddFunctionsToFixtureSchematicsSchema",
4
4
  "title": "Generate Otter Fixture",
5
5
  "description": "ng generate Otter fixture based on a selector and default methods",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAW7D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAkGxE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAYpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAW7D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAkGxE"}
@@ -11,7 +11,7 @@ const checkFixture = (componentPath, tree, baseFileName) => {
11
11
  node_path_1.posix.join((0, node_path_1.dirname)(componentPath), `${baseFileName}.fixture.ts`)
12
12
  ];
13
13
  if (files.some((file) => tree.exists(file))) {
14
- throw new Error(`Unable to add fixture to this component because it already has at least one of these files: ${files.join(', ')}.`);
14
+ throw new schematics_2.O3rCliError(`Unable to add fixture to this component because it already has at least one of these files: ${files.join(', ')}.`);
15
15
  }
16
16
  };
17
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.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EF,IAAA,8BAAqB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;oBACzC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;oBAE5B,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;yBAC3C,UAAU,CACT,gDAAgD,EAChD,gCAAgC,UAAU,CAAC,gBAAgB,kDAAkD,CAC9G;yBACA,UAAU,CACT,6CAA6C,EAC7C,8CAA8C,CAC/C,CAAC;oBAEJ,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;oBAEzC,OAAO,IAAI,CAAC;gBACd,CAAC;aACF,CAAC,CAAC;YAEH,OAAO,IAAA,kBAAK,EAAC;gBACX,sBAAsB;gBACtB,cAAc;gBACd,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,2BAAc,GAAE;aAC/C,CAAC,CAAC;SACJ;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,YAAY,6BAAgB,IAAI,OAAO,CAAC,WAAW,EAAE;gBACxD,MAAM,sBAAsB,GAAG,MAAM,IAAA,8CAAiC,GAAE,CAAC;gBACzE,IAAI,sBAAsB,EAAE;oBAC1B,OAAO,IAAA,kBAAK,EAAC;wBACX,IAAA,8BAAiB,EAAC,WAAW,EAAE,mBAAmB,EAAE;4BAClD,IAAI,EAAE,OAAO,CAAC,IAAI;yBACnB,CAAC;wBACF,YAAY,CAAC,OAAO,CAAC;qBACtB,CAAC,CAAC;iBACJ;aACF;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAlGD,oCAkGC"}
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "$id": "NgAddFixtureSchematicsSchema",
4
4
  "title": "Add Otter Fixture to an existing component",
5
5
  "description": "Add Otter Fixture to an existing component",
@@ -1,12 +1,13 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
2
  /**
3
3
  * Add fixture configuration
4
- *
5
4
  * @param options @see RuleFactory.options
6
5
  * @param options.projectName
7
6
  * @param registerUnitTestFixturePaths should add path mapping for unit test fixtures
7
+ * @param options.testingFramework
8
8
  */
9
9
  export declare function updateFixtureConfig(options: {
10
10
  projectName?: string | null | undefined;
11
+ testingFramework?: string | null | undefined;
11
12
  }, registerUnitTestFixturePaths: boolean): Rule;
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKjF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,4BAA4B,EAAE,OAAO,GAAG,IAAI,CA2DrI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKjF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,4BAA4B,EAAE,OAAO,GAAG,IAAI,CA2FnL"}
@@ -7,21 +7,20 @@ const schematics_2 = require("@o3r/schematics");
7
7
  const ts = require("typescript");
8
8
  /**
9
9
  * Add fixture configuration
10
- *
11
10
  * @param options @see RuleFactory.options
12
11
  * @param options.projectName
13
12
  * @param registerUnitTestFixturePaths should add path mapping for unit test fixtures
13
+ * @param options.testingFramework
14
14
  */
15
15
  function updateFixtureConfig(options, registerUnitTestFixturePaths) {
16
16
  const oldPaths = ['@otter/testing/core', '@otter/testing/core/*'];
17
17
  /**
18
18
  * Update test tsconfig
19
- *
20
19
  * @param tree
21
20
  * @param _context
22
21
  */
23
- const updateTestTsconfig = (tree, _context) => {
24
- const workspaceProject = (0, schematics_2.getProjectFromTree)(tree, options.projectName || null);
22
+ const updateTestTsconfig = (tree, context) => {
23
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
25
24
  if (!workspaceProject) {
26
25
  return tree;
27
26
  }
@@ -31,9 +30,6 @@ function updateFixtureConfig(options, registerUnitTestFixturePaths) {
31
30
  const tsconfigFile = ts.parseConfigFileTextToJson(tsconfig, tree.readText(tsconfig)).config;
32
31
  tsconfigFile.compilerOptions = tsconfigFile.compilerOptions || {};
33
32
  const tsconfigCompilerOptions = tsconfigFile.compilerOptions;
34
- if (!tsconfigCompilerOptions.baseUrl) {
35
- tsconfigCompilerOptions.baseUrl = '.';
36
- }
37
33
  tsconfigCompilerOptions.lib = [...(tsconfigCompilerOptions.lib || []),
38
34
  'dom',
39
35
  'es2020',
@@ -44,21 +40,52 @@ function updateFixtureConfig(options, registerUnitTestFixturePaths) {
44
40
  }
45
41
  return libs;
46
42
  }, []);
47
- tsconfigCompilerOptions.paths = Object.entries(tsconfigCompilerOptions.paths || {}).reduce((acc, [key, value]) => {
48
- if (oldPaths.indexOf(key) === -1) {
49
- acc[key] = value;
43
+ const testFramework = options.testingFramework || (0, schematics_2.getTestFramework)((0, schematics_2.getWorkspaceConfig)(tree), context);
44
+ if (testFramework === 'jest') {
45
+ tsconfigCompilerOptions.types ||= [];
46
+ if (tsconfigCompilerOptions.types.indexOf('jest') === -1) {
47
+ tsconfigCompilerOptions.types.push('jest');
50
48
  }
51
- return acc;
52
- }, {});
53
- if (registerUnitTestFixturePaths) {
54
- tsconfigCompilerOptions.paths['@o3r/testing/core'] = ['node_modules/@o3r/testing/core/angular'];
55
- tsconfigCompilerOptions.paths['@o3r/testing/core/*'] = ['node_modules/@o3r/testing/core/angular/*'];
56
49
  }
50
+ tsconfigCompilerOptions.esModuleInterop = true;
51
+ tsconfigCompilerOptions.outDir = 'test';
57
52
  tree.overwrite(tsconfig, JSON.stringify(tsconfigFile, null, 2));
58
53
  }
59
54
  return tree;
60
55
  };
61
- return (0, schematics_1.chain)([updateTestTsconfig]);
56
+ /**
57
+ * Update base tsconfig paths with o3r fixtures
58
+ * @param tree
59
+ * @param context
60
+ */
61
+ const updateBaseTsConfigWithO3rFixtures = (tree, context) => {
62
+ const tsconfigs = ['tsconfig.base.json', 'tsconfig.build.json', 'tsconfig.json'];
63
+ const configs = tsconfigs
64
+ .filter((tsconfig) => tree.exists(tsconfig))
65
+ .map((tsconfig) => ({
66
+ tsconfig,
67
+ content: ts.parseConfigFileTextToJson(tsconfig, tree.readText(tsconfig)).config
68
+ }))
69
+ .filter(({ content }) => !!content);
70
+ if (!configs.length) {
71
+ context.logger.warn('No base tsconfig found, the path mapping for otter fixtures will not be updated');
72
+ return tree;
73
+ }
74
+ const configWithPath = configs.find((config) => !!config.content?.compilerOptions?.paths) || configs[0];
75
+ configWithPath.content.compilerOptions.paths = Object.entries(configWithPath.content.compilerOptions.paths || {}).reduce((acc, [key, value]) => {
76
+ if (oldPaths.indexOf(key) === -1) {
77
+ acc[key] = value;
78
+ }
79
+ return acc;
80
+ }, {});
81
+ if (registerUnitTestFixturePaths) {
82
+ configWithPath.content.compilerOptions.paths['@o3r/testing/core'] = ['node_modules/@o3r/testing/core/angular'];
83
+ configWithPath.content.compilerOptions.paths['@o3r/testing/core/*'] = ['node_modules/@o3r/testing/core/angular/*'];
84
+ }
85
+ tree.overwrite(configWithPath.tsconfig, JSON.stringify(configWithPath.content, null, 2));
86
+ return tree;
87
+ };
88
+ return (0, schematics_1.chain)([updateTestTsconfig, updateBaseTsConfigWithO3rFixtures]);
62
89
  }
63
90
  exports.updateFixtureConfig = updateFixtureCon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C,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,CAAC;AACxE,CAAC;AA3FD,kDA2FC"}
@@ -2,7 +2,6 @@ import { Rule } from '@angular-devkit/schematics';
2
2
  import { NgAddSchematicsSchema } from '../../schematics/ng-add/schema';
3
3
  /**
4
4
  * Add Otter testing to an Angular Project
5
- *
6
5
  * @param options
7
6
  */
8
7
  export declare function ngAdd(options: NgAddSchematicsSchema): Rule;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2E,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAGlK,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAiBvE;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA6H1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2E,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAiBlK,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAavE;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAoH1D"}
@@ -4,10 +4,10 @@ exports.ngAdd = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
5
  const schematics_2 = require("@o3r/schematics");
6
6
  const prompt_1 = require("@angular/cli/src/utilities/prompt");
7
- const fixture_1 = require("./fixture");
8
- const path = require("node:path");
9
- const fs = require("node:fs");
10
7
  const dependencies_1 = require("@schematics/angular/utility/dependencies");
8
+ const fs = require("node:fs");
9
+ const path = require("node:path");
10
+ const fixture_1 = require("./fixture");
11
11
  const playwright_1 = require("./playwright");
12
12
  function canResolvePlaywright() {
13
13
  try {
@@ -20,19 +20,17 @@ function canResolvePlaywright() {
20
20
  }
21
21
  /**
22
22
  * Add Otter testing to an Angular Project
23
- *
24
23
  * @param options
25
24
  */
26
25
  function ngAdd(options) {
27
26
  return async (tree, context) => {
28
27
  try {
29
- const { addVsCodeRecommendations, getProjectDepType, getProjectFromTree, getO3rPeerDeps, ngAddPackages, ngAddPeerDependencyPackages, removePackages, registerPackageCollectionSchematics } = await Promise.resolve().then(() => require('@o3r/schematics'));
30
28
  const testPackageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
31
29
  const packageJson = JSON.parse(fs.readFileSync(testPackageJsonPath, { encoding: 'utf-8' }));
32
- const depsInfo = getO3rPeerDeps(testPackageJsonPath);
33
- const dependencyType = getProjectDepType(tree);
34
- const workspaceProject = (tree.exists('angular.json') && options.projectName) ? getProjectFromTree(tree, options.projectName) : undefined;
35
- const workingDirectory = workspaceProject?.root;
30
+ const depsInfo = (0, schematics_2.getO3rPeerDeps)(testPackageJsonPath);
31
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
32
+ const workingDirectory = workspaceProject?.root || '.';
33
+ const dependencyType = (0, schematics_2.getProjectNewDependenciesType)(workspaceProject);
36
34
  const projectType = workspaceProject?.projectType || 'application';
37
35
  let installJest;
38
36
  const testFramework = options.testingFramework || (0, schematics_2.getTestFramework)((0, schematics_2.getWorkspaceConfig)(tree), context);
@@ -64,9 +62,9 @@ function ngAdd(options) {
64
62
  }
65
63
  const rules = [
66
64
  (0, fixture_1.updateFixtureConfig)(options, installJest),
67
- removePackages(['@otter/testing']),
68
- addVsCodeRecommendations(['Orta.vscode-jest']),
69
- ngAddPackages(depsInfo.o3rPeerDeps, {
65
+ (0, schematics_2.removePackages)(['@otter/testing']),
66
+ (0, schematics_2.addVsCodeRecommendations)(['Orta.vscode-jest']),
67
+ (0, schematics_2.ngAddPackages)(depsInfo.o3rPeerDeps, {
70
68
  skipConfirmation: true,
71
69
  version: depsInfo.packageVersion,
72
70
  parentPackageInfo: depsInfo.packageName,
@@ -75,8 +73,8 @@ function ngAdd(options) {
75
73
  workingDirectory
76
74
  }),
77
75
  installPlaywright ? (0, playwright_1.updatePlaywright)(options) : schematics_1.noop,
78
- ngAddPeerDependencyPackages(['pixelmatch', 'pngjs'], testPackageJsonPath, dependencyType, { ...options, workingDirectory, skipNgAddSchematicRun: true }),
79
- registerPackageCollectionSchematics(packageJson),
76
+ (0, schematics_2.ngAddPeerDependencyPackages)(['pixelmatch', 'pngjs'], testPackageJsonPath, dependencyType, { ...options, workingDirectory, skipNgAddSchematicRun: true }),
77
+ (0, schematics_2.registerPackageCollectionSchematics)(packageJson),
80
78
  (0, schematics_2.setupSchematicsDefaultParams)({
81
79
  // eslint-disable-next-line @typescript-eslint/naming-convention
82
80
  '@o3r/core:component': {
@@ -101,7 +99,8 @@ function ngAdd(options) {
101
99
  const jestConfigFilesForProject = () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates/project'), [
102
100
  (0, schematics_1.template)({
103
101
  ...options,
104
- rootRelativePath: path.relative(workingDirectory, tree.root.path.replace(/^\//, './'))
102
+ rootRelativePath: path.posix.relative(workingDirectory, tree.root.path.replace(/^\//, './')),
103
+ isAngularSetup: tree.exists('/angular.json')
105
104
  }),
106
105
  (0, schematics_1.move)(workingDirectory),
107
106
  (0, schematics_1.renameTemplateFiles)()
@@ -113,10 +112,10 @@ function ngAdd(options) {
113
112
  (0, schematics_1.move)(tree.root.path),
114
113
  (0, schematics_1.renameTemplateFiles)()
115
114
  ]), schematics_1.MergeStrategy.Default);
116
- rules.push(ngAddPeerDependencyPackages(['jest', 'jest-preset-angular'], testPackageJsonPath, dependencies_1.NodeDependencyType.Dev, { ...options, workingDirectory, skipNgAddSchematicRun: true }), jestConfigFilesForProject, jestConfigFilesForWorkspace);
115
+ rules.push((0, schematics_2.ngAddPeerDependencyPackages)(['jest', 'jest-preset-angular'], testPackageJsonPath, dependencies_1.NodeDependencyType.Dev, { ...options, workingDirectory, skipNgAddSchematicRun: true }), jestConfigFilesForProject, jestConfigFilesForWorkspace);
117
116
  }
118
117
  else {
119
- throw new Error(`Could not find working directory for project ${workspaceProject?.name || ''}`);
118
+ throw new schematics_2.O3rCliError(`Could not find working directory for project ${options.projectName || ''}`);
120
119
  }
121
120
  }
122
121
  return () => (0, schematics_1.chain)(rules)(tree, context);
@@ -125,7 +124,7 @@ function ngAdd(options) {
125
124
  context.logger.error(`[ERROR]: Adding @o3r/testing has failed.
126
125
  If the error is related to missing @o3r dependencies you need to install '@o3r/core' or '@o3r/schematics' to be able to use the testing package.
127
126
  Please run 'ng add @o3r/core' or 'ng add @o3r/schematics'. Otherwise, use the error message as guidance.`);
128
- throw (e);
127
+ throw new schematics_2.O3rCliError(e);
129
128
  }
130
129
  };
131
130
  }