mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
a22d179903
* feat(cli): add GitHub Actions CI and raw app sync tests - Add CLI tests GitHub Action that runs on Linux and Windows - Add build check job that runs on CLI and openapi.yaml changes - Uses Rust cargo backend instead of Docker for better CI compatibility - Add cargo_backend.ts and test_backend.ts for test infrastructure - Fix Windows path separator bug in raw_apps.ts (use "/" for relative paths) - Fix PostgreSQL URL parsing in cargo_backend.ts - Update tests to use gitBranches format instead of deprecated overrides - Add raw_app_sync.test.ts for raw app sync workflow testing (ignored for now - needs EE) - Skip tests that require EE features (git sync settings, raw apps) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): Fix Windows path compatibility issues in tests - Use fromFileUrl() in cargo_backend.ts for proper Windows path handling - Normalize path separators to forward slashes in resource_folders.ts - Fix readDirRecursive to return normalized paths in test helper - Use forward slashes consistently in buildMetadataPath and detection functions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): Use SEP in test assertions instead of modifying logic - Revert resource_folders.ts to use SEP as intended - Update test assertions to use SEP for platform-specific paths - Keep readDirRecursive normalization for consistent test comparisons Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): Use SEP for all path separators in test assertions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): Use resolve() for proper cross-platform path handling in cargo_backend String concatenation with path separators creates malformed paths on Windows. Use path.resolve() instead for proper cross-platform path resolution. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(backend): Add cfg attributes for Windows compatibility - Add #[cfg(unix)] to anyhow::anyhow import (only used in unix cfg block) - Add #[cfg(not(windows))] to parse_file function (uses cat, only for cgroups) - Remove unused std::io import, use std::io::Result directly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Windows compilation + convert integration tests to withTestBackend - Fix unused import SYSTEM_ROOT in csharp_executor.rs on Windows by requiring both windows and csharp feature - Fix unused variable id in handle_child.rs on Windows by adding #[allow(unused_variables)] since id is only used in cfg(unix) code - Convert all RUN_INTEGRATION_TESTS dependent tests in sync_pull_push.test.ts to use withTestBackend pattern for automatic backend setup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: configurable test features with CI_MINIMAL_FEATURES env var - Default: full features (zip, private, enterprise) for local development - CI mode: minimal features (zip only) when CI_MINIMAL_FEATURES=true - Add shouldSkipOnCI() helper for tests requiring EE features - Update EE-dependent tests to use shouldSkipOnCI() - Add test instructions to cli/README.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: enable raw app tests (not EE-dependent) Raw apps work with minimal features. 2 tests pass, 2 have test logic bugs to investigate separately: - "delete file and push" - file deletion not syncing correctly - "dry-run push shows expected changes" - JSON output parsing issue Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: gate cgroups module to Linux only cgroups are Linux-specific, the module was causing dead_code warnings on Windows compilation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): add CI_MINIMAL_FEATURES env var to CLI tests workflow Set CI_MINIMAL_FEATURES=true in both Linux and Windows test jobs so the backend compiles with minimal features (zip only) and EE-dependent tests self-skip via shouldSkipOnCI(). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): raw app tests and backend startup timing - Add 5s delay after backend ready for migrations to complete - Fix dry-run JSON output parsing (handle pretty-printed JSON) - Temporarily ignore "delete file" test (needs isSuperset fix) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): raw app file deletion sync - Add deepEqual check for files in raw_apps.ts isSuperset comparison - Handle raw_app file deletions in sync.ts by re-pushing the entire app - Fix test to remove CSS import before deleting the file When deleting a file from a raw app, the sync now properly updates the backend with the new file list (excluding the deleted file). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): Windows path separators in tests Normalize paths for cross-platform comparison by converting backslashes to forward slashes before path assertions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): normalize featurePaths in multi_instance_workspace test Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(cli): add mixed case paths sync tests for Windows compatibility Add comprehensive tests for sync pull/push with capitalized folder paths to catch Windows case-insensitivity issues: - Scripts in f/MyFolder/MyScript - Flows in f/MyFlows/DataProcessor - Apps in f/MyApps/Dashboard - Variables in f/MyVars/ApiKey - Deeply nested paths with mixed case - Multiple resources in same capitalized folder - CamelCase folder names with numbers Each test verifies the full pull -> modify -> push -> verify cycle. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(cli): add idempotency check to mixed case paths tests After each push, pull again with --dry-run --json-output and verify that no changes are detected. This ensures the sync is stable and catches issues where pull/push cycles cause spurious diffs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
482 lines
17 KiB
TypeScript
482 lines
17 KiB
TypeScript
import { assertEquals, assert, assertStringIncludes } from "https://deno.land/std@0.224.0/assert/mod.ts";
|
|
import { withTestBackend } from "./test_backend.ts";
|
|
import { addWorkspace } from "../workspace.ts";
|
|
import * as path from "https://deno.land/std@0.224.0/path/mod.ts";
|
|
import { ensureDir } from "https://deno.land/std@0.224.0/fs/mod.ts";
|
|
|
|
// =============================================================================
|
|
// RAW APP SYNC TESTS
|
|
// Tests for raw app sync pull/push workflow
|
|
// =============================================================================
|
|
|
|
// Raw app file contents
|
|
const APP_TSX = `import React, { useState } from 'react'
|
|
import { backend } from './wmill'
|
|
import './index.css'
|
|
|
|
const App = () => {
|
|
const [value, setValue] = useState(undefined as string | undefined)
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
async function runA() {
|
|
setLoading(true)
|
|
try {
|
|
setValue(await backend.a({ x: 42 }))
|
|
} catch (e) {
|
|
console.error()
|
|
}
|
|
setLoading(false)
|
|
}
|
|
|
|
return <div style={{ width: "100%" }}>
|
|
<h1>hello world</h1>
|
|
|
|
<button style={{ marginTop: "2px" }} onClick={runA}>Run 'a'</button>
|
|
|
|
<div style={{ marginTop: "20px", width: '250px' }} className='myclass'>
|
|
{loading ? 'Loading ...' : value ?? 'Click button to see value here'}
|
|
</div>
|
|
</div>;
|
|
};
|
|
|
|
export default App;
|
|
`;
|
|
|
|
const INDEX_CSS = `.myclass {
|
|
border: 1px solid gray;
|
|
padding: 2px;
|
|
}`;
|
|
|
|
const INDEX_TSX = `
|
|
import React from 'react'
|
|
|
|
import { createRoot } from 'react-dom/client'
|
|
import App from './App'
|
|
|
|
const root = createRoot(document.getElementById('root')!);
|
|
root.render(<App/>);
|
|
`;
|
|
|
|
const PACKAGE_JSON = `{
|
|
"dependencies": {
|
|
"react": "19.0.0",
|
|
"react-dom": "19.0.0",
|
|
"windmill-client": "^1"
|
|
},
|
|
"devDependencies": {
|
|
"@types/react-dom": "^19.0.0",
|
|
"@types/react": "^19.0.0"
|
|
}
|
|
}`;
|
|
|
|
const INLINE_SCRIPT_A = `// import * as wmill from "windmill-client"
|
|
|
|
export async function main(x: string) {
|
|
return x
|
|
}
|
|
`;
|
|
|
|
const INLINE_SCRIPT_A_LOCK = `{
|
|
"dependencies": {}
|
|
}
|
|
//bun.lock
|
|
<empty>`;
|
|
|
|
// raw_app.yaml metadata file
|
|
const RAW_APP_YAML = `summary: Test Raw App
|
|
policy:
|
|
execution_mode: publisher
|
|
triggerables: {}
|
|
triggerables_v2: {}
|
|
`;
|
|
|
|
async function fileExists(filePath: string): Promise<boolean> {
|
|
try {
|
|
await Deno.stat(filePath);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
async function readFileContent(filePath: string): Promise<string> {
|
|
return await Deno.readTextFile(filePath);
|
|
}
|
|
|
|
/**
|
|
* Create a raw app directory structure on disk
|
|
* Uses .raw_app folder suffix with raw_app.yaml metadata
|
|
*/
|
|
async function createRawAppOnDisk(appDir: string): Promise<void> {
|
|
await ensureDir(appDir);
|
|
await ensureDir(path.join(appDir, "inline_scripts"));
|
|
|
|
// Create raw_app.yaml metadata file
|
|
await Deno.writeTextFile(path.join(appDir, "raw_app.yaml"), RAW_APP_YAML);
|
|
|
|
// Create app source files
|
|
await Deno.writeTextFile(path.join(appDir, "App.tsx"), APP_TSX);
|
|
await Deno.writeTextFile(path.join(appDir, "index.css"), INDEX_CSS);
|
|
await Deno.writeTextFile(path.join(appDir, "index.tsx"), INDEX_TSX);
|
|
await Deno.writeTextFile(path.join(appDir, "package.json"), PACKAGE_JSON);
|
|
|
|
// Create inline script in inline_scripts folder
|
|
await Deno.writeTextFile(
|
|
path.join(appDir, "inline_scripts", "a.inline_script.ts"),
|
|
INLINE_SCRIPT_A
|
|
);
|
|
await Deno.writeTextFile(
|
|
path.join(appDir, "inline_scripts", "a.inline_script.lock"),
|
|
INLINE_SCRIPT_A_LOCK
|
|
);
|
|
}
|
|
|
|
Deno.test({
|
|
name: "Raw App: full sync workflow - push, pull, modify, push, clear, pull",
|
|
ignore: false,
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
fn: async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace
|
|
const testWorkspace = {
|
|
remote: backend.baseUrl,
|
|
workspaceId: backend.workspace,
|
|
name: "raw_app_test",
|
|
token: backend.token
|
|
};
|
|
await addWorkspace(testWorkspace, { force: true, configDir: backend.testConfigDir });
|
|
|
|
// Create wmill.yaml
|
|
await Deno.writeTextFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
excludes: []`);
|
|
|
|
// Create folder structure
|
|
const appDir = path.join(tempDir, "f", "test", "my_raw_app.raw_app");
|
|
await ensureDir(path.join(tempDir, "f", "test"));
|
|
await createRawAppOnDisk(appDir);
|
|
|
|
// =========================================================================
|
|
// STEP 1: Initial push - create raw app on backend
|
|
// =========================================================================
|
|
const pushResult1 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_test");
|
|
|
|
assertEquals(pushResult1.code, 0, `Initial sync push should succeed: ${pushResult1.stderr}`);
|
|
|
|
// =========================================================================
|
|
// STEP 2: Clear disk and pull - verify raw app is pulled correctly
|
|
// =========================================================================
|
|
await Deno.remove(appDir, { recursive: true });
|
|
assert(!(await fileExists(appDir)), "App directory should be deleted before pull");
|
|
|
|
const pullResult1 = await backend.runCLICommand([
|
|
'sync', 'pull',
|
|
'--yes'
|
|
], tempDir, "raw_app_test");
|
|
|
|
assertEquals(pullResult1.code, 0, `Sync pull should succeed: ${pullResult1.stderr}`);
|
|
|
|
// Verify raw app directory structure was created
|
|
assert(await fileExists(appDir), `Raw app directory should exist at ${appDir}`);
|
|
|
|
// Verify files were pulled
|
|
const appTsxPath = path.join(appDir, "App.tsx");
|
|
const indexCssPath = path.join(appDir, "index.css");
|
|
const indexTsxPath = path.join(appDir, "index.tsx");
|
|
const packageJsonPath = path.join(appDir, "package.json");
|
|
const inlineScriptPath = path.join(appDir, "inline_scripts", "a.inline_script.ts");
|
|
|
|
assert(await fileExists(appTsxPath), "App.tsx should exist");
|
|
assert(await fileExists(indexCssPath), "index.css should exist");
|
|
assert(await fileExists(indexTsxPath), "index.tsx should exist");
|
|
assert(await fileExists(packageJsonPath), "package.json should exist");
|
|
assert(await fileExists(inlineScriptPath), "Inline script a.inline_script.ts should exist");
|
|
|
|
// Verify file contents
|
|
const appTsxContent = await readFileContent(appTsxPath);
|
|
assertStringIncludes(appTsxContent, "hello world", "App.tsx should contain 'hello world'");
|
|
assertStringIncludes(appTsxContent, "backend.a", "App.tsx should reference backend.a");
|
|
|
|
const indexCssContent = await readFileContent(indexCssPath);
|
|
assertStringIncludes(indexCssContent, ".myclass", "index.css should contain .myclass");
|
|
|
|
const inlineScriptContent = await readFileContent(inlineScriptPath);
|
|
assertStringIncludes(inlineScriptContent, "export async function main", "Inline script should have main function");
|
|
|
|
// =========================================================================
|
|
// STEP 3: Modify files locally
|
|
// =========================================================================
|
|
|
|
// Modify App.tsx - change the heading
|
|
const modifiedAppTsx = appTsxContent.replace("hello world", "hello modified world");
|
|
await Deno.writeTextFile(appTsxPath, modifiedAppTsx);
|
|
|
|
// Modify index.css - change the border color
|
|
const modifiedIndexCss = indexCssContent.replace("gray", "blue");
|
|
await Deno.writeTextFile(indexCssPath, modifiedIndexCss);
|
|
|
|
// Modify inline script - change the return value
|
|
const modifiedInlineScript = inlineScriptContent.replace("return x", "return `modified: ${x}`");
|
|
await Deno.writeTextFile(inlineScriptPath, modifiedInlineScript);
|
|
|
|
// =========================================================================
|
|
// STEP 4: Push changes
|
|
// =========================================================================
|
|
const pushResult2 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_test");
|
|
|
|
assertEquals(pushResult2.code, 0, `Sync push should succeed: ${pushResult2.stderr}`);
|
|
|
|
// =========================================================================
|
|
// STEP 5: Clear disk (delete the app directory)
|
|
// =========================================================================
|
|
await Deno.remove(appDir, { recursive: true });
|
|
assert(!(await fileExists(appDir)), "App directory should be deleted");
|
|
|
|
// =========================================================================
|
|
// STEP 6: Pull again and verify modifications persisted
|
|
// =========================================================================
|
|
const pullResult2 = await backend.runCLICommand([
|
|
'sync', 'pull',
|
|
'--yes'
|
|
], tempDir, "raw_app_test");
|
|
|
|
assertEquals(pullResult2.code, 0, `Second sync pull should succeed: ${pullResult2.stderr}`);
|
|
|
|
// Verify app directory exists again
|
|
assert(await fileExists(appDir), "Raw app directory should exist after second pull");
|
|
|
|
// Verify all files were pulled again
|
|
assert(await fileExists(appTsxPath), "App.tsx should exist after second pull");
|
|
assert(await fileExists(indexCssPath), "index.css should exist after second pull");
|
|
assert(await fileExists(indexTsxPath), "index.tsx should exist after second pull");
|
|
assert(await fileExists(packageJsonPath), "package.json should exist after second pull");
|
|
assert(await fileExists(inlineScriptPath), "Inline script should exist after second pull");
|
|
|
|
// Verify modifications were persisted
|
|
const pulledAppTsx = await readFileContent(appTsxPath);
|
|
assertStringIncludes(pulledAppTsx, "hello modified world", "Modifications to App.tsx should persist");
|
|
|
|
const pulledIndexCss = await readFileContent(indexCssPath);
|
|
assertStringIncludes(pulledIndexCss, "blue", "Modifications to index.css should persist");
|
|
|
|
const pulledInlineScript = await readFileContent(inlineScriptPath);
|
|
assertStringIncludes(pulledInlineScript, "modified:", "Modifications to inline script should persist");
|
|
});
|
|
}
|
|
});
|
|
|
|
Deno.test({
|
|
name: "Raw App: add new file and push",
|
|
ignore: false,
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
fn: async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace
|
|
const testWorkspace = {
|
|
remote: backend.baseUrl,
|
|
workspaceId: backend.workspace,
|
|
name: "raw_app_new_file_test",
|
|
token: backend.token
|
|
};
|
|
await addWorkspace(testWorkspace, { force: true, configDir: backend.testConfigDir });
|
|
|
|
// Create wmill.yaml
|
|
await Deno.writeTextFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
excludes: []`);
|
|
|
|
// Create initial raw app
|
|
const appDir = path.join(tempDir, "f", "test", "new_file_app.raw_app");
|
|
await ensureDir(path.join(tempDir, "f", "test"));
|
|
await createRawAppOnDisk(appDir);
|
|
|
|
// Initial push
|
|
const pushResult1 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_new_file_test");
|
|
|
|
assertEquals(pushResult1.code, 0, `Initial sync push should succeed: ${pushResult1.stderr}`);
|
|
|
|
// Add a new file
|
|
const newFilePath = path.join(appDir, "utils.ts");
|
|
await Deno.writeTextFile(newFilePath, `export function formatValue(val: string): string {
|
|
return \`Formatted: \${val}\`;
|
|
}
|
|
`);
|
|
|
|
// Push changes
|
|
const pushResult2 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_new_file_test");
|
|
|
|
assertEquals(pushResult2.code, 0, `Sync push with new file should succeed: ${pushResult2.stderr}`);
|
|
|
|
// Clear and pull again
|
|
await Deno.remove(appDir, { recursive: true });
|
|
|
|
const pullResult = await backend.runCLICommand([
|
|
'sync', 'pull',
|
|
'--yes'
|
|
], tempDir, "raw_app_new_file_test");
|
|
|
|
assertEquals(pullResult.code, 0, `Sync pull should succeed: ${pullResult.stderr}`);
|
|
|
|
// Verify new file was persisted
|
|
assert(await fileExists(newFilePath), "New file utils.ts should exist after pull");
|
|
const newFileContent = await readFileContent(newFilePath);
|
|
assertStringIncludes(newFileContent, "formatValue", "New file content should persist");
|
|
});
|
|
}
|
|
});
|
|
|
|
Deno.test({
|
|
name: "Raw App: delete file and push",
|
|
ignore: false,
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
fn: async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace
|
|
const testWorkspace = {
|
|
remote: backend.baseUrl,
|
|
workspaceId: backend.workspace,
|
|
name: "raw_app_delete_file_test",
|
|
token: backend.token
|
|
};
|
|
await addWorkspace(testWorkspace, { force: true, configDir: backend.testConfigDir });
|
|
|
|
// Create wmill.yaml
|
|
await Deno.writeTextFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
excludes: []`);
|
|
|
|
// Create initial raw app
|
|
const appDir = path.join(tempDir, "f", "test", "delete_file_app.raw_app");
|
|
await ensureDir(path.join(tempDir, "f", "test"));
|
|
await createRawAppOnDisk(appDir);
|
|
|
|
// Initial push
|
|
const pushResult1 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_delete_file_test");
|
|
|
|
assertEquals(pushResult1.code, 0, `Initial sync push should succeed: ${pushResult1.stderr}`);
|
|
|
|
const indexCssPath = path.join(appDir, "index.css");
|
|
const appTsxPath = path.join(appDir, "App.tsx");
|
|
assert(await fileExists(indexCssPath), "index.css should exist after initial push");
|
|
|
|
// First, update App.tsx to remove the CSS import (otherwise bundle will fail)
|
|
const appTsxContent = await readFileContent(appTsxPath);
|
|
const updatedAppTsx = appTsxContent.replace("import './index.css'\n", "");
|
|
await Deno.writeTextFile(appTsxPath, updatedAppTsx);
|
|
|
|
// Delete the CSS file
|
|
await Deno.remove(indexCssPath);
|
|
assert(!(await fileExists(indexCssPath)), "index.css should be deleted locally");
|
|
|
|
// Push changes
|
|
const pushResult2 = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--yes'
|
|
], tempDir, "raw_app_delete_file_test");
|
|
|
|
assertEquals(pushResult2.code, 0, `Sync push after delete should succeed: ${pushResult2.stderr}`);
|
|
|
|
// Clear and pull again
|
|
await Deno.remove(appDir, { recursive: true });
|
|
|
|
const pullResult = await backend.runCLICommand([
|
|
'sync', 'pull',
|
|
'--yes'
|
|
], tempDir, "raw_app_delete_file_test");
|
|
|
|
assertEquals(pullResult.code, 0, `Sync pull should succeed: ${pullResult.stderr}`);
|
|
|
|
// Verify the deleted file is NOT pulled (it was deleted from backend)
|
|
assert(!(await fileExists(indexCssPath)), "Deleted index.css should not exist after pull");
|
|
|
|
// But other files should still exist
|
|
assert(await fileExists(appTsxPath), "App.tsx should still exist after pull");
|
|
});
|
|
}
|
|
});
|
|
|
|
Deno.test({
|
|
name: "Raw App: dry-run push shows expected changes",
|
|
ignore: false,
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
fn: async () => {
|
|
await withTestBackend(async (backend, tempDir) => {
|
|
// Set up workspace
|
|
const testWorkspace = {
|
|
remote: backend.baseUrl,
|
|
workspaceId: backend.workspace,
|
|
name: "raw_app_dry_run_test",
|
|
token: backend.token
|
|
};
|
|
await addWorkspace(testWorkspace, { force: true, configDir: backend.testConfigDir });
|
|
|
|
// Create wmill.yaml
|
|
await Deno.writeTextFile(`${tempDir}/wmill.yaml`, `defaultTs: bun
|
|
includes:
|
|
- "**"
|
|
excludes: []`);
|
|
|
|
// Create raw app
|
|
const appDir = path.join(tempDir, "f", "test", "dry_run_app.raw_app");
|
|
await ensureDir(path.join(tempDir, "f", "test"));
|
|
await createRawAppOnDisk(appDir);
|
|
|
|
// Dry-run push
|
|
const dryRunResult = await backend.runCLICommand([
|
|
'sync', 'push',
|
|
'--dry-run',
|
|
'--json-output'
|
|
], tempDir, "raw_app_dry_run_test");
|
|
|
|
assertEquals(dryRunResult.code, 0, `Dry-run push should succeed: ${dryRunResult.stderr}`);
|
|
|
|
// Parse JSON output (may be pretty-printed across multiple lines)
|
|
let jsonOutput = null;
|
|
try {
|
|
// Try parsing the entire stdout as JSON
|
|
jsonOutput = JSON.parse(dryRunResult.stdout.trim());
|
|
} catch {
|
|
// If that fails, try to find JSON object in the output
|
|
const jsonMatch = dryRunResult.stdout.match(/\{[\s\S]*\}/);
|
|
if (jsonMatch) {
|
|
try {
|
|
jsonOutput = JSON.parse(jsonMatch[0]);
|
|
} catch {
|
|
// Ignore parse errors
|
|
}
|
|
}
|
|
}
|
|
|
|
assert(jsonOutput !== null, `Should have JSON output. Got: ${dryRunResult.stdout}`);
|
|
assert(Array.isArray(jsonOutput.changes), `Should have changes array. Got: ${JSON.stringify(jsonOutput)}`);
|
|
|
|
// Should include raw app in changes
|
|
const changePaths = jsonOutput.changes.map((c: any) => c.path);
|
|
const hasRawApp = changePaths.some((p: string) => p.includes("dry_run_app"));
|
|
assert(hasRawApp, `Dry-run should show raw app. Found: ${changePaths.join(', ')}`);
|
|
});
|
|
}
|
|
});
|