sentryRemoval.test.mjs
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import assert from 'node:assert/strict';
import { existsSync, readFileSync, statSync } from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const readProjectFile = (relativePath) =>
readFileSync(path.join(projectRoot, relativePath), 'utf8');
test('main package and AI failure paths do not ship Sentry references', () => {
for (const relativePath of [
'app.js',
'config.js',
'packageEquityAI/pages/aiCheck/chat/chat.js',
'packageEquityAI/pages/aiCheck/components/SpeechPopup/SpeechPopup.js',
]) {
assert.doesNotMatch(readProjectFile(relativePath), /sentry/i, relativePath);
}
assert.equal(existsSync(path.join(projectRoot, 'utils/lib/sentry-miniapp.js')), false);
assert.equal(existsSync(path.join(projectRoot, 'utils/sentryConfig/sentryInit.js')), false);
assert.doesNotMatch(readProjectFile('package.json'), /["']?@?sentry[\/"']?/i);
});
test('UsedCar request bundle excludes Sentry and is smaller than its baseline', () => {
const bundlePath = path.join(projectRoot, 'packageUsedCar/newRequestIndex.js');
assert.doesNotMatch(readFileSync(bundlePath, 'utf8'), /sentry/i);
assert.ok(statSync(bundlePath).size < 516_477, 'slim bundle must beat the 516477-byte baseline');
});
test('unused dynamic-form demo page is removed without weakening upload protection', () => {
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/test')), false);
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/tests')), true);
const projectConfig = JSON.parse(readProjectFile('project.config.json'));
const ignored = new Set((projectConfig.packOptions?.ignore || []).map(({ value }) => value));
assert.ok(ignored.has('packageDynamicForm/test'));
});