sentry-removal.test.mjs 1.23 KB
import assert from 'node:assert/strict'
import { access, readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, it } from 'node:test'

const projectRoot = path.resolve(
  path.dirname(fileURLToPath(import.meta.url)),
  '../..'
)

describe('Sentry removal boundary', () => {
  it('ships no Sentry SDK, bootstrap, DSN, or runtime reporter calls', async () => {
    const removedArtifacts = [
      'utils/lib/sentry-miniapp.js',
      'utils/sentryConfig/sentryInit.js'
    ]

    for (const relativePath of removedArtifacts) {
      await assert.rejects(
        access(path.join(projectRoot, relativePath)),
        error => error?.code === 'ENOENT',
        `Sentry artifact must not ship: ${relativePath}`
      )
    }

    const runtimeFiles = [
      'app.js',
      'config.js',
      'packageStudy/pages/aiCheck/chat/chat.js',
      'packageStudy/pages/aiCheck/components/SpeechPopup/SpeechPopup.js'
    ]
    const runtimeSource = (
      await Promise.all(
        runtimeFiles.map(relativePath =>
          readFile(path.join(projectRoot, relativePath), 'utf8')
        )
      )
    ).join('\n')

    assert.doesNotMatch(runtimeSource, /sentry|\$sendSentry|dsnUrl/i)
  })
})