#314 [TASK] Add test classes to ensure future changes do not introduce regressions#315
#314 [TASK] Add test classes to ensure future changes do not introduce regressions#315
Conversation
|
@copilot add a "script" run task into package.json and also enhance the existing testing github workflow with running this new test suite on top |
…uites) Co-authored-by: JoernBerkefeld <1917227+JoernBerkefeld@users.noreply.github.com>
Done in commit
The workflow enhancement commit ( |
|
@copilot please double check if these tests really cover all possible user interactions and if they really ensure the execution of mcdev is blocked as expected or runs the right mcdev command as expected |
…rtedForType, run() dispatch tests; fix clone error message Co-authored-by: JoernBerkefeld <1917227+JoernBerkefeld@users.noreply.github.com>
Reviewed carefully and found three gaps. Addressed in commit Gaps found and fixed:
Bug also fixed: Total: 140 tests (was 83). |
No automated tests existed —
npm testonly ran ESLint. This adds a full unit test suite covering all five extension commands across every supported file/folder selection scenario, integrates the suite into the CI workflow, and verifies both the action-blocking mechanism and the full path-to-command pipeline.Test infrastructure
tsconfig.test.json— CommonJS-mode TypeScript config with path alias resolution (@types,@config,utils, etc.).vscode-test.mjs—@vscode/test-cliconfig per current VSCode extension testing guidelines; uses Mocha TDD interface withts-node+tsconfig-paths@vscode/test-cli,@vscode/test-electron,@types/mocha,ts-node,tsconfig-pathsnpm testnow runs lint + unit tests;npm run test:unitruns the Mocha suite directly (no VSCode host required);npm run test:vscoderuns the fullvscode-testlauncher when a VSCode environment is available.github/workflows/code-test.yml— enhanced to runnpm run test:unitafter the lint step so every CI run onmain,develop, andhotfixexecutes the full test suiteTest suites (140 tests)
mcdev.convertPathsToFiles.test.tsCovers path parsing for every selection level and top-level folder:
.../retrieve/cred/bu/email/key.email-meta.jsonfile.../retrieve/cred/bu/emailmdt_folder.../retrieve/cred/bubu_folder.../retrieve/credcred_folder.../retrievetop_folderTests single, multiple, mixed, asset subtypes, and both
/retrieve/and/deploy/roots.mcdev.mapToCommandFileParameters.test.tsTests the critical bridge that converts
IExecuteFileDetails[](output ofconvertPathsToFiles) intoICommandFileParameters[](input to command builders). Covers:top_folder → "*",cred_folder → "cred/*",bu_folder → "cred/bu",mdt_folder/file → "cred/bu")convertPathsToFilesoutput correctly fed intomapToCommandFileParametersmcdev.isActionSupportedForType.test.tsTests the action-blocking mechanism that prevents commands from running on unsupported metadata types. Key invariants:
email(deprecated, retrieve-only):deploy,delete, andchangekeyare blockeddataExtension,automation: all actions allowedattributeGroup: retrieve-only; mutating actions blockedasset+ subtypes (asset-block,asset-message, etc.): subtype suffix resolved to base type; all actions allowedtrue) to support future action typescommands.standard.test.tsTests
retrieve,deploy,delete, andchangekeycommand builders with: 1 file, multiple files, 1 type folder, multiple type folders, mixed file+folder, and retrieve-vs-deploy folder distinctions. Also coversrun()dispatch. Key invariants verified:deployfrom/retrieve/→ injects--fromRetrieve; folder-level entries (no key) are filtered outchangekeyrequireschangeKeyFieldorchangeKeyValue; non-file entries filteredICommandFileParametersobjects are never mutatedrun(unknownCommand)returns empty config without throwingcommands.templating.test.tsTests
clone(Copy to BU) with same selection matrix plus BU folder and multi-target scenarios. Verifies--bf/--bt,--no-purge,--skipValidationflag placement. Also coversrun()dispatch.Bug fix
clonewas throwing"The property 'files' is missing"even whenfileswas present andtargetBusinessUnitwas the actually missing property. The two validations are now separate with accurate per-property error messages.Checklist
Before merge
npm run prepare-release(which runsnpm audit fix,npm run lint-ts,npm run lint:fix,git add,git commit)After merge
npm run version:major/minor/patchDocumentation
No documentation changes required.
Issues
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.