ios-app-review-plugin 1.0.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 (205) hide show
  1. package/.claude/settings.local.json +42 -0
  2. package/.github/actions/ios-review/action.yml +106 -0
  3. package/.github/workflows/ci.yml +103 -0
  4. package/.github/workflows/publish.yml +57 -0
  5. package/CHANGELOG.md +66 -0
  6. package/CONTRIBUTING.md +175 -0
  7. package/LICENSE +21 -0
  8. package/README.md +205 -0
  9. package/bitrise/step.sh +128 -0
  10. package/bitrise/step.yml +101 -0
  11. package/dist/analyzer.d.ts.map +1 -0
  12. package/dist/analyzers/asc-iap.d.ts.map +1 -0
  13. package/dist/analyzers/asc-metadata.d.ts.map +1 -0
  14. package/dist/analyzers/asc-screenshots.d.ts.map +1 -0
  15. package/dist/analyzers/asc-version.d.ts.map +1 -0
  16. package/dist/analyzers/code-scanner.d.ts.map +1 -0
  17. package/dist/analyzers/deprecated-api.d.ts.map +1 -0
  18. package/dist/analyzers/entitlements.d.ts.map +1 -0
  19. package/dist/analyzers/index.d.ts.map +1 -0
  20. package/dist/analyzers/info-plist.d.ts.map +1 -0
  21. package/dist/analyzers/privacy.d.ts.map +1 -0
  22. package/dist/analyzers/private-api.d.ts.map +1 -0
  23. package/dist/analyzers/security.d.ts.map +1 -0
  24. package/dist/analyzers/ui-ux.d.ts.map +1 -0
  25. package/dist/asc/auth.d.ts.map +1 -0
  26. package/dist/asc/client.d.ts.map +1 -0
  27. package/dist/asc/endpoints/apps.d.ts.map +1 -0
  28. package/dist/asc/endpoints/iap.d.ts.map +1 -0
  29. package/dist/asc/endpoints/screenshots.d.ts.map +1 -0
  30. package/dist/asc/endpoints/versions.d.ts.map +1 -0
  31. package/dist/asc/errors.d.ts.map +1 -0
  32. package/dist/asc/index.d.ts.map +1 -0
  33. package/dist/asc/types.d.ts.map +1 -0
  34. package/dist/badge/generator.d.ts.map +1 -0
  35. package/dist/badge/index.d.ts.map +1 -0
  36. package/dist/badge/types.d.ts.map +1 -0
  37. package/dist/cache/file-cache.d.ts.map +1 -0
  38. package/dist/cache/index.d.ts.map +1 -0
  39. package/dist/cache/types.d.ts.map +1 -0
  40. package/dist/cli/commands/help.d.ts.map +1 -0
  41. package/dist/cli/commands/scan.d.ts.map +1 -0
  42. package/dist/cli/commands/version.d.ts.map +1 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/types.d.ts.map +1 -0
  45. package/dist/git/diff.d.ts.map +1 -0
  46. package/dist/git/index.d.ts.map +1 -0
  47. package/dist/git/types.d.ts.map +1 -0
  48. package/dist/guidelines/database.d.ts.map +1 -0
  49. package/dist/guidelines/index.d.ts.map +1 -0
  50. package/dist/guidelines/matcher.d.ts.map +1 -0
  51. package/dist/guidelines/types.d.ts.map +1 -0
  52. package/dist/history/comparator.d.ts.map +1 -0
  53. package/dist/history/index.d.ts.map +1 -0
  54. package/dist/history/store.d.ts.map +1 -0
  55. package/dist/history/types.d.ts.map +1 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +994 -0
  58. package/dist/parsers/index.d.ts.map +1 -0
  59. package/dist/parsers/plist.d.ts.map +1 -0
  60. package/dist/parsers/xcodeproj.d.ts.map +1 -0
  61. package/dist/progress/index.d.ts.map +1 -0
  62. package/dist/progress/reporter.d.ts.map +1 -0
  63. package/dist/progress/types.d.ts.map +1 -0
  64. package/dist/reports/html.d.ts.map +1 -0
  65. package/dist/reports/index.d.ts.map +1 -0
  66. package/dist/reports/json.d.ts.map +1 -0
  67. package/dist/reports/markdown.d.ts.map +1 -0
  68. package/dist/reports/types.d.ts.map +1 -0
  69. package/dist/rules/engine.d.ts.map +1 -0
  70. package/dist/rules/index.d.ts.map +1 -0
  71. package/dist/rules/loader.d.ts.map +1 -0
  72. package/dist/rules/types.d.ts.map +1 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/docs/ANALYZERS.md +237 -0
  75. package/docs/API.md +308 -0
  76. package/docs/BADGES.md +130 -0
  77. package/docs/CI_CD.md +283 -0
  78. package/docs/CLI.md +140 -0
  79. package/docs/REPORTS.md +212 -0
  80. package/docs/ROADMAP.md +267 -0
  81. package/docs/RULES.md +182 -0
  82. package/docs/SECURITY.md +89 -0
  83. package/docs/TROUBLESHOOTING.md +227 -0
  84. package/docs/tutorials/ASC_SETUP.md +188 -0
  85. package/docs/tutorials/CI_INTEGRATION.md +292 -0
  86. package/docs/tutorials/CUSTOM_RULES.md +291 -0
  87. package/docs/tutorials/GETTING_STARTED.md +226 -0
  88. package/docs/video-scripts/01-introduction.md +106 -0
  89. package/docs/video-scripts/02-cli-usage.md +120 -0
  90. package/docs/video-scripts/03-ci-integration.md +198 -0
  91. package/eslint.config.js +33 -0
  92. package/examples/.ios-review-rules.json +82 -0
  93. package/examples/bitrise-workflow.yml +129 -0
  94. package/examples/fastlane-lane.rb +71 -0
  95. package/examples/github-action.yml +147 -0
  96. package/fastlane/Fastfile.example +114 -0
  97. package/fastlane/README.md +99 -0
  98. package/jest.config.js +36 -0
  99. package/package.json +65 -0
  100. package/scripts/benchmark.ts +112 -0
  101. package/scripts/debug-parser.ts +37 -0
  102. package/scripts/debug-pbxproj.ts +36 -0
  103. package/scripts/debug-specific.ts +47 -0
  104. package/scripts/test-analyze.ts +67 -0
  105. package/scripts/xcode-cloud-review.sh +167 -0
  106. package/src/analyzer.ts +227 -0
  107. package/src/analyzers/asc-iap.ts +300 -0
  108. package/src/analyzers/asc-metadata.ts +326 -0
  109. package/src/analyzers/asc-screenshots.ts +310 -0
  110. package/src/analyzers/asc-version.ts +368 -0
  111. package/src/analyzers/code-scanner.ts +408 -0
  112. package/src/analyzers/deprecated-api.ts +390 -0
  113. package/src/analyzers/entitlements.ts +345 -0
  114. package/src/analyzers/index.ts +12 -0
  115. package/src/analyzers/info-plist.ts +409 -0
  116. package/src/analyzers/privacy.ts +376 -0
  117. package/src/analyzers/private-api.ts +377 -0
  118. package/src/analyzers/security.ts +327 -0
  119. package/src/analyzers/ui-ux.ts +509 -0
  120. package/src/asc/auth.ts +204 -0
  121. package/src/asc/client.ts +258 -0
  122. package/src/asc/endpoints/apps.ts +115 -0
  123. package/src/asc/endpoints/iap.ts +171 -0
  124. package/src/asc/endpoints/screenshots.ts +164 -0
  125. package/src/asc/endpoints/versions.ts +174 -0
  126. package/src/asc/errors.ts +109 -0
  127. package/src/asc/index.ts +108 -0
  128. package/src/asc/types.ts +369 -0
  129. package/src/badge/generator.ts +48 -0
  130. package/src/badge/index.ts +2 -0
  131. package/src/badge/types.ts +5 -0
  132. package/src/cache/file-cache.ts +75 -0
  133. package/src/cache/index.ts +2 -0
  134. package/src/cache/types.ts +10 -0
  135. package/src/cli/commands/help.ts +41 -0
  136. package/src/cli/commands/scan.ts +44 -0
  137. package/src/cli/commands/version.ts +12 -0
  138. package/src/cli/index.ts +92 -0
  139. package/src/cli/types.ts +17 -0
  140. package/src/git/diff.ts +21 -0
  141. package/src/git/index.ts +2 -0
  142. package/src/git/types.ts +5 -0
  143. package/src/guidelines/database.ts +344 -0
  144. package/src/guidelines/index.ts +4 -0
  145. package/src/guidelines/matcher.ts +84 -0
  146. package/src/guidelines/types.ts +28 -0
  147. package/src/history/comparator.ts +114 -0
  148. package/src/history/index.ts +3 -0
  149. package/src/history/store.ts +135 -0
  150. package/src/history/types.ts +40 -0
  151. package/src/index.ts +1113 -0
  152. package/src/parsers/index.ts +3 -0
  153. package/src/parsers/plist.ts +253 -0
  154. package/src/parsers/xcodeproj.ts +265 -0
  155. package/src/progress/index.ts +2 -0
  156. package/src/progress/reporter.ts +65 -0
  157. package/src/progress/types.ts +9 -0
  158. package/src/reports/html.ts +322 -0
  159. package/src/reports/index.ts +20 -0
  160. package/src/reports/json.ts +92 -0
  161. package/src/reports/markdown.ts +187 -0
  162. package/src/reports/types.ts +26 -0
  163. package/src/rules/engine.ts +121 -0
  164. package/src/rules/index.ts +3 -0
  165. package/src/rules/loader.ts +83 -0
  166. package/src/rules/types.ts +25 -0
  167. package/src/types/index.ts +247 -0
  168. package/tests/analyzer.test.ts +142 -0
  169. package/tests/analyzers/asc-iap.test.ts +228 -0
  170. package/tests/analyzers/asc-metadata.test.ts +210 -0
  171. package/tests/analyzers/asc-screenshots.test.ts +135 -0
  172. package/tests/analyzers/asc-version.test.ts +259 -0
  173. package/tests/analyzers/code-scanner.test.ts +745 -0
  174. package/tests/analyzers/deprecated-api.test.ts +286 -0
  175. package/tests/analyzers/entitlements.test.ts +411 -0
  176. package/tests/analyzers/info-plist.test.ts +148 -0
  177. package/tests/analyzers/privacy.test.ts +623 -0
  178. package/tests/analyzers/private-api.test.ts +255 -0
  179. package/tests/analyzers/security.test.ts +300 -0
  180. package/tests/analyzers/ui-ux.test.ts +357 -0
  181. package/tests/asc/auth.test.ts +189 -0
  182. package/tests/asc/client.test.ts +207 -0
  183. package/tests/asc/endpoints.test.ts +1359 -0
  184. package/tests/badge/generator.test.ts +73 -0
  185. package/tests/cache/file-cache.test.ts +124 -0
  186. package/tests/cli/cli-index.test.ts +510 -0
  187. package/tests/cli/commands.test.ts +67 -0
  188. package/tests/cli/scan.test.ts +152 -0
  189. package/tests/git/diff.test.ts +69 -0
  190. package/tests/guidelines/matcher.test.ts +209 -0
  191. package/tests/history/comparator.test.ts +272 -0
  192. package/tests/history/store.test.ts +200 -0
  193. package/tests/integration/cli.test.ts +95 -0
  194. package/tests/integration/e2e.test.ts +130 -0
  195. package/tests/parsers/plist.test.ts +240 -0
  196. package/tests/parsers/xcodeproj.test.ts +289 -0
  197. package/tests/progress/reporter.test.ts +117 -0
  198. package/tests/reports/html.test.ts +176 -0
  199. package/tests/reports/json.test.ts +235 -0
  200. package/tests/reports/markdown.test.ts +196 -0
  201. package/tests/rules/engine.test.ts +229 -0
  202. package/tests/rules/loader.test.ts +187 -0
  203. package/tests/setup.ts +15 -0
  204. package/tsconfig.json +27 -0
  205. package/tsconfig.test.json +9 -0
@@ -0,0 +1,228 @@
1
+ import { ASCIAPAnalyzer } from '../../src/analyzers/asc-iap';
2
+ import type { XcodeProject } from '../../src/types/index';
3
+
4
+ // Mock the ASC module
5
+ jest.mock('../../src/asc/index', () => ({
6
+ hasCredentials: jest.fn(),
7
+ getAppByBundleId: jest.fn(),
8
+ validateAllIAPs: jest.fn(),
9
+ getIAPStateDescription: jest.fn().mockReturnValue('Missing Metadata'),
10
+ isASCError: jest.fn().mockReturnValue(false),
11
+ }));
12
+
13
+ const mocks = jest.requireMock('../../src/asc/index');
14
+
15
+ const mockProject: XcodeProject = {
16
+ path: '/test/TestApp.xcodeproj',
17
+ name: 'TestApp',
18
+ targets: [
19
+ {
20
+ name: 'TestApp',
21
+ type: 'application',
22
+ bundleIdentifier: 'com.test.app',
23
+ sourceFiles: [],
24
+ },
25
+ ],
26
+ configurations: ['Debug', 'Release'],
27
+ };
28
+
29
+ describe('ASCIAPAnalyzer', () => {
30
+ let analyzer: ASCIAPAnalyzer;
31
+
32
+ beforeEach(() => {
33
+ analyzer = new ASCIAPAnalyzer();
34
+ jest.clearAllMocks();
35
+ });
36
+
37
+ describe('analyze', () => {
38
+ it('should return info issue when credentials are not configured', async () => {
39
+ mocks.hasCredentials.mockReturnValue(false);
40
+
41
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
42
+
43
+ expect(result.passed).toBe(true);
44
+ expect(result.issues).toHaveLength(1);
45
+ expect(result.issues[0]?.id).toBe('asc-credentials-not-configured');
46
+ expect(result.issues[0]?.severity).toBe('info');
47
+ });
48
+
49
+ it('should return warning when no bundle ID found', async () => {
50
+ mocks.hasCredentials.mockReturnValue(true);
51
+
52
+ const projectWithoutBundleId: XcodeProject = {
53
+ ...mockProject,
54
+ targets: [{ name: 'TestApp', type: 'application', sourceFiles: [] }],
55
+ };
56
+
57
+ const result = await analyzer.analyze(projectWithoutBundleId, { basePath: '/test' });
58
+
59
+ expect(result.passed).toBe(true);
60
+ expect(result.issues[0]?.id).toBe('asc-no-bundle-id');
61
+ });
62
+
63
+ it('should return info when no IAPs configured', async () => {
64
+ mocks.hasCredentials.mockReturnValue(true);
65
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
66
+ mocks.validateAllIAPs.mockResolvedValue([]);
67
+
68
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
69
+
70
+ expect(result.issues.some((i) => i.id === 'asc-no-iaps')).toBe(true);
71
+ });
72
+
73
+ it('should detect IAP with missing metadata', async () => {
74
+ mocks.hasCredentials.mockReturnValue(true);
75
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
76
+ mocks.validateAllIAPs.mockResolvedValue([
77
+ {
78
+ iap: {
79
+ id: 'iap-1',
80
+ type: 'inAppPurchases',
81
+ attributes: {
82
+ name: 'Premium Feature',
83
+ productId: 'com.test.premium',
84
+ inAppPurchaseType: 'NON_CONSUMABLE',
85
+ state: 'MISSING_METADATA',
86
+ },
87
+ },
88
+ localizations: [],
89
+ reviewScreenshot: undefined,
90
+ isReadyForSubmission: false,
91
+ },
92
+ ]);
93
+
94
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
95
+
96
+ expect(result.passed).toBe(false);
97
+ expect(result.issues.some((i) => i.id === 'asc-iap-missing-metadata')).toBe(true);
98
+ expect(result.issues.some((i) => i.id === 'asc-iap-no-localizations')).toBe(true);
99
+ expect(result.issues.some((i) => i.id === 'asc-iap-missing-screenshot')).toBe(true);
100
+ });
101
+
102
+ it('should detect IAP with missing review screenshot', async () => {
103
+ mocks.hasCredentials.mockReturnValue(true);
104
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
105
+ mocks.validateAllIAPs.mockResolvedValue([
106
+ {
107
+ iap: {
108
+ id: 'iap-1',
109
+ type: 'inAppPurchases',
110
+ attributes: {
111
+ name: 'Premium Feature',
112
+ productId: 'com.test.premium',
113
+ inAppPurchaseType: 'CONSUMABLE',
114
+ state: 'READY_TO_SUBMIT',
115
+ },
116
+ },
117
+ localizations: [
118
+ {
119
+ id: 'loc-1',
120
+ type: 'inAppPurchaseLocalizations',
121
+ attributes: { locale: 'en-US', name: 'Premium', description: 'Unlock premium' },
122
+ },
123
+ ],
124
+ reviewScreenshot: undefined,
125
+ isReadyForSubmission: false,
126
+ },
127
+ ]);
128
+
129
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
130
+
131
+ expect(result.issues.some((i) => i.id === 'asc-iap-missing-screenshot')).toBe(true);
132
+ });
133
+
134
+ it('should pass with fully configured IAP', async () => {
135
+ mocks.hasCredentials.mockReturnValue(true);
136
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
137
+ mocks.validateAllIAPs.mockResolvedValue([
138
+ {
139
+ iap: {
140
+ id: 'iap-1',
141
+ type: 'inAppPurchases',
142
+ attributes: {
143
+ name: 'Premium Feature',
144
+ productId: 'com.test.premium',
145
+ inAppPurchaseType: 'NON_CONSUMABLE',
146
+ state: 'READY_TO_SUBMIT',
147
+ },
148
+ },
149
+ localizations: [
150
+ {
151
+ id: 'loc-1',
152
+ type: 'inAppPurchaseLocalizations',
153
+ attributes: { locale: 'en-US', name: 'Premium', description: 'Unlock premium features' },
154
+ },
155
+ ],
156
+ reviewScreenshot: {
157
+ id: 'ss-1',
158
+ type: 'inAppPurchaseAppStoreReviewScreenshots',
159
+ attributes: { fileName: 'screenshot.png', assetDeliveryState: { state: 'COMPLETE' } },
160
+ },
161
+ isReadyForSubmission: true,
162
+ },
163
+ ]);
164
+
165
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
166
+
167
+ expect(result.passed).toBe(true);
168
+ });
169
+ });
170
+
171
+ describe('validateByBundleId', () => {
172
+ it('should return error when credentials not configured', async () => {
173
+ mocks.hasCredentials.mockReturnValue(false);
174
+
175
+ const result = await analyzer.validateByBundleId('com.test.app');
176
+
177
+ expect(result.passed).toBe(false);
178
+ expect(result.issues[0]?.severity).toBe('error');
179
+ });
180
+
181
+ it('should validate IAPs for given bundle ID', async () => {
182
+ mocks.hasCredentials.mockReturnValue(true);
183
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
184
+ mocks.validateAllIAPs.mockResolvedValue([]);
185
+
186
+ const result = await analyzer.validateByBundleId('com.test.app');
187
+
188
+ expect(result.analyzer).toBe('ASC IAP Analyzer');
189
+ expect(result.issues.some((i) => i.id === 'asc-no-iaps')).toBe(true);
190
+ });
191
+
192
+ it('should detect rejected IAP', async () => {
193
+ mocks.hasCredentials.mockReturnValue(true);
194
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
195
+ mocks.validateAllIAPs.mockResolvedValue([
196
+ {
197
+ iap: {
198
+ id: 'iap-1',
199
+ type: 'inAppPurchases',
200
+ attributes: {
201
+ name: 'Premium',
202
+ productId: 'com.test.premium',
203
+ inAppPurchaseType: 'NON_CONSUMABLE',
204
+ state: 'REJECTED',
205
+ },
206
+ },
207
+ localizations: [
208
+ {
209
+ id: 'loc-1',
210
+ type: 'inAppPurchaseLocalizations',
211
+ attributes: { locale: 'en-US', name: 'Premium', description: 'Desc' },
212
+ },
213
+ ],
214
+ reviewScreenshot: {
215
+ id: 'ss-1',
216
+ type: 'inAppPurchaseAppStoreReviewScreenshots',
217
+ attributes: { fileName: 'screenshot.png', assetDeliveryState: { state: 'COMPLETE' } },
218
+ },
219
+ isReadyForSubmission: false,
220
+ },
221
+ ]);
222
+
223
+ const result = await analyzer.validateByBundleId('com.test.app');
224
+
225
+ expect(result.issues.some((i) => i.id === 'asc-iap-rejected')).toBe(true);
226
+ });
227
+ });
228
+ });
@@ -0,0 +1,210 @@
1
+ import { ASCMetadataAnalyzer } from '../../src/analyzers/asc-metadata';
2
+ import type { XcodeProject } from '../../src/types/index';
3
+
4
+ // Mock the ASC module
5
+ jest.mock('../../src/asc/index', () => ({
6
+ hasCredentials: jest.fn(),
7
+ getAppWithInfo: jest.fn(),
8
+ isASCError: jest.fn().mockReturnValue(false),
9
+ }));
10
+
11
+ const mockHasCredentials = jest.requireMock('../../src/asc/index').hasCredentials as jest.Mock;
12
+ const mockGetAppWithInfo = jest.requireMock('../../src/asc/index').getAppWithInfo as jest.Mock;
13
+
14
+ const mockProject: XcodeProject = {
15
+ path: '/test/TestApp.xcodeproj',
16
+ name: 'TestApp',
17
+ targets: [
18
+ {
19
+ name: 'TestApp',
20
+ type: 'application',
21
+ bundleIdentifier: 'com.test.app',
22
+ sourceFiles: [],
23
+ },
24
+ ],
25
+ configurations: ['Debug', 'Release'],
26
+ };
27
+
28
+ describe('ASCMetadataAnalyzer', () => {
29
+ let analyzer: ASCMetadataAnalyzer;
30
+
31
+ beforeEach(() => {
32
+ analyzer = new ASCMetadataAnalyzer();
33
+ jest.clearAllMocks();
34
+ });
35
+
36
+ describe('analyze', () => {
37
+ it('should return info issue when credentials are not configured', async () => {
38
+ mockHasCredentials.mockReturnValue(false);
39
+
40
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
41
+
42
+ expect(result.passed).toBe(true);
43
+ expect(result.issues).toHaveLength(1);
44
+ expect(result.issues[0]?.id).toBe('asc-credentials-not-configured');
45
+ expect(result.issues[0]?.severity).toBe('info');
46
+ });
47
+
48
+ it('should return warning when no bundle ID found', async () => {
49
+ mockHasCredentials.mockReturnValue(true);
50
+
51
+ const projectWithoutBundleId: XcodeProject = {
52
+ ...mockProject,
53
+ targets: [{ name: 'TestApp', type: 'application', sourceFiles: [] }],
54
+ };
55
+
56
+ const result = await analyzer.analyze(projectWithoutBundleId, { basePath: '/test' });
57
+
58
+ expect(result.passed).toBe(true);
59
+ expect(result.issues).toHaveLength(1);
60
+ expect(result.issues[0]?.id).toBe('asc-no-bundle-id');
61
+ expect(result.issues[0]?.severity).toBe('warning');
62
+ });
63
+
64
+ it('should validate metadata when credentials are configured', async () => {
65
+ mockHasCredentials.mockReturnValue(true);
66
+ mockGetAppWithInfo.mockResolvedValue({
67
+ app: {
68
+ id: '123',
69
+ type: 'apps',
70
+ attributes: { name: 'TestApp', bundleId: 'com.test.app', primaryLocale: 'en-US' },
71
+ },
72
+ localizations: [
73
+ {
74
+ id: 'loc-1',
75
+ type: 'appInfoLocalizations',
76
+ attributes: {
77
+ locale: 'en-US',
78
+ name: 'TestApp',
79
+ subtitle: 'A great app',
80
+ privacyPolicyUrl: 'https://example.com/privacy',
81
+ },
82
+ },
83
+ ],
84
+ });
85
+
86
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
87
+
88
+ expect(result.passed).toBe(true);
89
+ });
90
+
91
+ it('should detect app name too long', async () => {
92
+ mockHasCredentials.mockReturnValue(true);
93
+ mockGetAppWithInfo.mockResolvedValue({
94
+ app: {
95
+ id: '123',
96
+ type: 'apps',
97
+ attributes: { name: 'TestApp', bundleId: 'com.test.app', primaryLocale: 'en-US' },
98
+ },
99
+ localizations: [
100
+ {
101
+ id: 'loc-1',
102
+ type: 'appInfoLocalizations',
103
+ attributes: {
104
+ locale: 'en-US',
105
+ name: 'This App Name Is Way Too Long For The App Store Limit',
106
+ subtitle: null,
107
+ privacyPolicyUrl: 'https://example.com/privacy',
108
+ },
109
+ },
110
+ ],
111
+ });
112
+
113
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
114
+
115
+ expect(result.issues.some((i) => i.id === 'asc-name-too-long')).toBe(true);
116
+ });
117
+
118
+ it('should detect missing privacy policy URL', async () => {
119
+ mockHasCredentials.mockReturnValue(true);
120
+ mockGetAppWithInfo.mockResolvedValue({
121
+ app: {
122
+ id: '123',
123
+ type: 'apps',
124
+ attributes: { name: 'TestApp', bundleId: 'com.test.app', primaryLocale: 'en-US' },
125
+ },
126
+ localizations: [
127
+ {
128
+ id: 'loc-1',
129
+ type: 'appInfoLocalizations',
130
+ attributes: {
131
+ locale: 'en-US',
132
+ name: 'TestApp',
133
+ subtitle: null,
134
+ privacyPolicyUrl: null,
135
+ },
136
+ },
137
+ ],
138
+ });
139
+
140
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
141
+
142
+ expect(result.issues.some((i) => i.id === 'asc-missing-privacy-policy')).toBe(true);
143
+ });
144
+
145
+ it('should detect placeholder text', async () => {
146
+ mockHasCredentials.mockReturnValue(true);
147
+ mockGetAppWithInfo.mockResolvedValue({
148
+ app: {
149
+ id: '123',
150
+ type: 'apps',
151
+ attributes: { name: 'TestApp', bundleId: 'com.test.app', primaryLocale: 'en-US' },
152
+ },
153
+ localizations: [
154
+ {
155
+ id: 'loc-1',
156
+ type: 'appInfoLocalizations',
157
+ attributes: {
158
+ locale: 'en-US',
159
+ name: 'Lorem ipsum dolor sit amet',
160
+ subtitle: null,
161
+ privacyPolicyUrl: 'https://example.com/privacy',
162
+ },
163
+ },
164
+ ],
165
+ });
166
+
167
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
168
+
169
+ expect(result.issues.some((i) => i.id === 'asc-name-placeholder')).toBe(true);
170
+ });
171
+ });
172
+
173
+ describe('validateByBundleId', () => {
174
+ it('should return error when credentials not configured', async () => {
175
+ mockHasCredentials.mockReturnValue(false);
176
+
177
+ const result = await analyzer.validateByBundleId('com.test.app');
178
+
179
+ expect(result.passed).toBe(false);
180
+ expect(result.issues[0]?.severity).toBe('error');
181
+ });
182
+
183
+ it('should validate metadata for valid bundle ID', async () => {
184
+ mockHasCredentials.mockReturnValue(true);
185
+ mockGetAppWithInfo.mockResolvedValue({
186
+ app: {
187
+ id: '123',
188
+ type: 'apps',
189
+ attributes: { name: 'TestApp', bundleId: 'com.test.app', primaryLocale: 'en-US' },
190
+ },
191
+ localizations: [
192
+ {
193
+ id: 'loc-1',
194
+ type: 'appInfoLocalizations',
195
+ attributes: {
196
+ locale: 'en-US',
197
+ name: 'TestApp',
198
+ subtitle: null,
199
+ privacyPolicyUrl: 'https://example.com/privacy',
200
+ },
201
+ },
202
+ ],
203
+ });
204
+
205
+ const result = await analyzer.validateByBundleId('com.test.app');
206
+
207
+ expect(result.passed).toBe(true);
208
+ });
209
+ });
210
+ });
@@ -0,0 +1,135 @@
1
+ import { ASCScreenshotAnalyzer } from '../../src/analyzers/asc-screenshots';
2
+ import type { XcodeProject } from '../../src/types/index';
3
+
4
+ // Mock the ASC module
5
+ jest.mock('../../src/asc/index', () => ({
6
+ hasCredentials: jest.fn(),
7
+ getAppByBundleId: jest.fn(),
8
+ getEditableVersion: jest.fn(),
9
+ getVersionLocalizations: jest.fn(),
10
+ getScreenshotSetsWithScreenshots: jest.fn(),
11
+ REQUIRED_IPHONE_DISPLAY_TYPES: ['APP_IPHONE_65', 'APP_IPHONE_55'],
12
+ REQUIRED_IPAD_DISPLAY_TYPES: ['APP_IPAD_PRO_129'],
13
+ getDisplayTypeDescription: jest.fn((type: string) => type),
14
+ validateScreenshotSet: jest.fn().mockReturnValue({ hasProcessingErrors: false, issues: [] }),
15
+ isASCError: jest.fn().mockReturnValue(false),
16
+ }));
17
+
18
+ const mocks = jest.requireMock('../../src/asc/index');
19
+
20
+ const mockProject: XcodeProject = {
21
+ path: '/test/TestApp.xcodeproj',
22
+ name: 'TestApp',
23
+ targets: [
24
+ {
25
+ name: 'TestApp',
26
+ type: 'application',
27
+ bundleIdentifier: 'com.test.app',
28
+ sourceFiles: [],
29
+ },
30
+ ],
31
+ configurations: ['Debug', 'Release'],
32
+ };
33
+
34
+ describe('ASCScreenshotAnalyzer', () => {
35
+ let analyzer: ASCScreenshotAnalyzer;
36
+
37
+ beforeEach(() => {
38
+ analyzer = new ASCScreenshotAnalyzer();
39
+ jest.clearAllMocks();
40
+ });
41
+
42
+ describe('analyze', () => {
43
+ it('should return info issue when credentials are not configured', async () => {
44
+ mocks.hasCredentials.mockReturnValue(false);
45
+
46
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
47
+
48
+ expect(result.passed).toBe(true);
49
+ expect(result.issues).toHaveLength(1);
50
+ expect(result.issues[0]?.id).toBe('asc-credentials-not-configured');
51
+ expect(result.issues[0]?.severity).toBe('info');
52
+ });
53
+
54
+ it('should return warning when no bundle ID found', async () => {
55
+ mocks.hasCredentials.mockReturnValue(true);
56
+
57
+ const projectWithoutBundleId: XcodeProject = {
58
+ ...mockProject,
59
+ targets: [{ name: 'TestApp', type: 'application', sourceFiles: [] }],
60
+ };
61
+
62
+ const result = await analyzer.analyze(projectWithoutBundleId, { basePath: '/test' });
63
+
64
+ expect(result.passed).toBe(true);
65
+ expect(result.issues).toHaveLength(1);
66
+ expect(result.issues[0]?.id).toBe('asc-no-bundle-id');
67
+ });
68
+
69
+ it('should return info when no editable version found', async () => {
70
+ mocks.hasCredentials.mockReturnValue(true);
71
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
72
+ mocks.getEditableVersion.mockResolvedValue(null);
73
+
74
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
75
+
76
+ expect(result.issues.some((i: { id: string }) => i.id === 'asc-no-editable-version')).toBe(true);
77
+ });
78
+
79
+ it('should validate screenshots when version exists', async () => {
80
+ mocks.hasCredentials.mockReturnValue(true);
81
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
82
+ mocks.getEditableVersion.mockResolvedValue({
83
+ id: 'ver-1',
84
+ type: 'appStoreVersions',
85
+ attributes: { versionString: '1.0.0', appStoreState: 'PREPARE_FOR_SUBMISSION' },
86
+ });
87
+ mocks.getVersionLocalizations.mockResolvedValue([
88
+ {
89
+ id: 'loc-1',
90
+ type: 'appStoreVersionLocalizations',
91
+ attributes: { locale: 'en-US' },
92
+ },
93
+ ]);
94
+ mocks.getScreenshotSetsWithScreenshots.mockResolvedValue([
95
+ {
96
+ set: {
97
+ id: 'set-1',
98
+ type: 'appScreenshotSets',
99
+ attributes: { screenshotDisplayType: 'APP_IPHONE_65' },
100
+ },
101
+ screenshots: [
102
+ { id: 'ss-1', type: 'appScreenshots', attributes: { fileName: 'test.png', assetDeliveryState: { state: 'COMPLETE' } } },
103
+ ],
104
+ },
105
+ ]);
106
+
107
+ const result = await analyzer.analyze(mockProject, { basePath: '/test' });
108
+
109
+ // Should have some issues (missing some device sizes) but not error
110
+ expect(result.analyzer).toBe('ASC Screenshot Analyzer');
111
+ });
112
+ });
113
+
114
+ describe('validateByBundleId', () => {
115
+ it('should return error when credentials not configured', async () => {
116
+ mocks.hasCredentials.mockReturnValue(false);
117
+
118
+ const result = await analyzer.validateByBundleId('com.test.app');
119
+
120
+ expect(result.passed).toBe(false);
121
+ expect(result.issues[0]?.severity).toBe('error');
122
+ });
123
+
124
+ it('should validate screenshots for given bundle ID', async () => {
125
+ mocks.hasCredentials.mockReturnValue(true);
126
+ mocks.getAppByBundleId.mockResolvedValue({ id: 'app-1', type: 'apps' });
127
+ mocks.getEditableVersion.mockResolvedValue(null);
128
+
129
+ const result = await analyzer.validateByBundleId('com.test.app');
130
+
131
+ expect(result.analyzer).toBe('ASC Screenshot Analyzer');
132
+ expect(result.issues.some((i: { id: string }) => i.id === 'asc-no-editable-version')).toBe(true);
133
+ });
134
+ });
135
+ });