UNPKG

spanwright

Version:

CLI tool to generate Cloud Spanner E2E testing framework projects with Go database tools and Playwright browser automation

191 lines 12.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const constants_1 = require("../constants"); (0, vitest_1.describe)('Constants Module', () => { (0, vitest_1.describe)('Application Constants', () => { (0, vitest_1.it)('should have correct app name', () => { (0, vitest_1.expect)(constants_1.APP_NAME).toBe('Spanwright'); }); (0, vitest_1.it)('should have correct app description', () => { (0, vitest_1.expect)(constants_1.APP_DESCRIPTION).toBe('Cloud Spanner E2E Testing Framework Generator'); }); (0, vitest_1.it)('should have correct GitHub URL', () => { (0, vitest_1.expect)(constants_1.GITHUB_URL).toBe('https://github.com/nu0ma/spanwright'); }); }); (0, vitest_1.describe)('CLI_FLAGS', () => { (0, vitest_1.it)('should have version flags', () => { (0, vitest_1.expect)(constants_1.CLI_FLAGS.VERSION).toEqual(['--version', '-v']); (0, vitest_1.expect)(constants_1.CLI_FLAGS.VERSION).toHaveLength(2); }); (0, vitest_1.it)('should have help flags', () => { (0, vitest_1.expect)(constants_1.CLI_FLAGS.HELP).toEqual(['--help', '-h']); (0, vitest_1.expect)(constants_1.CLI_FLAGS.HELP).toHaveLength(2); }); (0, vitest_1.it)('should have non-interactive flag', () => { (0, vitest_1.expect)(constants_1.CLI_FLAGS.NON_INTERACTIVE).toBe('--non-interactive'); }); (0, vitest_1.it)('should be readonly', () => { (0, vitest_1.expect)(typeof constants_1.CLI_FLAGS.VERSION).toBe('object'); (0, vitest_1.expect)(Array.isArray(constants_1.CLI_FLAGS.VERSION)).toBe(true); }); }); (0, vitest_1.describe)('ENV_VARS', () => { (0, vitest_1.it)('should have CI environment variable', () => { (0, vitest_1.expect)(constants_1.ENV_VARS.CI).toBe('CI'); }); (0, vitest_1.it)('should have non-interactive environment variable', () => { (0, vitest_1.expect)(constants_1.ENV_VARS.NON_INTERACTIVE).toBe('SPANWRIGHT_NON_INTERACTIVE'); }); (0, vitest_1.it)('should have database count environment variable', () => { (0, vitest_1.expect)(constants_1.ENV_VARS.DB_COUNT).toBe('SPANWRIGHT_DB_COUNT'); }); (0, vitest_1.it)('should have primary database environment variables', () => { (0, vitest_1.expect)(constants_1.ENV_VARS.PRIMARY_DB_NAME).toBe('SPANWRIGHT_PRIMARY_DB_NAME'); (0, vitest_1.expect)(constants_1.ENV_VARS.PRIMARY_SCHEMA_PATH).toBe('SPANWRIGHT_PRIMARY_SCHEMA_PATH'); }); (0, vitest_1.it)('should have secondary database environment variables', () => { (0, vitest_1.expect)(constants_1.ENV_VARS.SECONDARY_DB_NAME).toBe('SPANWRIGHT_SECONDARY_DB_NAME'); (0, vitest_1.expect)(constants_1.ENV_VARS.SECONDARY_SCHEMA_PATH).toBe('SPANWRIGHT_SECONDARY_SCHEMA_PATH'); }); }); (0, vitest_1.describe)('DEFAULTS', () => { (0, vitest_1.it)('should have default database count', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.DB_COUNT).toBe('1'); }); (0, vitest_1.it)('should have default database names', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.PRIMARY_DB_NAME).toBe('primary-db'); (0, vitest_1.expect)(constants_1.DEFAULTS.SECONDARY_DB_NAME).toBe('secondary-db'); }); (0, vitest_1.it)('should have default schema paths', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.PRIMARY_SCHEMA_PATH).toBe('./schema'); (0, vitest_1.expect)(constants_1.DEFAULTS.SECONDARY_SCHEMA_PATH).toBe('./schema2'); }); (0, vitest_1.it)('should have default project configuration', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.PROJECT_ID).toBe('test-project'); (0, vitest_1.expect)(constants_1.DEFAULTS.INSTANCE_ID).toBe('test-instance'); }); (0, vitest_1.it)('should have default Docker configuration', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.DOCKER_IMAGE).toBe('gcr.io/cloud-spanner-emulator/emulator'); (0, vitest_1.expect)(constants_1.DEFAULTS.CONTAINER_NAME).toBe('spanner-emulator'); }); (0, vitest_1.it)('should have default port configuration', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.SPANNER_PORT).toBe('9010'); (0, vitest_1.expect)(constants_1.DEFAULTS.ADMIN_PORT).toBe('9020'); }); (0, vitest_1.it)('should have default startup wait time', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.STARTUP_WAIT).toBe('20'); }); }); (0, vitest_1.describe)('FILE_PATTERNS', () => { (0, vitest_1.it)('should have Go file extension', () => { (0, vitest_1.expect)(constants_1.FILE_PATTERNS.GO_EXTENSION).toBe('.go'); }); (0, vitest_1.it)('should have template file patterns', () => { (0, vitest_1.expect)(constants_1.FILE_PATTERNS.PACKAGE_JSON_TEMPLATE).toBe('_package.json'); (0, vitest_1.expect)(constants_1.FILE_PATTERNS.GITIGNORE_TEMPLATE).toBe('_gitignore'); (0, vitest_1.expect)(constants_1.FILE_PATTERNS.GO_MOD_TEMPLATE).toBe('go.mod.template'); }); (0, vitest_1.it)('should have output file patterns', () => { (0, vitest_1.expect)(constants_1.FILE_PATTERNS.PACKAGE_JSON).toBe('package.json'); (0, vitest_1.expect)(constants_1.FILE_PATTERNS.GITIGNORE).toBe('.gitignore'); (0, vitest_1.expect)(constants_1.FILE_PATTERNS.GO_MOD).toBe('go.mod'); (0, vitest_1.expect)(constants_1.FILE_PATTERNS.ENV).toBe('.env'); }); }); (0, vitest_1.describe)('TEMPLATE_VARS', () => { (0, vitest_1.it)('should have project name template variable', () => { (0, vitest_1.expect)(constants_1.TEMPLATE_VARS.PROJECT_NAME).toBe('PROJECT_NAME'); }); }); (0, vitest_1.describe)('VALIDATION', () => { (0, vitest_1.it)('should have valid database counts', () => { (0, vitest_1.expect)(constants_1.VALIDATION.DB_COUNTS).toEqual(['1', '2']); (0, vitest_1.expect)(constants_1.VALIDATION.DB_COUNTS).toHaveLength(2); }); (0, vitest_1.it)('should have flag prefix', () => { (0, vitest_1.expect)(constants_1.VALIDATION.FLAG_PREFIX).toBe('-'); }); (0, vitest_1.it)('should be readonly arrays', () => { (0, vitest_1.expect)(Array.isArray(constants_1.VALIDATION.DB_COUNTS)).toBe(true); }); }); (0, vitest_1.describe)('MESSAGES', () => { (0, vitest_1.describe)('ERRORS', () => { (0, vitest_1.it)('should have error messages', () => { (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.NO_PROJECT_NAME).toBe('❌ Please specify a project name'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.INVALID_DB_COUNT).toBe('❌ Please enter 1 or 2'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.ENV_DB_COUNT_INVALID).toBe('❌ SPANWRIGHT_DB_COUNT must be 1 or 2'); }); (0, vitest_1.it)('should have directory exists error function', () => { (0, vitest_1.expect)(typeof constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS).toBe('function'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('test')).toBe('❌ Directory "test" already exists'); }); }); (0, vitest_1.describe)('INFO', () => { (0, vitest_1.it)('should have info messages', () => { (0, vitest_1.expect)(constants_1.MESSAGES.INFO.STARTING_SETUP).toBe('🚀 Starting Spanner E2E Test Framework setup'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.CREATING_DIRECTORY).toBe('📁 Creating project directory...'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.COPYING_TEMPLATES).toBe('📦 Copying template files...'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.CONFIGURING_GO).toBe('🔧 Configuring Go modules...'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.CREATING_ENV).toBe('⚙️ Creating environment configuration file...'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.REMOVING_FILES).toBe('🗑️ Removing unnecessary files (Single DB configuration)...'); (0, vitest_1.expect)(constants_1.MESSAGES.INFO.COMPLETED).toBe('✅ Project creation completed!'); }); }); (0, vitest_1.describe)('USAGE', () => { (0, vitest_1.it)('should have usage messages', () => { (0, vitest_1.expect)(constants_1.MESSAGES.USAGE.BASIC).toBe('Usage: npx spanwright my-project'); (0, vitest_1.expect)(constants_1.MESSAGES.USAGE.HELP_SUGGESTION).toBe('Try "spanwright --help" for more information.'); }); }); }); (0, vitest_1.describe)('Constant Immutability', () => { (0, vitest_1.it)('should maintain CLI_FLAGS structure', () => { (0, vitest_1.expect)(constants_1.CLI_FLAGS.VERSION).toBeInstanceOf(Array); (0, vitest_1.expect)(constants_1.CLI_FLAGS.HELP).toBeInstanceOf(Array); (0, vitest_1.expect)(typeof constants_1.CLI_FLAGS.NON_INTERACTIVE).toBe('string'); }); (0, vitest_1.it)('should maintain VALIDATION arrays structure', () => { (0, vitest_1.expect)(constants_1.VALIDATION.DB_COUNTS).toBeInstanceOf(Array); (0, vitest_1.expect)(typeof constants_1.VALIDATION.FLAG_PREFIX).toBe('string'); }); (0, vitest_1.it)('should maintain DEFAULTS structure', () => { (0, vitest_1.expect)(typeof constants_1.DEFAULTS.DB_COUNT).toBe('string'); (0, vitest_1.expect)(typeof constants_1.DEFAULTS.PRIMARY_DB_NAME).toBe('string'); }); }); (0, vitest_1.describe)('Type Safety', () => { (0, vitest_1.it)('should maintain type safety for CLI_FLAGS', () => { const versionFlags = constants_1.CLI_FLAGS.VERSION; const helpFlags = constants_1.CLI_FLAGS.HELP; const nonInteractiveFlag = constants_1.CLI_FLAGS.NON_INTERACTIVE; (0, vitest_1.expect)(versionFlags).toBeDefined(); (0, vitest_1.expect)(helpFlags).toBeDefined(); (0, vitest_1.expect)(nonInteractiveFlag).toBeDefined(); }); (0, vitest_1.it)('should maintain type safety for VALIDATION', () => { const dbCounts = constants_1.VALIDATION.DB_COUNTS; const flagPrefix = constants_1.VALIDATION.FLAG_PREFIX; (0, vitest_1.expect)(dbCounts).toBeDefined(); (0, vitest_1.expect)(flagPrefix).toBeDefined(); }); (0, vitest_1.it)('should maintain type safety for DEFAULTS', () => { (0, vitest_1.expect)(constants_1.DEFAULTS.DB_COUNT).toBe('1'); (0, vitest_1.expect)(['1', '2']).toContain(constants_1.DEFAULTS.DB_COUNT); }); }); (0, vitest_1.describe)('Message Function Testing', () => { (0, vitest_1.it)('should generate directory exists message with different names', () => { (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('my-project')).toBe('❌ Directory "my-project" already exists'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('test-app')).toBe('❌ Directory "test-app" already exists'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('')).toBe('❌ Directory "" already exists'); }); (0, vitest_1.it)('should handle special characters in directory names', () => { (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('project-with-dashes')).toBe('❌ Directory "project-with-dashes" already exists'); (0, vitest_1.expect)(constants_1.MESSAGES.ERRORS.DIRECTORY_EXISTS('project_with_underscores')).toBe('❌ Directory "project_with_underscores" already exists'); }); }); }); //# sourceMappingURL=constants.test.js.map