@@ -27,6 +27,25 @@ const tempDirs = createTrackedTempDirs();
2727let testState : OpenClawTestState ;
2828let stateDir = "" ;
2929
30+ async function proposalArtifactPath (
31+ proposalId : string ,
32+ relativePath : string ,
33+ options : { stateDir ?: string ; env ?: NodeJS . ProcessEnv } = { } ,
34+ ) : Promise < string > {
35+ const record = await readSkillProposalRecord ( proposalId , options . env ? { env : options . env } : { } ) ;
36+ if ( ! record ) {
37+ throw new Error ( `expected stored proposal ${ proposalId } ` ) ;
38+ }
39+ return path . join (
40+ options . stateDir ?? stateDir ,
41+ "skill-workshop" ,
42+ "proposals" ,
43+ proposalId ,
44+ path . dirname ( record . draftFile ) ,
45+ relativePath ,
46+ ) ;
47+ }
48+
3049beforeEach ( async ( ) => {
3150 testState = await createOpenClawTestState ( {
3251 layout : "state-only" ,
@@ -312,7 +331,10 @@ describe("skill_workshop tool", () => {
312331
313332 await expect (
314333 fs . access (
315- path . join ( isolatedStateDir , "skill-workshop" , "proposals" , proposalId , "PROPOSAL.md" ) ,
334+ await proposalArtifactPath ( proposalId , "PROPOSAL.md" , {
335+ stateDir : isolatedStateDir ,
336+ env,
337+ } ) ,
316338 ) ,
317339 ) . resolves . toBeUndefined ( ) ;
318340 await expect (
@@ -521,6 +543,7 @@ describe("skill_workshop tool", () => {
521543 status : "pending" ,
522544 kind : "create" ,
523545 skillKey : "weather-planner" ,
546+ proposalFile : "PROPOSAL.md" ,
524547 scanState : "clean" ,
525548 supportFileCount : 1 ,
526549 } ) ;
@@ -529,27 +552,13 @@ describe("skill_workshop tool", () => {
529552 ) ;
530553 await expect (
531554 fs . readFile (
532- path . join (
533- stateDir ,
534- "skill-workshop" ,
535- "proposals" ,
536- ( result . details as { id : string } ) . id ,
537- "PROPOSAL.md" ,
538- ) ,
555+ await proposalArtifactPath ( ( result . details as { id : string } ) . id , "PROPOSAL.md" ) ,
539556 "utf8" ,
540557 ) ,
541558 ) . resolves . toContain ( "status: proposal" ) ;
542559 await expect (
543560 fs
544- . readFile (
545- path . join (
546- stateDir ,
547- "skill-workshop" ,
548- "proposals" ,
549- ( result . details as { id : string } ) . id ,
550- "PROPOSAL.md" ,
551- ) ,
552- )
561+ . readFile ( await proposalArtifactPath ( ( result . details as { id : string } ) . id , "PROPOSAL.md" ) )
553562 . then ( ( buffer ) => buffer . at ( - 1 ) ) ,
554563 ) . resolves . toBe ( 0x0a ) ;
555564 await expect (
@@ -563,14 +572,7 @@ describe("skill_workshop tool", () => {
563572 } ) ;
564573 await expect (
565574 fs . readFile (
566- path . join (
567- stateDir ,
568- "skill-workshop" ,
569- "proposals" ,
570- ( result . details as { id : string } ) . id ,
571- "references" ,
572- "weather.md" ,
573- ) ,
575+ await proposalArtifactPath ( ( result . details as { id : string } ) . id , "references/weather.md" ) ,
574576 "utf8" ,
575577 ) ,
576578 ) . resolves . toContain ( "Use weather API details." ) ;
@@ -615,13 +617,7 @@ describe("skill_workshop tool", () => {
615617 ) ;
616618 await expect (
617619 fs . readFile (
618- path . join (
619- stateDir ,
620- "skill-workshop" ,
621- "proposals" ,
622- ( result . details as { id : string } ) . id ,
623- "PROPOSAL.md" ,
624- ) ,
620+ await proposalArtifactPath ( ( result . details as { id : string } ) . id , "PROPOSAL.md" ) ,
625621 "utf8" ,
626622 ) ,
627623 ) . resolves . toContain ( 'version: "v2"' ) ;
@@ -733,15 +729,7 @@ describe("skill_workshop tool", () => {
733729
734730 await expect (
735731 fs
736- . readFile (
737- path . join (
738- stateDir ,
739- "skill-workshop" ,
740- "proposals" ,
741- ( result . details as { id : string } ) . id ,
742- "PROPOSAL.md" ,
743- ) ,
744- )
732+ . readFile ( await proposalArtifactPath ( ( result . details as { id : string } ) . id , "PROPOSAL.md" ) )
745733 . then ( ( buffer ) => buffer . at ( - 1 ) ) ,
746734 ) . resolves . toBe ( 0x0a ) ;
747735 } ) ;
0 commit comments