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.
- package/.claude/settings.local.json +42 -0
- package/.github/actions/ios-review/action.yml +106 -0
- package/.github/workflows/ci.yml +103 -0
- package/.github/workflows/publish.yml +57 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING.md +175 -0
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/bitrise/step.sh +128 -0
- package/bitrise/step.yml +101 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzers/asc-iap.d.ts.map +1 -0
- package/dist/analyzers/asc-metadata.d.ts.map +1 -0
- package/dist/analyzers/asc-screenshots.d.ts.map +1 -0
- package/dist/analyzers/asc-version.d.ts.map +1 -0
- package/dist/analyzers/code-scanner.d.ts.map +1 -0
- package/dist/analyzers/deprecated-api.d.ts.map +1 -0
- package/dist/analyzers/entitlements.d.ts.map +1 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/info-plist.d.ts.map +1 -0
- package/dist/analyzers/privacy.d.ts.map +1 -0
- package/dist/analyzers/private-api.d.ts.map +1 -0
- package/dist/analyzers/security.d.ts.map +1 -0
- package/dist/analyzers/ui-ux.d.ts.map +1 -0
- package/dist/asc/auth.d.ts.map +1 -0
- package/dist/asc/client.d.ts.map +1 -0
- package/dist/asc/endpoints/apps.d.ts.map +1 -0
- package/dist/asc/endpoints/iap.d.ts.map +1 -0
- package/dist/asc/endpoints/screenshots.d.ts.map +1 -0
- package/dist/asc/endpoints/versions.d.ts.map +1 -0
- package/dist/asc/errors.d.ts.map +1 -0
- package/dist/asc/index.d.ts.map +1 -0
- package/dist/asc/types.d.ts.map +1 -0
- package/dist/badge/generator.d.ts.map +1 -0
- package/dist/badge/index.d.ts.map +1 -0
- package/dist/badge/types.d.ts.map +1 -0
- package/dist/cache/file-cache.d.ts.map +1 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/version.d.ts.map +1 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/git/diff.d.ts.map +1 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/types.d.ts.map +1 -0
- package/dist/guidelines/database.d.ts.map +1 -0
- package/dist/guidelines/index.d.ts.map +1 -0
- package/dist/guidelines/matcher.d.ts.map +1 -0
- package/dist/guidelines/types.d.ts.map +1 -0
- package/dist/history/comparator.d.ts.map +1 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/store.d.ts.map +1 -0
- package/dist/history/types.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +994 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/plist.d.ts.map +1 -0
- package/dist/parsers/xcodeproj.d.ts.map +1 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/reporter.d.ts.map +1 -0
- package/dist/progress/types.d.ts.map +1 -0
- package/dist/reports/html.d.ts.map +1 -0
- package/dist/reports/index.d.ts.map +1 -0
- package/dist/reports/json.d.ts.map +1 -0
- package/dist/reports/markdown.d.ts.map +1 -0
- package/dist/reports/types.d.ts.map +1 -0
- package/dist/rules/engine.d.ts.map +1 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/loader.d.ts.map +1 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/docs/ANALYZERS.md +237 -0
- package/docs/API.md +308 -0
- package/docs/BADGES.md +130 -0
- package/docs/CI_CD.md +283 -0
- package/docs/CLI.md +140 -0
- package/docs/REPORTS.md +212 -0
- package/docs/ROADMAP.md +267 -0
- package/docs/RULES.md +182 -0
- package/docs/SECURITY.md +89 -0
- package/docs/TROUBLESHOOTING.md +227 -0
- package/docs/tutorials/ASC_SETUP.md +188 -0
- package/docs/tutorials/CI_INTEGRATION.md +292 -0
- package/docs/tutorials/CUSTOM_RULES.md +291 -0
- package/docs/tutorials/GETTING_STARTED.md +226 -0
- package/docs/video-scripts/01-introduction.md +106 -0
- package/docs/video-scripts/02-cli-usage.md +120 -0
- package/docs/video-scripts/03-ci-integration.md +198 -0
- package/eslint.config.js +33 -0
- package/examples/.ios-review-rules.json +82 -0
- package/examples/bitrise-workflow.yml +129 -0
- package/examples/fastlane-lane.rb +71 -0
- package/examples/github-action.yml +147 -0
- package/fastlane/Fastfile.example +114 -0
- package/fastlane/README.md +99 -0
- package/jest.config.js +36 -0
- package/package.json +65 -0
- package/scripts/benchmark.ts +112 -0
- package/scripts/debug-parser.ts +37 -0
- package/scripts/debug-pbxproj.ts +36 -0
- package/scripts/debug-specific.ts +47 -0
- package/scripts/test-analyze.ts +67 -0
- package/scripts/xcode-cloud-review.sh +167 -0
- package/src/analyzer.ts +227 -0
- package/src/analyzers/asc-iap.ts +300 -0
- package/src/analyzers/asc-metadata.ts +326 -0
- package/src/analyzers/asc-screenshots.ts +310 -0
- package/src/analyzers/asc-version.ts +368 -0
- package/src/analyzers/code-scanner.ts +408 -0
- package/src/analyzers/deprecated-api.ts +390 -0
- package/src/analyzers/entitlements.ts +345 -0
- package/src/analyzers/index.ts +12 -0
- package/src/analyzers/info-plist.ts +409 -0
- package/src/analyzers/privacy.ts +376 -0
- package/src/analyzers/private-api.ts +377 -0
- package/src/analyzers/security.ts +327 -0
- package/src/analyzers/ui-ux.ts +509 -0
- package/src/asc/auth.ts +204 -0
- package/src/asc/client.ts +258 -0
- package/src/asc/endpoints/apps.ts +115 -0
- package/src/asc/endpoints/iap.ts +171 -0
- package/src/asc/endpoints/screenshots.ts +164 -0
- package/src/asc/endpoints/versions.ts +174 -0
- package/src/asc/errors.ts +109 -0
- package/src/asc/index.ts +108 -0
- package/src/asc/types.ts +369 -0
- package/src/badge/generator.ts +48 -0
- package/src/badge/index.ts +2 -0
- package/src/badge/types.ts +5 -0
- package/src/cache/file-cache.ts +75 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/types.ts +10 -0
- package/src/cli/commands/help.ts +41 -0
- package/src/cli/commands/scan.ts +44 -0
- package/src/cli/commands/version.ts +12 -0
- package/src/cli/index.ts +92 -0
- package/src/cli/types.ts +17 -0
- package/src/git/diff.ts +21 -0
- package/src/git/index.ts +2 -0
- package/src/git/types.ts +5 -0
- package/src/guidelines/database.ts +344 -0
- package/src/guidelines/index.ts +4 -0
- package/src/guidelines/matcher.ts +84 -0
- package/src/guidelines/types.ts +28 -0
- package/src/history/comparator.ts +114 -0
- package/src/history/index.ts +3 -0
- package/src/history/store.ts +135 -0
- package/src/history/types.ts +40 -0
- package/src/index.ts +1113 -0
- package/src/parsers/index.ts +3 -0
- package/src/parsers/plist.ts +253 -0
- package/src/parsers/xcodeproj.ts +265 -0
- package/src/progress/index.ts +2 -0
- package/src/progress/reporter.ts +65 -0
- package/src/progress/types.ts +9 -0
- package/src/reports/html.ts +322 -0
- package/src/reports/index.ts +20 -0
- package/src/reports/json.ts +92 -0
- package/src/reports/markdown.ts +187 -0
- package/src/reports/types.ts +26 -0
- package/src/rules/engine.ts +121 -0
- package/src/rules/index.ts +3 -0
- package/src/rules/loader.ts +83 -0
- package/src/rules/types.ts +25 -0
- package/src/types/index.ts +247 -0
- package/tests/analyzer.test.ts +142 -0
- package/tests/analyzers/asc-iap.test.ts +228 -0
- package/tests/analyzers/asc-metadata.test.ts +210 -0
- package/tests/analyzers/asc-screenshots.test.ts +135 -0
- package/tests/analyzers/asc-version.test.ts +259 -0
- package/tests/analyzers/code-scanner.test.ts +745 -0
- package/tests/analyzers/deprecated-api.test.ts +286 -0
- package/tests/analyzers/entitlements.test.ts +411 -0
- package/tests/analyzers/info-plist.test.ts +148 -0
- package/tests/analyzers/privacy.test.ts +623 -0
- package/tests/analyzers/private-api.test.ts +255 -0
- package/tests/analyzers/security.test.ts +300 -0
- package/tests/analyzers/ui-ux.test.ts +357 -0
- package/tests/asc/auth.test.ts +189 -0
- package/tests/asc/client.test.ts +207 -0
- package/tests/asc/endpoints.test.ts +1359 -0
- package/tests/badge/generator.test.ts +73 -0
- package/tests/cache/file-cache.test.ts +124 -0
- package/tests/cli/cli-index.test.ts +510 -0
- package/tests/cli/commands.test.ts +67 -0
- package/tests/cli/scan.test.ts +152 -0
- package/tests/git/diff.test.ts +69 -0
- package/tests/guidelines/matcher.test.ts +209 -0
- package/tests/history/comparator.test.ts +272 -0
- package/tests/history/store.test.ts +200 -0
- package/tests/integration/cli.test.ts +95 -0
- package/tests/integration/e2e.test.ts +130 -0
- package/tests/parsers/plist.test.ts +240 -0
- package/tests/parsers/xcodeproj.test.ts +289 -0
- package/tests/progress/reporter.test.ts +117 -0
- package/tests/reports/html.test.ts +176 -0
- package/tests/reports/json.test.ts +235 -0
- package/tests/reports/markdown.test.ts +196 -0
- package/tests/rules/engine.test.ts +229 -0
- package/tests/rules/loader.test.ts +187 -0
- package/tests/setup.ts +15 -0
- package/tsconfig.json +27 -0
- 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
|
+
});
|