@@ -770,19 +770,22 @@ fn proposal_review_summary_markdown(
770770 {
771771 if !reviewed_commits. is_empty ( ) {
772772 md_content. push_str ( "\n Commits review:\n " ) ;
773+
774+ const INDENT : & str = " " ;
775+
773776 let mut commits_list = String :: new ( ) ;
774777 for ( _, commit) in reviewed_commits {
775778 if let Some ( state) = commit. reviewed_state ( ) {
776779 let mut commit_sha = commit. commit_sha . to_string ( ) ;
777780 commit_sha. truncate ( 9 ) ;
778781 commits_list. push_str ( & format ! (
779- "- **{}**:\n \t {}\n " ,
782+ "- **{}**:\n {INDENT} {}\n " ,
780783 commit_sha,
781784 state
782785 . to_string( )
783786 . lines( )
784787 . collect:: <Vec <& str >>( )
785- . join( "\n \t " )
788+ . join( & format! ( "\n {INDENT}" ) )
786789 ) ) ;
787790 }
788791 }
@@ -801,7 +804,8 @@ mod tests {
801804 repositories:: {
802805 ImageId , MockCertificationRepository , MockImageRepository , MockProposalRepository ,
803806 MockProposalReviewCommitRepository , MockProposalReviewRepository ,
804- MockUserProfileRepository , ProposalReviewId , IMAGES_BASE_PATH ,
807+ MockUserProfileRepository , NervousSystem , ProposalReviewId , ReviewCommitState ,
808+ ReviewedCommitState , IMAGES_BASE_PATH ,
805809 } ,
806810 } ;
807811 use backend_api:: {
@@ -2463,4 +2467,115 @@ mod tests {
24632467 ) ,
24642468 )
24652469 }
2470+
2471+ #[ fixture]
2472+ fn basic_proposal ( ) -> Proposal {
2473+ let proposal = fixtures:: nns_replica_version_management_proposal ( None , None ) ;
2474+ Proposal {
2475+ nervous_system : match proposal. nervous_system {
2476+ NervousSystem :: Network { proposal_info, .. } => NervousSystem :: Network {
2477+ proposal_id : 123 ,
2478+ proposal_info,
2479+ } ,
2480+ } ,
2481+ ..proposal
2482+ }
2483+ }
2484+
2485+ #[ fixture]
2486+ fn basic_review ( ) -> ProposalReview {
2487+ ProposalReview {
2488+ vote : ProposalVote :: Yes ,
2489+ summary : Some ( "Test summary" . to_string ( ) ) ,
2490+ build_reproduced : Some ( true ) ,
2491+ ..fixtures:: proposal_review_published ( )
2492+ }
2493+ }
2494+
2495+ #[ fixture]
2496+ fn reviewed_commits ( ) -> Vec < ( ProposalReviewCommitId , ProposalReviewCommit ) > {
2497+ vec ! [
2498+ (
2499+ fixtures:: uuid( ) ,
2500+ ProposalReviewCommit {
2501+ commit_sha: fixtures:: commit_sha_a( ) ,
2502+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2503+ matches_description: Some ( true ) ,
2504+ comment: Some ( "Good commit" . to_string( ) ) ,
2505+ highlights: vec![ "Feature A" . to_string( ) , "Bug fix B" . to_string( ) ] ,
2506+ } ) ,
2507+ ..fixtures:: proposal_review_commit_reviewed( )
2508+ } ,
2509+ ) ,
2510+ (
2511+ fixtures:: uuid( ) ,
2512+ ProposalReviewCommit {
2513+ commit_sha: fixtures:: commit_sha_b( ) ,
2514+ state: ReviewCommitState :: Reviewed ( ReviewedCommitState {
2515+ matches_description: Some ( false ) ,
2516+ comment: Some ( "Issues found" . to_string( ) ) ,
2517+ highlights: vec![ "Missing tests" . to_string( ) ] ,
2518+ } ) ,
2519+ ..fixtures:: proposal_review_commit_reviewed( )
2520+ } ,
2521+ ) ,
2522+ (
2523+ fixtures:: uuid( ) ,
2524+ ProposalReviewCommit {
2525+ commit_sha: fixtures:: commit_sha_c( ) ,
2526+ state: ReviewCommitState :: NotReviewed ,
2527+ ..fixtures:: proposal_review_commit_reviewed( )
2528+ } ,
2529+ ) ,
2530+ ]
2531+ }
2532+
2533+ #[ fixture]
2534+ fn images_paths ( ) -> Vec < String > {
2535+ vec ! [
2536+ "/images/13449503-1b2f-4b92-8346-8e843253e842.png" . to_string( ) ,
2537+ "/images/68362227-6f0f-4fb4-b80a-0bfa53a9e99b.png" . to_string( ) ,
2538+ ]
2539+ }
2540+
2541+ #[ rstest]
2542+ fn test_proposal_review_summary_markdown ( ) {
2543+ let basic_proposal = basic_proposal ( ) ;
2544+ let basic_review = basic_review ( ) ;
2545+ let reviewed_commits = reviewed_commits ( ) ;
2546+ let images_paths = images_paths ( ) ;
2547+ let markdown = proposal_review_summary_markdown (
2548+ & basic_proposal,
2549+ & basic_review,
2550+ & reviewed_commits,
2551+ & images_paths,
2552+ ) ;
2553+
2554+ assert_eq ! (
2555+ markdown,
2556+ r#"# Proposal 123
2557+
2558+ Vote: ADOPTED
2559+ Hashes match: true
2560+ All reviewed commits match their descriptions: false
2561+
2562+ 
2563+
2564+ 
2565+
2566+ Summary:
2567+ Test summary
2568+
2569+ Commits review:
2570+ - **28111ed23**:
2571+ Matches description: true
2572+ Comment: Good commit
2573+ Highlights: Feature A, Bug fix B
2574+ - **47d98477c**:
2575+ Matches description: false
2576+ Comment: Issues found
2577+ Highlights: Missing tests
2578+ "#
2579+ ) ;
2580+ }
24662581}
0 commit comments