Skip to content

Issue 1416#1451

Merged
allanbowe merged 5 commits into
mainfrom
issue-1416
Jul 3, 2026
Merged

Issue 1416#1451
allanbowe merged 5 commits into
mainfrom
issue-1416

Conversation

@YuryShkoda

@YuryShkoda YuryShkoda commented Jul 3, 2026

Copy link
Copy Markdown
Member

Issue

Closes #1416

sasjs c producing an incorrect sasjsbuild/tests folder structure on Windows. Also covers two related test-infrastructure bugs (a hanging npm run test:mocked run and leftover test-fixture artifacts) surfaced while investigating and verifying the fix.

Intent

  1. Fix sasjs compile writing testSetUp/testTearDown to a nested, incorrect path on Windows instead of flattening them into sasjsbuild/tests/.
  2. Fix sasjs doc silently dropping the README content from generated docs on newer Doxygen versions.
  3. Fix npm run test:mocked hanging instead of completing, and stop several spec files from leaving real folders/files behind after each run.

Implementation

Windows path flattening (compileTestFile.ts)

testSetUp/testTearDown values in sasjsconfig.json are forward-slash paths by convention, but the destination-flattening logic split only on path.sep (\ on Windows). A forward-slash string was left untouched by that split, producing sasjsbuild/tests/sasjs/tests/testsetup.sas instead of the expected flat sasjsbuild/tests/testsetup.sas. Extracted the logic into getTestFileDestinationFragment, which splits on both / and \ regardless of host OS.

Doxygen mainpage matching (generateDocs.ts, Doxyfile)

Doxygen matches USE_MDFILE_AS_MAINPAGE against the file's path exactly as it appears in INPUT. The Doxyfile hardcoded a bare README.md while INPUT carried an absolute path, so newer Doxygen versions no longer matched them and silently dropped the README content. Introduced a DOXY_MAINPAGE env var set to the same absolute path used in DOXY_INPUT, keeping the two in sync.

Test suite hang and leftover artifacts

  • jobCommand.spec.ts's deprecation-warning test lived outside its protective describe/beforeEach block, so it hit a real, unmocked process.exit(2) in TargetCommand.getTargetInfo() — killing the Jest worker mid-suite. Moved it into the correctly-mocked block.
  • create.spec.ts/init.spec.ts called deleteFolder() with a glob string, which the function doesn't support (it takes a literal path) — every test's real folder was silently left on disk. Now deletes the actual folder each test creates.
  • downloadFile()'s wget/curl calls ignored the requested filename on Linux/macOS, so createTemplateApp's repo-existence probe wrote a stray file at the repo root (e.g. template_jobs) instead of a discarded response.txt. Filename is now passed through explicitly and the probe file is deleted after use.

Other

  • Added unit tests for several previously-uncovered utils.ts functions to restore branch coverage lost when the jobCommand.spec.ts fix removed a test that was accidentally exercising TargetCommand's error paths.
  • Added docs/diagrams/sasjs-compile.md and docs/diagrams/sasjs-doc.md — mermaid reference diagrams of the current sasjs compile/sasjs doc command logic, for use as context in future AI-assisted work.

Checks

  • Code is formatted correctly (npm run lint:fix).
  • Any new functionality has been unit tested.
  • All unit tests are passing (npm test).
  • Unit tests coverage has been increased and a new threshold is set.
  • All CI checks are green.
  • Development comments have been added or updated.
  • Development documentation coverage has been increased and a new threshold is set.
  • Reviewer is assigned.

Reviewer checks

  • Any new code is documented.

… compile

sasjsconfig.json's testConfig.testSetUp/testTearDown are conventionally
forward-slash paths, but compileTestFile's destination logic split only on
path.sep. On Windows (path.sep === '\'), a forward-slash-only config value
was left untouched by the split, producing a nested
sasjsbuild/tests/sasjs/tests/testsetup.sas instead of the expected flat
sasjsbuild/tests/testsetup.sas.

Extracts the destination-path computation into getTestFileDestinationFragment,
which splits on both '/' and '\' regardless of host OS, and adds unit tests
covering the flattening/reduce logic against both separator styles plus the
exact real-world config from issue 1416.
…ering

Doxygen matches USE_MDFILE_AS_MAINPAGE against the file's path exactly as it
appears in INPUT. The Doxyfile hardcoded a bare "README.md" while INPUT
carried an absolute path, so newer Doxygen versions (see doxygen/doxygen#10110)
silently failed to match them and dropped the README content instead of using
it as the generated docs' main page.

Introduces a DOXY_MAINPAGE env var set to the same absolute path used in
DOXY_INPUT, keeping the two in sync regardless of Doxygen version. Adds a
regression test covering the missing-mainpage scenario, plus a mermaid
reference diagram of the current 'sasjs doc' command flow for context
injection.
…/glob bugs

Three related test-infrastructure bugs, found while chasing a hanging
`npm run test:mocked` run:

- jobCommand.spec.ts's deprecation-warning test lived outside the describe
  block that mocks findTargetInConfiguration/process.exit. It only "passed"
  by leaking process.logger state from a prior test; the real
  findTargetInConfiguration still ran and hit an unmocked process.exit(2) in
  TargetCommand.getTargetInfo(), killing the Jest worker mid-suite. Moved the
  test into the correctly-mocked describe block.

- create.spec.ts/init.spec.ts's afterEach called deleteFolder() with a glob
  string ('test-app-create-*'), but deleteFolder() takes a literal path and
  silently no-ops on the non-existent literal folder, leaving every test's
  real timestamped folder on disk. Deletes process.projectDir (the actual
  folder each test creates) instead.

- downloadFile()'s wget/curl calls ignored the requested `filename` on
  Linux/macOS (using bare `wget`/`curl -O`, which save under the remote URL's
  basename instead). createTemplateApp's repo-existence probe therefore wrote
  a stray file at the repo root named after the template (e.g. `template_jobs`)
  instead of the intended, discarded `response.txt`. Passes filename through
  explicitly (`wget -O`/`curl -o`) and deletes the probe file after use.

Also adds unit tests for several previously-uncovered utils.ts functions
(prefixAppLoc, isSASjsProject, getNodeModulePath, getUniqServicesObj,
convertToSASStatements, terminateProcess, isSasJsServerInServerMode, and an
empty-.gitignore edge case) to restore branch coverage lost when the
jobCommand.spec.ts fix removed a test that was accidentally exercising
TargetCommand's error paths.
@YuryShkoda YuryShkoda self-assigned this Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Coverage report

Total coverage

Status Category Percentage Covered / Total
🟡 Statements 73.96% 3338/4513
🟡 Branches 60.55% 1320/2180
🟡 Functions 74.02% 678/916
🟢 Lines 82.7% 8471/10243

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Report generated by 🧪jest coverage report action from cd60b30

@YuryShkoda YuryShkoda marked this pull request as ready for review July 3, 2026 09:25
@allanbowe allanbowe merged commit ec4fb25 into main Jul 3, 2026
2 checks passed
@allanbowe allanbowe deleted the issue-1416 branch July 3, 2026 12:04
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.

'sasjs c' - sasjsbuild/tests folder misconfigured

3 participants