11import { execSync } from 'child_process' ;
2- import path , { join } from 'path' ;
2+ import path from 'path' ;
33import * as fs from 'fs' ;
44import * as os from 'os' ;
55import { execa } from 'execa' ;
66import { parseStringPromise } from 'xml2js' ;
77import axios from 'axios' ;
88import { expectDirectoryMatch , expectFilesMatch } from '@finos/calm-shared' ;
99import { spawn } from 'node:child_process' ;
10+ import { STATIC_GETTING_STARTED_MAPPING_PATH } from './test_helpers/getting-started-url-mapping' ;
1011
1112const millisPerSecond = 1000 ;
1213const integrationTestPrefix = 'calm-consumer-test' ;
1314let tempDir : string ;
1415const repoRoot = path . resolve ( __dirname ) ;
16+ const GETTING_STARTED_DIR = path . resolve (
17+ __dirname ,
18+ '../../calm/getting-started'
19+ ) ;
20+ const GETTING_STARTED_TEST_FIXTURES_DIR = path . resolve (
21+ __dirname ,
22+ '../test_fixtures/getting-started'
23+ ) ;
1524
1625function run ( file : string , args : string [ ] ) {
1726 const cp = execa ( file , args , { cwd : tempDir } ) ;
@@ -438,30 +447,35 @@ describe('CLI Integration Tests', () => {
438447
439448 await expectDirectoryMatch ( expectedOutputDir , actualOutputDir ) ;
440449 } ) ;
441-
442-
450+ // Docify widget rendering verifies every template keeps working with the
451+ // getting-started assets bundled in the repo, so we use the static mapping
452+ // to avoid hitting the public site during CI.
443453 describe ( 'calm docify command - widget rendering' , ( ) => {
444454 function runTemplateWidgetTest ( templateName : string , outputName : string ) {
445455 return async ( ) => {
446456
447- const GETTING_STARTED_TEST_FIXTURES_DIR = join (
448- __dirname ,
449- '../../cli/test_fixtures/getting-started'
450- ) ;
451-
452457 const testModelPath = path . resolve (
453458 GETTING_STARTED_TEST_FIXTURES_DIR ,
454459 'STEP-3/conference-signup-with-flow.arch.json'
455460 ) ;
456-
457461 const fixtureDir = path . resolve ( __dirname , '../test_fixtures/template' ) ;
458462 const templatePath = path . join ( fixtureDir , `widget-tests/${ templateName } ` ) ;
459463 const expectedOutputPath = path . join ( fixtureDir , `expected-output/widget-tests/${ outputName } ` ) ;
460464 const outputDir = path . join ( tempDir , 'widget-tests' ) ;
461465 const outputFile = path . join ( outputDir , outputName ) ;
462466
463467 await run (
464- calm ( ) , [ 'docify' , '--architecture' , testModelPath , '--template' , templatePath , '--output' , outputFile ]
468+ calm ( ) , [
469+ 'docify' ,
470+ '--architecture' ,
471+ testModelPath ,
472+ '--template' ,
473+ templatePath ,
474+ '--output' ,
475+ outputFile ,
476+ '--url-to-local-file-mapping' ,
477+ STATIC_GETTING_STARTED_MAPPING_PATH ,
478+ ]
465479 ) ;
466480
467481 expect ( fs . existsSync ( outputFile ) ) . toBe ( true ) ;
@@ -488,15 +502,8 @@ describe('CLI Integration Tests', () => {
488502
489503
490504 test ( 'Getting Started Verification - CLI Steps' , async ( ) => {
491- const GETTING_STARTED_DIR = join (
492- __dirname ,
493- '../../calm/getting-started'
494- ) ;
495- const GETTING_STARTED_TEST_FIXTURES_DIR = join (
496- __dirname ,
497- '../../cli/test_fixtures/getting-started'
498- ) ;
499-
505+ // This flow mirrors the public Getting Started guide to ensure the
506+ // documentation actually works when the CLI resolves URLs locally.
500507 //STEP 1: Generate Architecture From Pattern
501508 const inputPattern = path . resolve (
502509 GETTING_STARTED_DIR ,
@@ -517,7 +524,15 @@ describe('CLI Integration Tests', () => {
517524 //STEP 2: Generate Docify Website From Architecture
518525 const outputWebsite = path . resolve ( tempDir , 'website' ) ;
519526 await run (
520- calm ( ) , [ 'docify' , '--architecture' , outputArchitecture , '--output' , outputWebsite ]
527+ calm ( ) , [
528+ 'docify' ,
529+ '--architecture' ,
530+ outputArchitecture ,
531+ '--output' ,
532+ outputWebsite ,
533+ '--url-to-local-file-mapping' ,
534+ STATIC_GETTING_STARTED_MAPPING_PATH ,
535+ ]
521536 ) ;
522537
523538 const expectedOutputDocifyWebsite = path . resolve (
@@ -570,7 +585,15 @@ describe('CLI Integration Tests', () => {
570585 'website-with-flow'
571586 ) ;
572587 await run (
573- calm ( ) , [ 'docify' , '--architecture' , outputArchitecture , '--output' , outputWebsiteWithFlow ]
588+ calm ( ) , [
589+ 'docify' ,
590+ '--architecture' ,
591+ outputArchitecture ,
592+ '--output' ,
593+ outputWebsiteWithFlow ,
594+ '--url-to-local-file-mapping' ,
595+ STATIC_GETTING_STARTED_MAPPING_PATH ,
596+ ]
574597 ) ;
575598
576599 const expectedOutputDocifyWebsiteWithFLow = path . resolve (
0 commit comments