* fix: only enable EE features in test backend when license key is available Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: skip EE tests without license key and exclude test-skills from test discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: unskip passing tests and add duplicate (remote, workspaceId) check in addWorkspace Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(cli): migrate from Deno APIs to Node.js/Bun-compatible APIs Replace Deno-specific APIs with Node.js equivalents across the entire CLI codebase to enable running on Node.js/Bun. Switch build system from dnt to bun, update imports from jsr:/npm: prefixed to bare specifiers, and add package.json/tsconfig.json for the Node.js ecosystem. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * all * test(cli): expand test coverage with new integration and unit tests Add standalone_commands.test.ts covering folder list, schedule list, resource-type list/push/update, script show/run/bootstrap, and user commands. Add unit tests for filePathExtensionFromContentType and removeExtensionToPath. Add git_unit, local_encryption_unit, resource_folders_unit, and settings_unit test files. Fix schedule cron expressions (6-field format), add includeSchedules flag, improve test setup with pre-build and auto-cleanup, and support TEST_CLI_RUNTIME=node. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): replace Deno.readFile with node:fs in WASM loaders and add schema parsing tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(cli): switch WASM parsers from local files to npm packages Use published windmill-parser-wasm-* npm packages instead of local wasm/ files. A loadParser() helper uses createRequire to resolve the .wasm binary from node_modules and passes it to init() via readFileSync, avoiding fetch() and Deno.readFile() patches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(cli): add coverage for --locks-required lint feature Add 15 tests covering the lock-checking functionality merged from main: - checkMissingLocks: standalone scripts (python, bun, bash), inline lock file resolution (valid, empty, missing), flow inline rawscripts (with/without locks, nested forloopflow), app inline scripts, raw apps without backend folder - runLint --locks-required integration: reports issues when locks missing, skips checks when flag absent, passes when locks exist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci(cli): replace Deno with Bun in CI workflows - cli-tests.yml: remove Deno setup, use `bun test` instead of `deno test`, add `bun install` step for dependency installation - npm_on_release.yml: replace Deno setup with Bun setup for CLI publishing - build.sh: add `bun install` before building so CI has dependencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): pre-start backend in test preload and remove Deno test leftovers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): normalize path separators for Windows compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * more tests + windows * ci(cli): use Blacksmith runner for Windows tests Switch test-windows job from windows-latest to blacksmith-16vcpu-windows-2025 for faster CI execution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): fix Windows path separator expectations in unit tests buildMetadataPath and extractResourceName normalize to forward slashes internally, so tests should not expect platform-specific separators in their output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): fix Windows CI test failures for dev_server and script_run Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): set BUN_PATH and NODE_BIN_PATH for backend worker on Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci(cli): add SSH debug step on Windows test failure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): use native path separators for ignore check in dev mode on Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
205 lines
8.0 KiB
TypeScript
205 lines
8.0 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { writeFile } from "node:fs/promises";
|
|
import { readConfigFile, getEffectiveSettings } from "../src/core/conf.ts";
|
|
import { withTestBackend } from "./test_backend.ts";
|
|
import { addWorkspace } from "../workspace.ts";
|
|
import { parseJsonFromCLIOutput } from "./test_config_helpers.ts";
|
|
|
|
// =============================================================================
|
|
// SYNC CONFIGURATION RESOLUTION TESTS
|
|
// Tests for configuration resolution and integration with backend
|
|
// =============================================================================
|
|
|
|
// Helper function to set up workspace profile with localhost_test name
|
|
async function setupWorkspaceProfile(backend: any): Promise<void> {
|
|
const testWorkspace = {
|
|
remote: backend.baseUrl, // "http://localhost:8001/"
|
|
workspaceId: backend.workspace, // "test"
|
|
name: "localhost_test", // This is what the tests expect!
|
|
token: backend.token
|
|
};
|
|
|
|
await addWorkspace(testWorkspace, { force: true, configDir: backend.testConfigDir });
|
|
}
|
|
|
|
|
|
// =============================================================================
|
|
// INTEGRATION TESTS WITH REAL BACKEND
|
|
// =============================================================================
|
|
|
|
test("Integration: wmill.yaml configuration produces expected results", async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace profile with name "localhost_test"
|
|
await setupWorkspaceProfile(backend);
|
|
|
|
// Create wmill.yaml with settings
|
|
await writeFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- f/**
|
|
- settings.yaml
|
|
excludes:
|
|
- "*.test.ts"
|
|
skipVariables: true
|
|
skipResources: true
|
|
includeSettings: true
|
|
includeSchedules: true
|
|
includeTriggers: true`, "utf-8");
|
|
|
|
// Test pull with wmill.yaml configuration
|
|
const yamlResult = await backend.runCLICommand(['sync', 'pull', '--dry-run', '--json-output'], tempDir);
|
|
if (yamlResult.code !== 0) {
|
|
console.log("YAML command failed!");
|
|
console.log("Exit code:", yamlResult.code);
|
|
console.log("Stdout:", yamlResult.stdout);
|
|
console.log("Stderr:", yamlResult.stderr);
|
|
}
|
|
expect(yamlResult.code).toEqual(0);
|
|
|
|
// Extract JSON from CLI output (skip log messages)
|
|
const yamlData = parseJsonFromCLIOutput(yamlResult.stdout);
|
|
|
|
// Should include settings.yaml due to includeSettings: true
|
|
const hasSettings = (yamlData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path === 'settings.yaml'
|
|
);
|
|
expect(hasSettings).toEqual(true);
|
|
|
|
// Should NOT include resources or variables (due to skip flags)
|
|
const hasResources = (yamlData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.resource.yaml')
|
|
);
|
|
const hasVariables = (yamlData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.variable.yaml')
|
|
);
|
|
expect(hasResources).toEqual(false);
|
|
expect(hasVariables).toEqual(false);
|
|
});
|
|
});
|
|
|
|
test("Integration: settings.yaml inclusion respects includeSettings flag", async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace profile with name "localhost_test"
|
|
await setupWorkspaceProfile(backend);
|
|
|
|
// Test 1: includeSettings: true should include settings.yaml
|
|
await writeFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
includeSettings: true`, "utf-8");
|
|
|
|
const includeResult = await backend.runCLICommand(['sync', 'pull', '--dry-run', '--json-output'], tempDir);
|
|
expect(includeResult.code).toEqual(0);
|
|
|
|
// Extract JSON from CLI output (skip log messages)
|
|
const includeData = parseJsonFromCLIOutput(includeResult.stdout);
|
|
const hasSettingsInclude = (includeData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path === 'settings.yaml'
|
|
);
|
|
expect(hasSettingsInclude).toEqual(true);
|
|
|
|
// Test 2: includeSettings: false should NOT include settings.yaml
|
|
await writeFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
includeSettings: false`, "utf-8");
|
|
|
|
const excludeResult = await backend.runCLICommand(['sync', 'pull', '--dry-run', '--json-output'], tempDir);
|
|
expect(excludeResult.code).toEqual(0);
|
|
|
|
// Extract JSON from CLI output (skip log messages)
|
|
const excludeData = parseJsonFromCLIOutput(excludeResult.stdout);
|
|
const hasSettingsExclude = (excludeData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path === 'settings.yaml'
|
|
);
|
|
expect(hasSettingsExclude).toEqual(false);
|
|
});
|
|
});
|
|
|
|
test("Integration: resource/variable filtering respects skip flags", async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace profile with name "localhost_test"
|
|
await setupWorkspaceProfile(backend);
|
|
|
|
// Test skipResources: true
|
|
await writeFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
skipResources: true
|
|
skipVariables: false`, "utf-8");
|
|
|
|
const result = await backend.runCLICommand(['sync', 'pull', '--dry-run', '--json-output'], tempDir);
|
|
expect(result.code).toEqual(0);
|
|
|
|
// Extract JSON from CLI output (skip log messages)
|
|
const data = parseJsonFromCLIOutput(result.stdout);
|
|
|
|
// Should NOT include resources
|
|
const hasResources = (data.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.resource.yaml')
|
|
);
|
|
expect(hasResources).toEqual(false);
|
|
|
|
// Should include variables (not skipped)
|
|
const hasVariables = (data.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.variable.yaml')
|
|
);
|
|
expect(hasVariables).toEqual(true);
|
|
});
|
|
});
|
|
|
|
// =============================================================================
|
|
// CLI FLAG OVERRIDE TESTS
|
|
// Tests for CLI flags overriding configuration file settings
|
|
// =============================================================================
|
|
|
|
test("CLI skip flags override wmill.yaml configuration", async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace profile with name "localhost_test"
|
|
await setupWorkspaceProfile(backend);
|
|
|
|
// Create wmill.yaml that INCLUDES resources by default (skipResources: false)
|
|
await writeFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- f/**
|
|
- u/**
|
|
skipResources: false
|
|
skipResourceTypes: false
|
|
includeSettings: true`, "utf-8");
|
|
|
|
// Test 1: Without CLI flags - should respect wmill.yaml (include resources)
|
|
const configResult = await backend.runCLICommand(['sync', 'pull', '--dry-run', '--json-output'], tempDir);
|
|
expect(configResult.code).toEqual(0);
|
|
|
|
const configData = parseJsonFromCLIOutput(configResult.stdout);
|
|
|
|
|
|
// Should include resources (not skipped by config)
|
|
const hasResources = (configData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.resource.yaml')
|
|
);
|
|
expect(hasResources).toEqual(true);
|
|
|
|
// Test 2: With CLI --skip-resources flag - should override wmill.yaml to skip resources
|
|
const overrideResult = await backend.runCLICommand([
|
|
'sync', 'pull', '--dry-run', '--json-output',
|
|
'--skip-resources', // CLI flag should override config to skip resources
|
|
'--skip-resource-types' // CLI flag should override config to skip resource types
|
|
], tempDir);
|
|
expect(overrideResult.code).toEqual(0);
|
|
|
|
const overrideData = parseJsonFromCLIOutput(overrideResult.stdout);
|
|
|
|
// Should NOT include resources (CLI flag overrides config)
|
|
const hasResourcesOverride = (overrideData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.resource.yaml')
|
|
);
|
|
expect(hasResourcesOverride).toEqual(false);
|
|
|
|
// Should NOT include resource types (CLI flag overrides config)
|
|
const hasResourceTypesOverride = (overrideData.changes || []).some((change: any) =>
|
|
change.type === 'added' && change.path?.includes('.resource-type.yaml')
|
|
);
|
|
expect(hasResourceTypesOverride).toEqual(false);
|
|
});
|
|
});
|