Skip to content

#314 [TASK] Add test classes to ensure future changes do not introduce regressions#315

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/add-test-classes
Closed

#314 [TASK] Add test classes to ensure future changes do not introduce regressions#315
Copilot wants to merge 4 commits intomainfrom
copilot/add-test-classes

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

No automated tests existed — npm test only 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-cli config per current VSCode extension testing guidelines; uses Mocha TDD interface with ts-node + tsconfig-paths
  • New dev deps: @vscode/test-cli, @vscode/test-electron, @types/mocha, ts-node, tsconfig-paths
  • npm test now runs lint + unit tests; npm run test:unit runs the Mocha suite directly (no VSCode host required); npm run test:vscode runs the full vscode-test launcher when a VSCode environment is available
  • .github/workflows/code-test.yml — enhanced to run npm run test:unit after the lint step so every CI run on main, develop, and hotfix executes the full test suite

Test suites (140 tests)

mcdev.convertPathsToFiles.test.ts

Covers path parsing for every selection level and top-level folder:

Input path Expected level
.../retrieve/cred/bu/email/key.email-meta.json file
.../retrieve/cred/bu/email mdt_folder
.../retrieve/cred/bu bu_folder
.../retrieve/cred cred_folder
.../retrieve top_folder

Tests single, multiple, mixed, asset subtypes, and both /retrieve/ and /deploy/ roots.

mcdev.mapToCommandFileParameters.test.ts

Tests the critical bridge that converts IExecuteFileDetails[] (output of convertPathsToFiles) into ICommandFileParameters[] (input to command builders). Covers:

  • Credential format for every selection level (top_folder → "*", cred_folder → "cred/*", bu_folder → "cred/bu", mdt_folder/file → "cred/bu")
  • Metadata array content per level (file → key=filename, mdt_folder → key="", higher levels → empty array)
  • Same-BU grouping (multiple files/folders from same BU combined into one credential group)
  • Separation across different BUs, projects, and topFolders
  • End-to-end pipeline: convertPathsToFiles output correctly fed into mapToCommandFileParameters

mcdev.isActionSupportedForType.test.ts

Tests the action-blocking mechanism that prevents commands from running on unsupported metadata types. Key invariants:

  • email (deprecated, retrieve-only): deploy, delete, and changekey are blocked
  • dataExtension, automation: all actions allowed
  • attributeGroup: retrieve-only; mutating actions blocked
  • asset + subtypes (asset-block, asset-message, etc.): subtype suffix resolved to base type; all actions allowed
  • Unknown folder names: always blocked for all known actions
  • Unknown action names: permissive (true) to support future action types

commands.standard.test.ts

Tests retrieve, deploy, delete, and changekey command builders with: 1 file, multiple files, 1 type folder, multiple type folders, mixed file+folder, and retrieve-vs-deploy folder distinctions. Also covers run() dispatch. Key invariants verified:

  • deploy from /retrieve/ → injects --fromRetrieve; folder-level entries (no key) are filtered out
  • changekey requires changeKeyField or changeKeyValue; non-file entries filtered
  • Input ICommandFileParameters objects are never mutated
  • run(unknownCommand) returns empty config without throwing

commands.templating.test.ts

Tests clone (Copy to BU) with same selection matrix plus BU folder and multi-target scenarios. Verifies --bf/--bt, --no-purge, --skipValidation flag placement. Also covers run() dispatch.

Bug fix

clone was throwing "The property 'files' is missing" even when files was present and targetBusinessUnit was the actually missing property. The two validations are now separate with accurate per-property error messages.

Checklist

Before merge

  • Wiki updated with info in ticket listed under Documentation
  • ran npm run prepare-release (which runs npm audit fix, npm run lint-ts, npm run lint:fix, git add, git commit)
  • pushed potential changes made by prepare-release

After merge

  • merged all dependabot PRs that target main branch
  • ran npm run version:major/minor/patch
  • pushed version-prep commits
  • merged main branch into develop branch
  • closed GitHub milestone
  • created new GitHub Release

Documentation

No documentation changes required.

Issues

Original prompt

This section details on the original issue you should resolve

<issue_title>[TASK] add test classes to ensure future changes do not introduce regressions</issue_title>
<issue_description>ensure to use most current guidelines for testing of vscode extensions as defined on https://code.visualstudio.com/api/working-with-extensions/testing-extension

Make sure every command is tested with

  • 1 selected file
  • multiple selected files
  • 1 selected type folder
  • multiple selected type folders
  • 1 selected BU folder
  • multiple selected BU folders
  • a mix of the above
  • for files & folders ./retrieve as well as in ./deploy

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 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.

@JoernBerkefeld
Copy link
Contributor

@copilot make sure to prefix commits and pr title with "#314 "

@JoernBerkefeld
Copy link
Contributor

@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>
Copilot AI changed the title [WIP] Add test classes to ensure no regressions in vscode extensions [TASK] Add test classes to ensure future changes do not introduce regressions Mar 19, 2026
Copilot AI requested a review from JoernBerkefeld March 19, 2026 18:51
Copy link
Contributor Author

Copilot AI commented Mar 19, 2026

@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

Done in commit 2014a33. The code-test.yml workflow now runs npm run test:unit after the lint step so every CI run executes all 83 unit tests. The test:unit npm script in package.json also serves as a VS Code-discoverable NPM task for local runs.

@copilot make sure to prefix commits and pr title with "#314 "

The workflow enhancement commit (2014a33) carries the #314 prefix. The initial test-infrastructure commit (63d7478) was already published to the remote branch before this request, so it can't be rewritten without a force-push. All future commits on this PR will carry the prefix.

Copilot AI changed the title [TASK] Add test classes to ensure future changes do not introduce regressions #314 [TASK] Add test classes to ensure future changes do not introduce regressions Mar 19, 2026
@JoernBerkefeld
Copy link
Contributor

@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>
Copy link
Contributor Author

Copilot AI commented Mar 19, 2026

@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 expec...

Reviewed carefully and found three gaps. Addressed in commit 1db249c:

Gaps found and fixed:

  1. mapToCommandFileParameters (critical bridge) — was never tested. This method transforms IExecuteFileDetails[] (from convertPathsToFiles) into ICommandFileParameters[] (fed into command builders). A bug here would silently produce wrong mcdev commands. New suite mcdev.mapToCommandFileParameters.test.ts (27 tests) covers credential format per selection level, metadata array content, same-BU grouping, cross-BU/project/topFolder separation, and a full end-to-end convertPathsToFiles → mapToCommandFileParameters pipeline.

  2. isActionSupportedForType (the blocking mechanism) — was never tested. This is what prevents deploy/delete/changekey from running on unsupported types. For example, email only supports retrieve — the other actions are blocked. New suite mcdev.isActionSupportedForType.test.ts (29 tests) verifies blocked and allowed actions for email, dataExtension, automation, attributeGroup, asset subtypes, unknown types (always blocked), and unknown action names (permissive).

  3. run() dispatch in both command classes — was never tested. Added 5 dispatch tests to commands.standard.test.ts and 2 to commands.templating.test.ts.

Bug also fixed: clone was throwing "The property 'files' is missing" when targetBusinessUnit was the missing property. Separated the two validation checks with accurate messages; the corresponding test was updated to assert the correct error.

Total: 140 tests (was 83).

@JoernBerkefeld JoernBerkefeld added this to the 2.7.0 milestone Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] add test classes to ensure future changes do not introduce regressions

2 participants