@testgorilla/tgo-coding-test 0.0.1

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 (163) hide show
  1. package/.eslintrc.json +45 -0
  2. package/README.md +257 -0
  3. package/jest.config.ts +21 -0
  4. package/ng-package.json +14 -0
  5. package/package.json +33 -0
  6. package/project.json +36 -0
  7. package/src/assets/i18n/en.json +124 -0
  8. package/src/index.ts +30 -0
  9. package/src/lib/components/.gitkeep +0 -0
  10. package/src/lib/components/code-editor/code-editor.component.html +10 -0
  11. package/src/lib/components/code-editor/code-editor.component.scss +21 -0
  12. package/src/lib/components/code-editor/code-editor.component.spec.ts +136 -0
  13. package/src/lib/components/code-editor/code-editor.component.ts +369 -0
  14. package/src/lib/components/code-editor/code-editor.mocks.ts +28 -0
  15. package/src/lib/components/code-editor/code-editor.service.spec.ts +160 -0
  16. package/src/lib/components/code-editor/code-editor.service.ts +94 -0
  17. package/src/lib/components/code-editor/helpers/c-helper.spec.ts +39 -0
  18. package/src/lib/components/code-editor/helpers/c-helper.ts +51 -0
  19. package/src/lib/components/code-editor/helpers/code-editor-helper.base.spec.ts +30 -0
  20. package/src/lib/components/code-editor/helpers/code-editor-helper.base.ts +16 -0
  21. package/src/lib/components/code-editor/helpers/code-editor-helper.mocks.ts +24 -0
  22. package/src/lib/components/code-editor/helpers/code-editor-helper.model.ts +67 -0
  23. package/src/lib/components/code-editor/helpers/cpp-helper.spec.ts +40 -0
  24. package/src/lib/components/code-editor/helpers/cpp-helper.ts +52 -0
  25. package/src/lib/components/code-editor/helpers/csharp-helper.spec.ts +42 -0
  26. package/src/lib/components/code-editor/helpers/csharp-helper.ts +55 -0
  27. package/src/lib/components/code-editor/helpers/go-helper.spec.ts +41 -0
  28. package/src/lib/components/code-editor/helpers/go-helper.ts +54 -0
  29. package/src/lib/components/code-editor/helpers/index.ts +15 -0
  30. package/src/lib/components/code-editor/helpers/java-helper.spec.ts +41 -0
  31. package/src/lib/components/code-editor/helpers/java-helper.ts +54 -0
  32. package/src/lib/components/code-editor/helpers/javascript-helper.spec.ts +39 -0
  33. package/src/lib/components/code-editor/helpers/javascript-helper.ts +32 -0
  34. package/src/lib/components/code-editor/helpers/kotlin-helper.spec.ts +41 -0
  35. package/src/lib/components/code-editor/helpers/kotlin-helper.ts +54 -0
  36. package/src/lib/components/code-editor/helpers/php-helper.spec.ts +39 -0
  37. package/src/lib/components/code-editor/helpers/php-helper.ts +32 -0
  38. package/src/lib/components/code-editor/helpers/python-helper.spec.ts +39 -0
  39. package/src/lib/components/code-editor/helpers/python-helper.ts +32 -0
  40. package/src/lib/components/code-editor/helpers/r-helper.spec.ts +39 -0
  41. package/src/lib/components/code-editor/helpers/r-helper.ts +32 -0
  42. package/src/lib/components/code-editor/helpers/ruby-helper.spec.ts +39 -0
  43. package/src/lib/components/code-editor/helpers/ruby-helper.ts +32 -0
  44. package/src/lib/components/code-editor/helpers/scala-helper.spec.ts +41 -0
  45. package/src/lib/components/code-editor/helpers/scala-helper.ts +53 -0
  46. package/src/lib/components/code-editor/helpers/sql-helper.spec.ts +87 -0
  47. package/src/lib/components/code-editor/helpers/sql-helper.ts +44 -0
  48. package/src/lib/components/code-editor/helpers/swift-helper.spec.ts +40 -0
  49. package/src/lib/components/code-editor/helpers/swift-helper.ts +51 -0
  50. package/src/lib/components/code-editor/helpers/typescript-helper.spec.ts +40 -0
  51. package/src/lib/components/code-editor/helpers/typescript-helper.ts +52 -0
  52. package/src/lib/components/code-editor/models/code-editor.model.ts +9 -0
  53. package/src/lib/components/code-editor/models/coding-snapshot.model.ts +4 -0
  54. package/src/lib/components/coding-question/coding-question.component.html +78 -0
  55. package/src/lib/components/coding-question/coding-question.component.scss +76 -0
  56. package/src/lib/components/coding-question/coding-question.component.spec.ts +85 -0
  57. package/src/lib/components/coding-question/coding-question.component.ts +102 -0
  58. package/src/lib/components/coding-section/coding-section.component.html +82 -0
  59. package/src/lib/components/coding-section/coding-section.component.scss +64 -0
  60. package/src/lib/components/coding-section/coding-section.component.spec.ts +257 -0
  61. package/src/lib/components/coding-section/coding-section.component.ts +187 -0
  62. package/src/lib/components/coding-test.module.ts +124 -0
  63. package/src/lib/components/common/truncated-text/truncated-text.component.html +6 -0
  64. package/src/lib/components/common/truncated-text/truncated-text.component.scss +18 -0
  65. package/src/lib/components/common/truncated-text/truncated-text.component.spec.ts +84 -0
  66. package/src/lib/components/common/truncated-text/truncated-text.component.ts +37 -0
  67. package/src/lib/components/configurations/configurations.component.html +57 -0
  68. package/src/lib/components/configurations/configurations.component.scss +42 -0
  69. package/src/lib/components/configurations/configurations.component.spec.ts +186 -0
  70. package/src/lib/components/configurations/configurations.component.ts +98 -0
  71. package/src/lib/components/instructions/instructions.component.html +41 -0
  72. package/src/lib/components/instructions/instructions.component.scss +167 -0
  73. package/src/lib/components/instructions/instructions.component.spec.ts +106 -0
  74. package/src/lib/components/instructions/instructions.component.ts +138 -0
  75. package/src/lib/components/panel/panel.component.html +19 -0
  76. package/src/lib/components/panel/panel.component.scss +41 -0
  77. package/src/lib/components/panel/panel.component.spec.ts +40 -0
  78. package/src/lib/components/panel/panel.component.ts +34 -0
  79. package/src/lib/components/runnable-editor/runnable-editor.component.html +75 -0
  80. package/src/lib/components/runnable-editor/runnable-editor.component.scss +55 -0
  81. package/src/lib/components/runnable-editor/runnable-editor.component.spec.ts +124 -0
  82. package/src/lib/components/runnable-editor/runnable-editor.component.ts +155 -0
  83. package/src/lib/components/tests/test-cases/test-cases.component.html +135 -0
  84. package/src/lib/components/tests/test-cases/test-cases.component.scss +220 -0
  85. package/src/lib/components/tests/test-cases/test-cases.component.spec.ts +401 -0
  86. package/src/lib/components/tests/test-cases/test-cases.component.ts +205 -0
  87. package/src/lib/components/tests/test-cases-content/test-cases-content.component.html +94 -0
  88. package/src/lib/components/tests/test-cases-content/test-cases-content.component.scss +103 -0
  89. package/src/lib/components/tests/test-cases-content/test-cases-content.component.spec.ts +122 -0
  90. package/src/lib/components/tests/test-cases-content/test-cases-content.component.ts +102 -0
  91. package/src/lib/components/tests/test-cases-status/test-cases-status.component.html +16 -0
  92. package/src/lib/components/tests/test-cases-status/test-cases-status.component.scss +49 -0
  93. package/src/lib/components/tests/test-cases-status/test-cases-status.component.spec.ts +22 -0
  94. package/src/lib/components/tests/test-cases-status/test-cases-status.component.ts +18 -0
  95. package/src/lib/components/tests/test-results.component.html +119 -0
  96. package/src/lib/components/tests/test-results.component.scss +189 -0
  97. package/src/lib/components/tests/test-results.component.spec.ts +140 -0
  98. package/src/lib/components/tests/test-results.component.ts +98 -0
  99. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.html +96 -0
  100. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.scss +6 -0
  101. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.spec.ts +599 -0
  102. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.ts +279 -0
  103. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.html +36 -0
  104. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.scss +183 -0
  105. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.spec.ts +883 -0
  106. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.ts +575 -0
  107. package/src/lib/config/index.ts +3 -0
  108. package/src/lib/config/tgo-coding-test.config.ts +26 -0
  109. package/src/lib/config/tgo-coding-test.provider.ts +38 -0
  110. package/src/lib/config/tgo-coding-test.token.ts +21 -0
  111. package/src/lib/models/.gitkeep +0 -0
  112. package/src/lib/models/auto-saved-data.ts +51 -0
  113. package/src/lib/models/code-event.ts +17 -0
  114. package/src/lib/models/coderunner-execution-results.ts +58 -0
  115. package/src/lib/models/coding-lib.mocks.ts +246 -0
  116. package/src/lib/models/configs.ts +18 -0
  117. package/src/lib/models/language-change-action.ts +4 -0
  118. package/src/lib/models/lat-languages.ts +12 -0
  119. package/src/lib/models/mixpanel-events.ts +3 -0
  120. package/src/lib/models/mode.ts +5 -0
  121. package/src/lib/models/paste-data.ts +4 -0
  122. package/src/lib/models/programming-language.ts +9 -0
  123. package/src/lib/models/test-cases.ts +74 -0
  124. package/src/lib/models/theme.ts +5 -0
  125. package/src/lib/models/translations.ts +1 -0
  126. package/src/lib/models/view-mode.ts +6 -0
  127. package/src/lib/pipes/memoize-func.pipe.ts +34 -0
  128. package/src/lib/services/.gitkeep +0 -0
  129. package/src/lib/services/candidate-coding-test-services/candidature-api.service.spec.ts +40 -0
  130. package/src/lib/services/candidate-coding-test-services/candidature-api.service.ts +15 -0
  131. package/src/lib/services/candidate-coding-test-services/coderunner-api.service.spec.ts +134 -0
  132. package/src/lib/services/candidate-coding-test-services/coderunner-api.service.ts +105 -0
  133. package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.spec.ts +161 -0
  134. package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.ts +100 -0
  135. package/src/lib/services/candidate-coding-test-services/coding-test.service.spec.ts +1524 -0
  136. package/src/lib/services/candidate-coding-test-services/coding-test.service.ts +843 -0
  137. package/src/lib/services/candidate-coding-test-services/index.ts +4 -0
  138. package/src/lib/services/coding-test-config.service.ts +48 -0
  139. package/src/lib/services/configurations.service.mocks.ts +77 -0
  140. package/src/lib/services/configurations.service.spec.ts +79 -0
  141. package/src/lib/services/configurations.service.ts +111 -0
  142. package/src/lib/services/index.ts +0 -0
  143. package/src/lib/services/lib-coding-test.service.spec.ts +265 -0
  144. package/src/lib/services/lib-coding-test.service.ts +157 -0
  145. package/src/lib/services/local-storage.service.mocks.ts +22 -0
  146. package/src/lib/services/storage.service.spec.ts +1120 -0
  147. package/src/lib/services/storage.service.ts +729 -0
  148. package/src/lib/services/test-cases.service.spec.ts +53 -0
  149. package/src/lib/services/test-cases.service.ts +29 -0
  150. package/src/lib/services/theme.service.spec.ts +76 -0
  151. package/src/lib/services/theme.service.ts +34 -0
  152. package/src/lib/styles/mixins.scss +86 -0
  153. package/src/lib/styles/styles.scss +112 -0
  154. package/src/lib/styles/variables.scss +105 -0
  155. package/src/lib/utils/.gitkeep +0 -0
  156. package/src/lib/utils/additional-languages/erlang.ts +115 -0
  157. package/src/lib/utils/resize-element.ts +15 -0
  158. package/src/lib/utils/time-to-ms.util.ts +10 -0
  159. package/src/test-setup.ts +1 -0
  160. package/tsconfig.json +16 -0
  161. package/tsconfig.lib.json +12 -0
  162. package/tsconfig.lib.prod.json +9 -0
  163. package/tsconfig.spec.json +13 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "extends": ["../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts"],
7
+ "extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
8
+ "rules": {
9
+ "@angular-eslint/directive-selector": [
10
+ "error",
11
+ {
12
+ "type": "attribute",
13
+ "prefix": "tgo",
14
+ "style": "camelCase"
15
+ }
16
+ ],
17
+ "@angular-eslint/component-selector": [
18
+ "error",
19
+ {
20
+ "type": "element",
21
+ "prefix": "tgo",
22
+ "style": "kebab-case"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "files": ["*.html"],
29
+ "extends": ["plugin:@nx/angular-template"],
30
+ "rules": {}
31
+ },
32
+ {
33
+ "files": ["*.json"],
34
+ "parser": "jsonc-eslint-parser",
35
+ "rules": {
36
+ "@nx/dependency-checks": [
37
+ "error",
38
+ {
39
+ "ignoredFiles": ["{projectRoot}/eslint.config.{js,cjs,mjs}"]
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ ]
45
+ }
package/README.md ADDED
@@ -0,0 +1,257 @@
1
+ # @testgorilla/tgo-coding-test
2
+
3
+ Coding test component for TestGorilla assessments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @testgorilla/tgo-coding-test
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ The library requires runtime configuration to be provided by the consuming application. This follows the Dependency Injection pattern for NPM libraries, where the library artifact is immutable and configuration is provided at runtime.
14
+
15
+ ### Setup
16
+
17
+ In your application's `app.config.ts` (for standalone apps) or module providers:
18
+
19
+ ```typescript
20
+ import { ApplicationConfig } from '@angular/core';
21
+ import { provideTgoCodingTest } from '@testgorilla/tgo-coding-test';
22
+ import { environment } from './environments/environment';
23
+
24
+ export const appConfig: ApplicationConfig = {
25
+ providers: [
26
+ // Provide TGO Coding Test library configuration
27
+ provideTgoCodingTest({
28
+ apiUrl: environment.apiUrl,
29
+ coderunnerV2Endpoint: environment.coderunnerV2Endpoint,
30
+ }),
31
+ // ... other providers
32
+ ],
33
+ };
34
+ ```
35
+
36
+ ### Configuration Interface
37
+
38
+ ```typescript
39
+ interface TgoCodingTestConfig {
40
+ /**
41
+ * The base URL for the main API endpoint.
42
+ * Example: 'https://api-talent-staging.testgorilla.com/api/'
43
+ */
44
+ apiUrl: string;
45
+
46
+ /**
47
+ * The base URL for the CodeRunner V2 API endpoint.
48
+ * Example: 'https://cr-v2-staging.testgorilla.com'
49
+ */
50
+ coderunnerV2Endpoint: string;
51
+ }
52
+ ```
53
+
54
+ **Note:** The configuration must be provided at the application level. If you're using `TgoCodingTestCandidateViewComponent` in a demo or test environment, you can provide the configuration directly in the component's providers array, but this is not recommended for production use.
55
+
56
+ ## Usage
57
+
58
+ ### TgoCodingTestComponent
59
+
60
+ The core coding test component for rendering code editors and test cases.
61
+
62
+ ```typescript
63
+ import { TgoCodingTestComponent } from '@testgorilla/tgo-coding-test';
64
+
65
+ @Component({
66
+ imports: [TgoCodingTestComponent],
67
+ template: `
68
+ <tgo-coding-test
69
+ [languages]="languages"
70
+ [initCode]="initCode"
71
+ [questionText]="questionText"
72
+ [mode]="mode"
73
+ [viewMode]="viewMode"
74
+ [isLAT]="isLAT"
75
+ [isSQL]="isSQL"
76
+ [applicationTheme]="applicationTheme"
77
+ (codeChange)="onCodeChange($event)"
78
+ (languageChange)="onLanguageChange($event)"
79
+ (runTestClick)="onRunTestClick($event)"
80
+ (pasteEvent)="onPasteEvent($event)"
81
+ ></tgo-coding-test>
82
+ `,
83
+ })
84
+ export class MyComponent {}
85
+ ```
86
+
87
+ ### TgoCodingTestCandidateViewComponent
88
+
89
+ The candidate view component that wraps `TgoCodingTestComponent` with full test management, API integration, and anti-cheating features.
90
+
91
+ ```typescript
92
+ import { TgoCodingTestCandidateViewComponent } from '@testgorilla/tgo-coding-test';
93
+
94
+ @Component({
95
+ imports: [TgoCodingTestCandidateViewComponent],
96
+ template: `
97
+ <tgo-coding-test-candidate-view
98
+ [question]="question"
99
+ [test]="test"
100
+ [assessment]="assessment"
101
+ [expirationObservable]="expirationObservable"
102
+ [completeObservable]="completeObservable"
103
+ (submissionStateChanged)="onSubmissionStateChanged($event)"
104
+ (loadingStateChanged)="onLoadingStateChanged($event)"
105
+ (antiCheatingConfigurationChanged)="onAntiCheatingConfigurationChanged($event)"
106
+ (fullscreenChanged)="onFullscreenChanged($event)"
107
+ (themeChanged)="onThemeChanged($event)"
108
+ (navigationButtonStateChanged)="onNavigationButtonStateChanged($event)"
109
+ (configurationStateChanged)="onConfigurationStateChanged($event)"
110
+ ></tgo-coding-test-candidate-view>
111
+ `,
112
+ })
113
+ export class MyComponent {}
114
+ ```
115
+
116
+ ## API
117
+
118
+ ### TgoCodingTestComponent
119
+
120
+ #### Inputs
121
+
122
+ | Name | Type | Required | Default | Description |
123
+ | --------------------------- | --------------------------- | -------- | ------- | ---------------------------------------------------------------- |
124
+ | languages | LATLanguages | Yes | - | Array of available programming languages |
125
+ | initCode | string | No | - | Initial code to display in the editor |
126
+ | snapshot | CodingSnapshot | No | - | Snapshot of coding state for restoration |
127
+ | functionParams | CodeEditorFuncParam[] | No | - | Function parameters for function-based questions |
128
+ | functionName | string | No | - | Function name for function-based questions |
129
+ | returnType | keyof CodeEditorTypesMap | No | - | Return type for function-based questions |
130
+ | isLAT | boolean | No | - | Whether this is a Language-Agnostic Test |
131
+ | isSQL | boolean | No | - | Whether this is an SQL test |
132
+ | shouldGenerateInitCode | boolean | No | true | Whether to generate initial code automatically |
133
+ | canAddCustomTestCases | boolean | No | true | Whether users can add custom test cases |
134
+ | selectedProgrammingLanguage | LATLanguage | No | - | Pre-selected programming language |
135
+ | isReadonly | boolean | No | - | Whether the editor is in read-only mode |
136
+ | autoHeight | boolean | No | - | Whether the editor should auto-adjust height |
137
+ | translations | Record\<string, unknown\> | No | - | Translation object for UI text |
138
+ | questionText | string | No | - | Question text to display |
139
+ | mode | Modes | No | - | Test mode (Running, Preview, NonAssessmentPreview) |
140
+ | assessmentId | string | No | - | Assessment ID for storage and tracking |
141
+ | companyColor | string | No | - | Company brand color for theming |
142
+ | testCasesStatus | any | No | - | Status of test case execution |
143
+ | loading | boolean | No | - | Loading state indicator |
144
+ | runTestResponse | any[] | No | [] | Response from test execution |
145
+ | viewMode | ViewMode | No | - | View mode (Full, Compact) |
146
+ | exampleTestCases | ExampleTestCase[] | No | - | Example test cases to display |
147
+ | hideTestCases | boolean | No | - | Whether to hide test cases UI (legacy property) |
148
+ | applicationTheme | ApplicationTheme | No | 'light' | Application theme (light/dark) |
149
+ | questionId | number | No | - | Question ID for storage and tracking |
150
+
151
+ #### Outputs
152
+
153
+ | Name | Type | Description |
154
+ | -------------- | --------------------------------- | ---------------------------------------------- |
155
+ | pasteEvent | EventEmitter\<PasteData\> | Emits when paste event is detected |
156
+ | codeChange | EventEmitter\<string\> | Emits when code content changes |
157
+ | runTestClick | EventEmitter\<boolean\> | Emits when run test button is clicked |
158
+ | languageChange | EventEmitter\<CodeEditorLanguages\> | Emits when programming language is changed |
159
+
160
+ ### TgoCodingTestCandidateViewComponent
161
+
162
+ #### Inputs
163
+
164
+ | Name | Type | Required | Default | Description |
165
+ | -------------------- | ---------------------- | -------- | ------- | ------------------------------------------------ |
166
+ | question | Question | Yes | - | Question data containing coding test context |
167
+ | test | TestResultRead | Yes | - | Test configuration and metadata |
168
+ | assessment | Assessment | No | - | Assessment context |
169
+ | expirationObservable | Observable\<void\> | No | - | Observable to trigger test expiration externally |
170
+ | completeObservable | Observable\<void\> | No | - | Observable to trigger test completion externally |
171
+ | isDemo | boolean | No | - | Whether this is a demo/preview mode |
172
+
173
+ #### Outputs
174
+
175
+ | Name | Type | Description |
176
+ | ------------------------------ | ---------------------------------------- | ----------------------------------------------- |
177
+ | submissionStateChanged | EventEmitter\<ISubmissionState \| null\> | Emits submission state when answer is submitted |
178
+ | loadingStateChanged | EventEmitter\<boolean\> | Emits loading state changes |
179
+ | antiCheatingConfigurationChanged | EventEmitter\<IAntiCheatingState \| null\> | Emits anti-cheating configuration changes |
180
+ | fullscreenChanged | EventEmitter\<boolean\> | Emits when fullscreen state changes |
181
+ | themeChanged | EventEmitter\<ApplicationTheme\> | Emits when application theme changes |
182
+ | codingFullscreenChanged | EventEmitter\<boolean\> | Emits when coding editor fullscreen changes |
183
+ | navigationButtonStateChanged | EventEmitter\<INavigationButtonState \| null\> | Emits navigation button state changes |
184
+ | configurationStateChanged | EventEmitter\<IConfigurationState \| null\> | Emits configuration state changes |
185
+ | validationStatusChanged | EventEmitter\<any\> | Emits validation status changes |
186
+
187
+ ## Peer Dependencies
188
+
189
+ This library requires the following peer dependencies:
190
+
191
+ - `@angular/common` ^18.2.13
192
+ - `@angular/core` ^18.2.13
193
+ - `@angular/animations` ^18.2.13
194
+ - `@angular/forms` ^18.2.13
195
+ - `@angular/material` 18.2.14
196
+ - `@angular/router` ^18.2.13
197
+ - `@ngneat/transloco` ~4.3.0
198
+ - `@ngneat/until-destroy` 10.0.0
199
+ - `@testgorilla/tgo-test-shared` ^0.0.1
200
+ - `@testgorilla/tgo-ui` ^3.0.0
201
+ - `angular-split` ^18.0.0
202
+ - `monaco-editor` 0.50.0
203
+ - `ngx-guided-tour` ^2.0.1
204
+ - `ngx-monaco-editor-v2` ^18.1.0
205
+ - `ngx-quill` ^26.0.10
206
+ - `ngx-webstorage` ^18.0.0
207
+ - `quill` ^2.0.3
208
+ - `rxjs` ~7.8.1
209
+
210
+ ## Internal Dependencies
211
+
212
+ All required services, models, and components are included within this library:
213
+
214
+ - `LibCodingTestService` - Manages coding test state, language selection, and code management
215
+ - `StorageCodingService` - Handles localStorage persistence for code and test cases
216
+ - `CodingTestService` - Handles test execution, API calls, and test case management
217
+ - `CandidatureApiService` - API service for candidate-related operations
218
+ - `CoderunnerApiService` - API service for code execution
219
+ - `CodingTestConfigService` - Provides access to library configuration (injects configuration token internally)
220
+ - `ThemeService` - Provides theme/company color configuration
221
+ - `Question`, `TestResultRead`, `Assessment`, `ISubmissionState` - Type definitions from `@testgorilla/tgo-test-shared`
222
+ - `CodeEditorComponent`, `CodingQuestionComponent`, `RunnableEditorComponent` - UI components
223
+ - `TranslocoLazyModuleUtils`, `getAvailableLangs` - Translation utilities
224
+
225
+ ### Accessing Configuration
226
+
227
+ If you need to access the library configuration in your services or components, inject `CodingTestConfigService`:
228
+
229
+ ```typescript
230
+ import { CodingTestConfigService } from '@testgorilla/tgo-coding-test';
231
+
232
+ @Injectable()
233
+ export class MyService {
234
+ private readonly configService = inject(CodingTestConfigService);
235
+
236
+ doSomething() {
237
+ const endpoint = this.configService.getCoderunnerV2Endpoint();
238
+ // Use endpoint...
239
+ }
240
+ }
241
+ ```
242
+
243
+ ## Features
244
+
245
+ - Multi-language code editor support (Language-Agnostic Tests)
246
+ - SQL test support
247
+ - Custom test case creation and management
248
+ - Code auto-save and restoration
249
+ - Test execution with real-time results
250
+ - Fullscreen mode support
251
+ - Theme support (light/dark)
252
+ - Guided tour for new users
253
+ - Anti-cheating configuration
254
+ - Translation support via Transloco
255
+ - Preview mode support
256
+ - Code paste detection and tracking
257
+ - Periodic storage maintenance
package/jest.config.ts ADDED
@@ -0,0 +1,21 @@
1
+ export default {
2
+ displayName: 'tgo-coding-test',
3
+ preset: '../../jest.preset.js',
4
+ setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
5
+ coverageDirectory: '../../coverage/packages/tgo-coding-test',
6
+ transform: {
7
+ '^.+\\.(ts|mjs|js|html)$': [
8
+ 'jest-preset-angular',
9
+ {
10
+ tsconfig: '<rootDir>/tsconfig.spec.json',
11
+ stringifyContentPathRegex: '\\.(html|svg)$',
12
+ },
13
+ ],
14
+ },
15
+ transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$|lodash-es|@testgorilla/tgo-ui|ng2-charts|quill|ngx-quill|parchment)'],
16
+ snapshotSerializers: [
17
+ 'jest-preset-angular/build/serializers/no-ng-attributes',
18
+ 'jest-preset-angular/build/serializers/ng-snapshot',
19
+ 'jest-preset-angular/build/serializers/html-comment',
20
+ ],
21
+ };
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/packages/tgo-coding-test",
4
+ "assets": [
5
+ {
6
+ "glob": "**/*",
7
+ "input": "./src/assets",
8
+ "output": "./assets"
9
+ }
10
+ ],
11
+ "lib": {
12
+ "entryFile": "src/index.ts"
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@testgorilla/tgo-coding-test",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/animations": "^18.2.13",
6
+ "@angular/common": "^18.2.13",
7
+ "@angular/core": "^18.2.13",
8
+ "@angular/forms": "^18.2.13",
9
+ "@angular/material": "18.2.14",
10
+ "@angular/router": "^18.2.13",
11
+ "@ngneat/transloco": "~4.3.0",
12
+ "@ngneat/until-destroy": "10.0.0",
13
+ "@testgorilla/tgo-test-shared": "^0.0.1",
14
+ "@testgorilla/tgo-ui": "^3.0.0",
15
+ "angular-split": "^18.0.0",
16
+ "jest-preset-angular": "~14.2.4",
17
+ "monaco-editor": "0.50.0",
18
+ "ngx-guided-tour": "^2.0.1",
19
+ "ngx-monaco-editor-v2": "^18.1.0",
20
+ "ngx-quill": "^26.0.10",
21
+ "ngx-webstorage": "^18.0.0",
22
+ "quill": "^2.0.3",
23
+ "rxjs": "~7.8.1"
24
+ },
25
+ "sideEffects": false,
26
+ "license": "PROPRIETARY",
27
+ "publishConfig": {
28
+ "access": "restricted",
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "displayName": "Coding test",
32
+ "description": "Coding test component"
33
+ }
package/project.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "tgo-coding-test",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/tgo-coding-test/src",
5
+ "prefix": "tgo",
6
+ "projectType": "library",
7
+ "tags": [],
8
+ "targets": {
9
+ "build": {
10
+ "executor": "@nx/angular:package",
11
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12
+ "options": {
13
+ "project": "packages/tgo-coding-test/ng-package.json"
14
+ },
15
+ "configurations": {
16
+ "production": {
17
+ "tsConfig": "packages/tgo-coding-test/tsconfig.lib.prod.json"
18
+ },
19
+ "development": {
20
+ "tsConfig": "packages/tgo-coding-test/tsconfig.lib.json"
21
+ }
22
+ },
23
+ "defaultConfiguration": "production"
24
+ },
25
+ "test": {
26
+ "executor": "@nx/jest:jest",
27
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28
+ "options": {
29
+ "jestConfig": "packages/tgo-coding-test/jest.config.ts"
30
+ }
31
+ },
32
+ "lint": {
33
+ "executor": "@nx/eslint:lint"
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,124 @@
1
+ {
2
+ "ERRORS": {
3
+ "SYSTEM_ERROR": "Oops. Something went wrong. Please try again in a few minutes."
4
+ },
5
+ "COMMON": {
6
+ "CANCEL": "Cancel"
7
+ },
8
+ "TEST_RESULTS": {
9
+ "TEST_CASES": {
10
+ "NONE": "None",
11
+ "NO_RESPONSE": "No response",
12
+ "EXECUTED_SUCCESSFULLY": "Code executed successfully",
13
+ "TIMEOUT_ERROR": "Timeout error, please review your code"
14
+ }
15
+ },
16
+ "MODALS": {
17
+ "RESET_CODE": {
18
+ "TITLE": "Are you sure you want to reset your code?",
19
+ "MESSAGE": "Your code will be cleared and you’d have to start again from the scratch. Is that what you want to do?",
20
+ "SUBMIT": "Reset code"
21
+ },
22
+ "DELETE_TEST_CASE": {
23
+ "TITLE": "Delete this test case?",
24
+ "MESSAGE": "You won't be able to recover the entered data.",
25
+ "SUBMIT": "Delete"
26
+ },
27
+ "LANGUAGE_CHANGE": {
28
+ "TITLE": "You are switching the programming language",
29
+ "MESSAGE": "Your current progress will be saved. It will still be available if you switch back to this language.",
30
+ "SUBMIT": "Confirm"
31
+ },
32
+ "FINISH_TEST": {
33
+ "TITLE": "This action will submit and finish your coding test!",
34
+ "MESSAGE": "You cannot come back to this test later. Make sure your answer is ready to be submitted before proceeding",
35
+ "CANCEL": "Keep coding",
36
+ "SUBMIT": "Finish test"
37
+ }
38
+ },
39
+ "CODING_LIB": {
40
+ "PRACTICE_QUESTIONS_STAGE": {
41
+ "INFO": "Info",
42
+ "QUESTIONS_INDEXING": "This is the first practice question.",
43
+ "QUESTIONS_INDEXING_AS_LAST": "This is the first and last practice question."
44
+ },
45
+ "CODE_QUESTION": {
46
+ "PRACTICE_INTRODUCTION": "The purpose of this question is to show you how coding tests work. You are not being scored for anything in this question.<br /><br /> Use this time to explore this practice question before your actual test begins.<br /><br /><strong>Do not close this window at any time.</strong> The countdown timer will keep running, and you will miss your test question if you close the window.<br /><br />Here are the instructions.",
47
+ "LANGUAGE_USING": "For this test you’re using",
48
+ "ADD_COMMENTS": "Feel free to add comments in your code explaining your solution."
49
+ },
50
+ "HEADINGS": {
51
+ "INSTRUCTIONS": "Instructions",
52
+ "CODING": "Coding Window",
53
+ "CONFIGURATIONS": "Configurations",
54
+ "FORMATTING": "Formatting",
55
+ "CODING_ASSISTANCE": "Coding Assistance",
56
+ "TESTS": "Tests"
57
+ },
58
+ "TOOLTIPS": {
59
+ "RESET_CODE": "Reset code",
60
+ "HELP": "Help",
61
+ "MAXIMISE": "Click to view code-runner in full-screen",
62
+ "MINIMIZE": "Minimize",
63
+ "CONFIGURATIONS": "Configurations",
64
+ "DISABLE_LANGUAGE": "The screening company only allows this programming language for this test",
65
+ "CANT_ADD_TEST_CASE": "You cannot add more than 6 of your own tests.",
66
+ "DELETE_TEST_CASE": "Remove test case"
67
+ },
68
+ "TEST_RESULTS": {
69
+ "PASSED": "Passed: ",
70
+ "ERROR": "Error: ",
71
+ "TOTAL": "Total: ",
72
+ "TEST_RUNNNING": "Running...",
73
+ "TESTS_CHECK": "Run tests to check your code",
74
+ "RUN_TESTS": "Run tests",
75
+ "TEST_CASES": {
76
+ "BOTH_FIELDS_MUST_BE_FILLED": "To run the test, both the input and expected output must be filled in.",
77
+ "EXAMPLE_TEST_CASE_INFO": "This is a test case example we recommend for this task. Run tests to get results.",
78
+ "FILL_ALL_FIELDS": "Fill in the input and expected output, and run tests to get results.",
79
+ "OUTPUT": "Output",
80
+ "LOG": "Log",
81
+ "INPUT": "Input",
82
+ "EXPECTED_OUTPUT": "Expected output",
83
+ "EXPECTED_QUERY": "Expected query result",
84
+ "QUERY_RESULT": "Query result",
85
+ "RESULT": "Result:",
86
+ "EXPECTED": "Expected:",
87
+ "TEST_VALIDATION": "Test Validation:",
88
+ "STATUSES": {
89
+ "PASSED": "Passed",
90
+ "ERROR": "Error",
91
+ "EMPTY": "Empty"
92
+ },
93
+ "NONE": "None",
94
+ "NO_RESPONSE": "No response",
95
+ "EXECUTED_SUCCESSFULLY": "Code executed successfully",
96
+ "SQL_EXECUTED_SUCCESSFULLY": "Task executed successfully",
97
+ "TIMEOUT_ERROR": "Timeout error, please review your code",
98
+ "ADD_TEST_CASE": "Add Test Case"
99
+ }
100
+ }
101
+ },
102
+ "TOUR": {
103
+ "STEP_1": {
104
+ "TITLE": "Practice question",
105
+ "MESSAGE": "Notice this is an example question that has been solved for you. The real test will start in the next page."
106
+ },
107
+ "STEP_2": {
108
+ "TITLE": "Programming language",
109
+ "MESSAGE": "You will be able to select the programming language of your choice, from the options your screening company has decided.<br />Your active selection when submitting the test is the one that will be considered."
110
+ },
111
+ "STEP_3": {
112
+ "TITLE": "Test cases",
113
+ "MESSAGE": "These are pairs of inputs and expected outputs. Press “Run tests” to test your function against them.<br />We encourage you to think of your own test cases, covering possible corner cases!"
114
+ },
115
+ "STEP_4": {
116
+ "TITLE": "Configurable IDE",
117
+ "MESSAGE": "Feel free to configure the IDE with settings of your choice: theme, font size, tab size, full screen, etc"
118
+ },
119
+ "STEP_5": {
120
+ "TITLE": "Start real test",
121
+ "MESSAGE": "When you’re ready, proceed to the actual test or wait until the timer ends. Good luck!"
122
+ }
123
+ }
124
+ }
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Public API Surface of coding-test
3
+ */
4
+
5
+ export { TgoCodingTestComponent } from './lib/components/tgo-coding-test/tgo-coding-test.component';
6
+ export { TgoCodingTestCandidateViewComponent } from './lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component';
7
+ // Note: CodingTestModule is kept internal for now and not exposed in the public API
8
+ // export * from './lib/components/coding-test.module';
9
+ export { Config as LibCodingConfig } from './lib/models/configs';
10
+ export {
11
+ CustomTestCase,
12
+ ExampleTestCase,
13
+ TestCaseResult,
14
+ TestCaseDeletionAction,
15
+ TestCaseDeletionData,
16
+ } from './lib/models/test-cases';
17
+ export { Themes } from './lib/models/theme';
18
+ export { ViewMode } from './lib/models/view-mode';
19
+ export { LATLanguage, LATLanguages } from './lib/models/lat-languages';
20
+ export { CodeEditorLanguages } from './lib/components/code-editor/helpers/code-editor-helper.model';
21
+ export { Modes } from './lib/models/mode';
22
+ export { LibCodingTestService, ResetCodeAction } from './lib/services/lib-coding-test.service';
23
+ export { StorageCodingService } from './lib/services/storage.service';
24
+ export { CodingTestConfigService } from './lib/services/coding-test-config.service';
25
+
26
+ // Configuration exports
27
+ export {
28
+ TgoCodingTestConfig,
29
+ provideTgoCodingTest,
30
+ } from './lib/config';
File without changes
@@ -0,0 +1,10 @@
1
+ <div class="container notranslate" translate="no">
2
+ <ngx-monaco-editor
3
+ #editor
4
+ class="editor"
5
+ [options]="editorOptions"
6
+ [(ngModel)]="code"
7
+ (ngModelChange)="publishCode($event)"
8
+ (onInit)="initEditor($event)"
9
+ ></ngx-monaco-editor>
10
+ </div>
@@ -0,0 +1,21 @@
1
+ :host {
2
+ display: block;
3
+ height: 100%;
4
+ max-width: 100%;
5
+ max-height: 100%;
6
+ }
7
+
8
+ .container {
9
+ height: 100%;
10
+ background-color: var(--code-editor-background);
11
+ }
12
+
13
+ .editor {
14
+ height: 100%;
15
+
16
+ ::ng-deep {
17
+ .copy-pasted-code {
18
+ background-color: yellow;
19
+ }
20
+ }
21
+ }