UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

113 lines 6.71 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs = __importStar(require("node:fs")); const path = __importStar(require("node:path")); const Constants_1 = require("../../lib/Constants"); const utils_1 = require("../utils"); const utils_2 = require("../utils"); const utils_3 = require("../utils"); const vitest_1 = require("vitest"); (0, vitest_1.describe)('Flutter', () => { const integration = Constants_1.Integration.flutter; const projectDir = path.resolve(__dirname, '../test-applications/flutter-test-app'); (0, vitest_1.describe)('with apple platforms', () => { (0, vitest_1.beforeAll)(async () => { const wizardInstance = (0, utils_2.startWizardInstance)(integration, projectDir); const tracingOptionPrompted = await wizardInstance.waitForOutput( // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold. 'to track the performance of your application?'); const profilingOptionPrompted = tracingOptionPrompted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], // "Do you want to enable Profiling", sometimes doesn't work as `Profiling` can be printed in bold. 'to analyze CPU usage and optimize performance-critical code on iOS & macOS?')); const replayOptionPrompted = profilingOptionPrompted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], // "Do you want to enable Session Replay", sometimes doesn't work as `Session Replay` can be printed in bold. 'to record user interactions and debug issues?')); replayOptionPrompted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Successfully installed the Sentry Flutter SDK!')); wizardInstance.kill(); }); (0, vitest_1.afterAll)(() => { (0, utils_1.revertLocalChanges)(projectDir); (0, utils_1.cleanupGit)(projectDir); }); (0, vitest_1.test)('pubspec.yaml is updated.', () => { (0, utils_3.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry_flutter:`); // dependencies (0, utils_3.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry_dart_plugin:`); // dev_dependencies (0, utils_3.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry:`); // gradle plugin options }); (0, vitest_1.test)('sentry.properties exists and has auth token', () => { (0, utils_3.checkSentryProperties)(projectDir); }); (0, vitest_1.test)('.gitignore has sentry.properties', () => { (0, utils_3.checkFileContents)(`${projectDir}/.gitignore`, `sentry.properties`); }); (0, vitest_1.test)('lib/main.dart calls sentry init', () => { (0, utils_3.checkFileContents)(`${projectDir}/lib/main.dart`, `import 'package:sentry_flutter/sentry_flutter.dart';`); (0, utils_3.checkFileContents)(`${projectDir}/lib/main.dart`, `await SentryFlutter.init(`); }); (0, vitest_1.test)('lib/main.dart enables tracing and profiling', () => { (0, utils_3.checkFileContents)(`${projectDir}/lib/main.dart`, `options.tracesSampleRate = 1.0;`); (0, utils_3.checkFileContents)(`${projectDir}/lib/main.dart`, `options.profilesSampleRate = 1.0;`); }); (0, vitest_1.test)('builds correctly', async () => { await (0, utils_3.checkIfFlutterBuilds)(projectDir, '✓ Built build/web'); }); }); (0, vitest_1.describe)('without apple platforms', () => { (0, vitest_1.beforeAll)(async () => { const wizardInstance = (0, utils_2.startWizardInstance)(integration, projectDir); if (fs.existsSync(`${projectDir}/ios`)) { fs.renameSync(`${projectDir}/ios`, `${projectDir}/_ios`); } if (fs.existsSync(`${projectDir}/macos`)) { fs.renameSync(`${projectDir}/macos`, `${projectDir}/_macos`); } const continueOnUncommitedFilesPromted = await wizardInstance.waitForOutput('Do you want to continue anyway?'); const tracingOptionPrompted = continueOnUncommitedFilesPromted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold. 'to track the performance of your application?')); const replayOptionPrompted = tracingOptionPrompted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], // "Do you want to enable Session Replay", sometimes doesn't work as `Session Replay` can be printed in bold. 'to record user interactions and debug issues?')); replayOptionPrompted && (await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Successfully installed the Sentry Flutter SDK!')); wizardInstance.kill(); }); (0, vitest_1.afterAll)(() => { (0, utils_1.revertLocalChanges)(projectDir); (0, utils_1.cleanupGit)(projectDir); }); (0, vitest_1.test)('lib/main.dart does not add profiling with missing ios and macos folder', () => { const fileContent = fs.readFileSync(`${projectDir}/lib/main.dart`, 'utf-8'); (0, vitest_1.expect)(fileContent).not.toContain(`options.profilesSampleRate = 1.0;`); }); }); }); //# sourceMappingURL=flutter.test.js.map